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
typeT1={as?: 'button',onClick?: (el: number)=>void}typeT2={as: 'a',onClick?: (el: string)=>void}typeT=T1|T2;// onClick first parameter type is inferred according to T1 (number)constmyT1_1: T={as: undefined,onClick: _ev=>{}}// onClick first parameter type is inferred according to T1 (number)constmyT1_2: T={as: 'button',onClick: _ev=>{}}// onClick first parameter type is inferred according to T2 (string)constmyT2_1: T={as: 'a',onClick: _ev=>{}}// onClick first parameter type is not inferred (any)constmyT1_3: T={onClick: _ev=>{}}
Expected behavior:
onClick _ev parameter of myT1_3 is inferred to be a number
Actual behavior:
onClick _ev parameter of myT1_3 is any
discriminated union
Code
Expected behavior:
onClick
_ev
parameter ofmyT1_3
is inferred to be anumber
Actual behavior:
onClick
_ev
parameter ofmyT1_3
isany
Playground Link:
Playground Link
If the callback in
T1
andT2
is replaced with a primitive member thenmyT1_3
is inferred correctly. Playground LinkThe text was updated successfully, but these errors were encountered: