-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Open
Labels
BugA bug in TypeScriptA bug in TypeScriptHas ReproThis issue has compiler-backed repros: https://aka.ms/ts-reprosThis issue has compiler-backed repros: https://aka.ms/ts-repros
Milestone
Description
TypeScript Version: 4.0
Search Terms:
Code
interface A {
type:'A'
}
interface B {
type:'B'
}
function assert(x:any) :asserts x is A|B{
}
function foo(x: any): any {
x; // any
assert(x);
x; // A | B
if (x.type === 'A') {
return x;
}
x; // B
if (x.type === 'B') {
return x;
}
x; // B, but should be never.
// ^?
}
Expected behavior:
the last x should be never.
Actual behavior:
still B.
Related Issues:
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptHas ReproThis issue has compiler-backed repros: https://aka.ms/ts-reprosThis issue has compiler-backed repros: https://aka.ms/ts-repros