Skip to content

Disallow type predicates as union type members #5903

Closed
@weswigham

Description

@weswigham
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.

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions