TypeScript Version: 3.5.0-dev.20190412
Search Terms:
Code
Compile the following ts with --noImplicitAny
let x;
if (Date.now()) {
x = 1;
} else {
x = { obj: true };
}
foo(x);
function foo(y) { }
Expected behavior:
The declaration let x should produce an implicit any error
Actual behavior:
No error reported. After the assignment, the type of x is number | { obj: boolean }
Playground Link:
https://www.typescriptlang.org/play/#src=let%20x%3B%0D%0Aif%20(Date.now())%20%7B%0D%0A%20%20%20%20x%20%3D%201%3B%0D%0A%7D%20else%20%7B%0D%0A%20%20%20%20x%20%3D%20%7B%20obj%3A%20true%20%7D%3B%0D%0A%7D%0D%0A%0D%0Afoo(x)%3B%0D%0A%0D%0Afunction%20foo(y)%20%7B%20%7D
Related Issues:
From microsoft/vscode#72193
TypeScript Version: 3.5.0-dev.20190412
Search Terms:
Code
Compile the following ts with
--noImplicitAnyExpected behavior:
The declaration
let xshould produce an implicit any errorActual behavior:
No error reported. After the assignment, the type of
xisnumber | { obj: boolean }Playground Link:
https://www.typescriptlang.org/play/#src=let%20x%3B%0D%0Aif%20(Date.now())%20%7B%0D%0A%20%20%20%20x%20%3D%201%3B%0D%0A%7D%20else%20%7B%0D%0A%20%20%20%20x%20%3D%20%7B%20obj%3A%20true%20%7D%3B%0D%0A%7D%0D%0A%0D%0Afoo(x)%3B%0D%0A%0D%0Afunction%20foo(y)%20%7B%20%7D
Related Issues:
From microsoft/vscode#72193