Skip to content

Type lost when using interfaces with filter, find, first, last #2163

@timblakely

Description

@timblakely

RxJS version: RC4

Code to reproduce:

interface Bar {
  bar?: string;
}
class Foo implements Bar {
  constructor(public bar: string = 'name') {}
}

let foo: Foo = new Foo();
Observable.of(foo)
    .filter(foo => foo.bar === 'name')
    .subscribe(foo => console.log(foo.bar));  <--- works fine

let foo2: Bar = new Foo(); <--- type is interface, not the class
Observable.of(foo2)
    .filter(foo => foo.bar === 'name')
    .subscribe(foo => console.log(foo.bar)); <-- "Property 'bar' does not exist on type '{}'"

Expected behavior:

Typing to be maintained through the filter() function.

Actual behavior:

Type is lost downstream from .filter,() instead being typed as '{}'

Additional information:

Worked in RC2. Occurs for all functions changed in RC3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions