TypeScript Version: v3.7-Beta
Search terms : narrow narrowing down type parameter closure
Code
functionfoo(arg: string|undefined){arg=arg??"default";arg.length// no errorconstbar=()=>{arg.length;// error }}Expected behavior:
arg should be of type string within the body of the closure.
Actual behavior:
arg is possibly 'undefined' within the body of the closure.
Playground Link:Playground link
TypeScript Version: v3.7-Beta
Search terms : narrow narrowing down type parameter closure
Code
Expected behavior:
arg should be of type string within the body of the closure.
Actual behavior:
arg is possibly 'undefined' within the body of the closure.
Playground Link:Playground link