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

Disallow type predicates as union type members #5903

Closed
weswigham opened this issue Dec 2, 2015 · 0 comments
Closed

Disallow type predicates as union type members #5903

weswigham opened this issue Dec 2, 2015 · 0 comments
Assignees
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@weswigham
Copy link
Member

function isA<A>(x: any, y: any): x is A | y is B {
    return false;
}

var x: number | number[];
var y: string | string[];

if (isA<number>(x, y)) {
    x, y;
}
else {
    x, y;
}

It makes no sense, but parses correctly, doesn't error (despite the missing identifier), and shows up in quick info as boolean.

@weswigham weswigham added the Bug A bug in TypeScript label Dec 2, 2015
@weswigham weswigham assigned weswigham and sandersn and unassigned weswigham Dec 2, 2015
@weswigham weswigham changed the title Disallow type guards return types as union type members Disallow type predicates as union type members Dec 3, 2015
@mhegazy mhegazy added this to the TypeScript 1.8 milestone Dec 3, 2015
@mhegazy mhegazy added the Fixed A PR has been merged for this issue label Jan 13, 2016
@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
Bug A bug in TypeScript Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

3 participants