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
lettest: string;constobj1: {val: string|number}={val: ''};if(typeofobj1.val==='string'){test=obj1.val;// => Works fine}constobj2: {[k: string]: string|number}={val: ''};if(typeofobj2.val==='string'){test=obj2.val;// => Type 'string | number' is not assignable to type 'string'}
Expected behavior:
Type guards to work on key/value objects
Actual behavior:
Can't infer the correct type after check
The text was updated successfully, but these errors were encountered:
Interesting. This will likely require some architectural changes as we currently have no symbol to associate with the .val property access and thus nothing to narrow by.
TypeScript Version: 2.2.2 with
--strictNullChecks
Code
Expected behavior:
Type guards to work on key/value objects
Actual behavior:
Can't infer the correct type after check
The text was updated successfully, but these errors were encountered: