Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should strictNullChecks be applicable with Observable filter operator? #12702

Closed
goldenbearkin opened this issue Dec 7, 2016 · 3 comments
Closed
Labels
Design Limitation Constraints of the existing architecture prevent this from being fixed

Comments

@goldenbearkin
Copy link

goldenbearkin commented Dec 7, 2016

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)

@HerringtonDarkholme
Copy link
Contributor

Related: #9998 (comment)

@mhegazy mhegazy added the Design Limitation Constraints of the existing architecture prevent this from being fixed label Dec 8, 2016
@mhegazy
Copy link
Contributor

mhegazy commented Dec 8, 2016

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

@goldenbearkin
Copy link
Author

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

@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Design Limitation Constraints of the existing architecture prevent this from being fixed
Projects
None yet
Development

No branches or pull requests

4 participants