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
Implicit generics inference with nested types Β #47230
typeCommand=(...args: Array<any>)=>any;typeClient<CextendsCommand>={command: C;};typeClientOptions<CextendsCommand>={command: C;}typeSetup<CextendsCommand>=(client: Client<C>)=>unknown;functiontest1<CextendsCommand>(setup: Setup<C>,options: ClientOptions<C>): void{}test1(asyncclient=>{// `client.command` type is `Command`, but should be inferred from `options.command`client.command('message');// ^?},{command(message: string): void{console.log(message);}});functiontest2<CextendsCommand>(setup: Setup<C>,command: C): void{}test2(asyncclient=>{// works as expected, "client.command" type is inferred from `command` (the next argument)client.command('message');// ^?},(message: string): void=>{console.log(message);});
π Actual behavior
test1 - client.command type is Command
test2 - works as expected
π Expected behavior
test1 - client.command type should be (message: string) => void
Activity
leibale commentedon Dec 27, 2021
another demo
RyanCavanaugh commentedon Jan 5, 2022
Duplicate #38623