Closed
Description
TypeScript Version: 3.6.0-dev.20190726
Search Terms:
type inference
Code
declare function f(x: string | undefined): string;
declare function id<T>(x: T): T;
let state: undefined | string = undefined;
while (true) {
const x = id(f(state));
state = x;
}
// A *self-contained* demonstration of the problem follows...
// Test this by running `tsc` on the command-line, rather than through another build tool such as Gulp, Webpack, etc.
Expected behavior:
x: string
Actual behavior:
'x' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.
Related Issues: