Skip to content

Commit c7b1e27

Browse files
rafaelss95jelbourn
authored andcommitted
docs: adjust types in autocomplete-display-example (#9240)
1 parent 310da32 commit c7b1e27

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/material-examples/autocomplete-display/autocomplete-display-example.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ export class AutocompleteDisplayExample {
3131
ngOnInit() {
3232
this.filteredOptions = this.myControl.valueChanges
3333
.pipe(
34-
startWith({} as User),
35-
map(user => user && typeof user === 'object' ? user.name : user),
34+
startWith<string | User>(''),
35+
map(value => typeof value === 'string' ? value : value.name),
3636
map(name => name ? this.filter(name) : this.options.slice())
3737
);
3838
}
@@ -42,8 +42,8 @@ export class AutocompleteDisplayExample {
4242
option.name.toLowerCase().indexOf(name.toLowerCase()) === 0);
4343
}
4444

45-
displayFn(user: User): string {
46-
return user ? user.name : user;
45+
displayFn(user?: User): string | undefined {
46+
return user ? user.name : undefined;
4747
}
4848

4949
}

0 commit comments

Comments
 (0)