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
{{ message }}
Repository navigation
Type discrimination in function calls for callable types doesn't work if discriminating property is optional #34529
Search Terms: type discrimination, callable, signatures, implicit any
Code
functiontest(a:
|{type?: 1;property: (a: number)=>void}|{type: 2;property: (a: string)=>void},){returna.property}test({property: (x)=>{// complaining that x implicitly has type anyconsole.log('hi')},})
Expected behavior:
x should be inferred to be number.
Actual behavior:
x is any.
If you change type?: 1 to type: 1, it works as expected.
changed the title [-]Type discrimination in function calls for callable types don't work if discriminating property is optional[/-][+]Type discrimination in function calls for callable types doesn't work if discriminating property is optional[/+]on Oct 17, 2019
Activity
[-]Type discrimination in function calls for callable types don't work if discriminating property is optional[/-][+]Type discrimination in function calls for callable types doesn't work if discriminating property is optional[/+]