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
/** * @param {string} a */functionexample1(a){a===2;// error TS2365: Operator '===' cannot be applied to types 'string' and 'number'.}/** * @param {any} a * @param {string} a.b */functionexample3(a){a.b===2;// no errors}/** * @param {{b: string}} a * @param {string} a.b */functionexample5(a){a.b===2;// error TS2365: Operator '===' cannot be applied to types 'string' and 'number'.}/** * @param {{b: string}} a * @param {number} a.b */functionexample6(a){a.b===2;// error TS2365: Operator '===' cannot be applied to types 'string' and 'number'.}/** * @param {number} a.b */functionexample7(a){a.b===2;// error TS2339: Property 'b' does not exist on type 'number'.}
Expected behavior:
Example 1 works correctly
I expect in example 3 that a.b is detected as a string and that error TS2365 is shown
Example 5 works correctly
I expect in example 6 to say that it's ambiguous.
I expect in example 7 that a is detected as an object and not as a number.
Actual behavior:
Errors shown in the code
The text was updated successfully, but these errors were encountered:
TypeScript Version: 2.3.2
Code
Expected behavior:
Example 1 works correctly
I expect in example 3 that
a.b
is detected as astring
and that errorTS2365
is shownExample 5 works correctly
I expect in example 6 to say that it's ambiguous.
I expect in example 7 that
a
is detected as an object and not as anumber
.Actual behavior:
Errors shown in the code
The text was updated successfully, but these errors were encountered: