Can't infer type in the map function

本小妞迷上赌 提交于 2019-12-11 12:04:49

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!