问题
As part of migrating my project from angular 5 to 6 I had to update the way RXJS6 does things.
So this
this.filteredList = this.autoComplete.valueChanges
.startWith(null)
.map(val => val ? this.filter(val) : this.list.slice());
changed to this
this.filteredList = this.autoComplete.valueChanges.pipe(
startWith(null),
map(val => val ? this.filter(val) : this.list.slice()));
It seems the compiler can't infer type anymore as I get
Severity Code Description Project File Line Suppression State
Error TS2345 (TS) Argument of type '{}' is not assignable to parameter of
type 'string'.
I get the same thing on all the pipeable
operators - none of them can tell the type of the data they are receiving. How do I help it out?
Interestingly enough this seems to be only an intellisense error is the code compiles and works fine.
来源:https://stackoverflow.com/questions/51845336/cant-infer-type-in-the-map-function