Why is the new generics in TypeScript 2.4 causing this to fail?

六眼飞鱼酱① 提交于 2019-12-25 18:34:09

问题


So I understand that with TS 2.4 we get trickter generic checks. But what I don't understand is why now I get with this:

getChannelBlockModels(i_campaign_timeline_chanel_id): Observable<List<CampaignTimelineChanelPlayersModel>> {
        return this.store.select(store => store.msDatabase.sdk.table_campaign_timeline_chanel_players)
            .map((campaignTimelineChanelPlayersModels: List<CampaignTimelineChanelPlayersModel>) => {
                return campaignTimelineChanelPlayersModels.filter(campaignTimelineChanelsModel => {
                    return campaignTimelineChanelsModel.getCampaignTimelineChanelId() == i_campaign_timeline_chanel_id;
                })
            }).take(1);
    }

this error:

Error:(806, 9) TS2322:Type 'Observable<Iterable<number, CampaignTimelineChanelPlayersModel>>' is not assignable to type 'Observable<List<CampaignTimelineChanelPlayersModel>>'.
  Type 'Iterable<number, CampaignTimelineChanelPlayersModel>' is not assignable to type 'List<CampaignTimelineChanelPlayersModel>'.
    Property 'set' is missing in type 'Iterable<number, CampaignTimelineChanelPlayersModel>'.

as I am returning Observable<List<CampaignTimelineChanelPlayersModel>> so why isn't TS happy?

来源:https://stackoverflow.com/questions/45153925/why-is-the-new-generics-in-typescript-2-4-causing-this-to-fail

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