Open
Description
TypeScript Version: 2.9.0-dev.20180512
Search Terms:
Code
// @strictNullChecks: true
function test1(param?: {prop: string}) {
switch (param && param.prop) {
case 'foo':
return param.prop; // error: 'param' is possibly undefined
}
}
function test2(param: {prop?: string}) {
switch (param && param.prop) {
case 'foo':
return param.prop.charAt(0); // error: 'param.prop' is possibly undefined
}
}
Expected behavior:
Compiles without error.
Actual behavior:
strictNullChecks errors as described in the comments above.
Related Issues:
#23818