TypeScript Version: playground
Code
typeunknown={}|undefined|null|void;interfaceDict{[key: string]: unknown;}functionisDict(value: any): value is Dict{returnvalue!==null&&value!==undefined;}functionany(): any{}letnotSure: unknown=any();if(isDict(notSure)){notSure['foo'];// <- turn on strict mode to see error, `notSure` is `{}`}Expected behavior:
notSure is Dict after the narrowing
Actual behavior:
notSure is {} after the narrowing
Playground link
TypeScript Version: playground
Code
Expected behavior:
notSureisDictafter the narrowingActual behavior:
notSureis{}after the narrowingPlayground link