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 check and Object key completion on overloaded functions with generic types defined in a class are incorrect #58226
interfaceBar{name: string;}declareclassFoo{load<TextendsBar[]>(list: string[]): Promise<T>;load<TextendsBar>(name: string): Promise<T>;// If I revert the overload definition, it still does not work as expected.// load<T extends Bar>(name: string): Promise<T>;// load<T extends Bar[]>(list: string[]): Promise<T>;}constfoo=newFoo()foo.load<Bar[]>([''])// Correct type checkfoo.load<Bar>('')// <---- Incorrect type check here. The parameter type should be inferred as `string` but is `string[]`.
🙁 Actual behavior
When overload function in class with generic type(One is an array and the other is a normal type), Typescript could not match the correct type.
I know that Typescript check the overloaded function from top-to-down, but it still not working even if i revert the definition.
Activity