Skip to content

Should strictNullChecks be applicable with Observable filter operator? #12702

Closed
@goldenbearkin

Description

@goldenbearkin

TypeScript Version: 2.0.10

{
    "compilerOptions": {
        "module": "commonjs",
        "target": "es5",
        "strictNullChecks": true,
        "noImplicitAny": false,
        "sourceMap": false
    }
}

Code

const mixed = [1, 'one', null, undefined];

const $ = Observable.of(...mixed)
            .filter(x => x !== null)
            .filter(x => x !== undefined)
            .filter(x => typeof x !== 'string');

$.subscribe(x => console.log(x));  //  1

Expected behavior:
$ is in type (number)

Actual behavior:
$ is in type (string | number | null | undefined)

Activity

HerringtonDarkholme

HerringtonDarkholme commented on Dec 7, 2016

@HerringtonDarkholme
Contributor
added
Design LimitationConstraints of the existing architecture prevent this from being fixed
on Dec 8, 2016
mhegazy

mhegazy commented on Dec 8, 2016

@mhegazy
Contributor

there is not a way to represent this transformation to the type system. an option would be something like #12424

goldenbearkin

goldenbearkin commented on Jan 26, 2017

@goldenbearkin
Author

@mhegazy Could you please explain a little bit more? I still can't get my head around after looking at #12424...

locked and limited conversation to collaborators on Jun 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Design LimitationConstraints of the existing architecture prevent this from being fixed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @DanielRosenwasser@HerringtonDarkholme@mhegazy@goldenbearkin

        Issue actions

          Should strictNullChecks be applicable with Observable filter operator? · Issue #12702 · microsoft/TypeScript