TypeScript Version: 2.8.1
Code
// Compile with --strictinterfaceIFoo{a?: number[],}letfoo: IFoo={a: []};// error: Object is possible 'undefined'foo.a.push(4);// this will work// foo.a = [];// foo.a.push(5) // no errors// alternatively,foo!.a.push(3);Expected behavior:
The compiler should be able to infer using the object initialization that foo.a is defined.
Actual behavior:
The compiler ignores the initialization of property 'a'.
Playground Link:Playground link (use strict check in options)
Related Issues:
TypeScript Version: 2.8.1
Code
Expected behavior:
The compiler should be able to infer using the object initialization that foo.a is defined.
Actual behavior:
The compiler ignores the initialization of property 'a'.
Playground Link:Playground link (use strict check in options)
Related Issues: