You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// 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'.