Skip to content

publish's selector doesn't have return type captured in generics in TypeScript #2889

Closed
@benlesh

Description

@benlesh

RxJS version: 5.4.x

Code to reproduce:

const result: Observable<string> = of<number>(1, 2, 3).publish(source => source.map(x => x + '!'))
                                                                                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expected behavior:

No errors, proper type inferrence

Actual behavior:

error TS2345: Argument of type '(source: Observable<number>) => Observable<string>' is not assignable to parameter of type 'selector<number>'.
  Type 'Observable<string>' is not assignable to type 'Observable<number>'

Additional information:
TS 2.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    TSIssues and PRs related purely to TypeScript issuesbugConfirmed bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions