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
Control flow analysis for dependent parameters doesn't work for methodsΒ #48160
interfaceFoo{method(...args: ['a',number]|['b',string]): void};constmethodSyntax: Foo={method(kind,payload){if(kind==='a'){payload.toFixed();// error, Property 'toFixed' does not exist on type 'string | number'}if(kind==='b'){payload.toUpperCase();// error, Property 'toUpperCase' does not exist on type 'string | number'}}}
π Actual behavior
Checking kind inside the body of method() does not narrow payload from string | number.
π Expected behavior
Given #47190, I'd expect kind === 'a' to narrow payload to number, and kind === 'b' to narrow payload to string, which does happen when method is a function expression:
Activity
RyanCavanaugh commentedon Mar 8, 2022
Seems like an oversight