You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
functiongetGetter(){letdata={}data['bar']=1if(hasBar(data)){return()=>data.bar// Property 'bar' does not exist on type '{}'.}}functionhasBar(thing): thing is {bar: number}{returntypeofthing.bar=='number'}
Expected behavior:
Compile successfully.
Actual behavior:
index.ts(6,21): error TS2339: Property 'bar' does not exist on type '{}'.
The text was updated successfully, but these errors were encountered:
Your example works if you use const to declare data. Type guards for let variables are not in effect in nested functions because the variable might be reassigned. See #8849.
TypeScript Version: 2.2.0-dev.20161202
Code
Expected behavior:
Compile successfully.
Actual behavior:
The text was updated successfully, but these errors were encountered: