In strictNullChecks mode only:
TypeScript Version: nightly (2.0.2)
Code
interfaceIRoute{children?: IRoute[];}functionregister(route: IRoute){if(route.children){// <-- route.children is of type IRoute|undefinedObject.keys(route.children).forEach(routeKey=>{// <-- route.children is of type IRouteregister(route.children[routeKey]);// <-- Error: Object 'route.children' is possibly 'undefined'.});}}Expected behavior:
There shouldn't be an error here, because route.children is being checked 2 lines above.
Actual behavior:
TypeScript fails to recognize route.children cannot be undefined anymore, because of the nested function. It is the same behavior with both function declaration and arrow functions.
In strictNullChecks mode only:
TypeScript Version: nightly (2.0.2)
Code
Expected behavior:
There shouldn't be an error here, because
route.childrenis being checked 2 lines above.Actual behavior:
TypeScript fails to recognize
route.childrencannot be undefined anymore, because of the nested function. It is the same behavior with both function declaration and arrow functions.