Closed
Description
TypeScript Version: 2.2.1
Effective type of argument p
below seems to not match explicit declaration under tsc 2.2.1
Code
interface RuleContext {
_parent: RuleContext | undefined;
};
var _ctx = { _parent: undefined};
function walk( p: RuleContext | undefined = _ctx ) {
while (p) {
p = p._parent; // Error w/ "strictNullChecks": true !
}
}
Expected behavior:
Compiled w/o error under 2.1
Actual behavior:
Generates error:
index.ts(9,4): error TS2322: Type 'RuleContext | undefined' is not assignable to type 'RuleContext'.
Type 'undefined' is not assignable to type 'RuleContext'.