-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
DuplicateAn existing issue was already createdAn existing issue was already created
Description
Bug Report
π Search Terms
bind overload signature
π Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about bind and method overload
β― Playground Link
Playground link with relevant code
π» Code
method(x:number): string;
method(x:string): number;
method(x:string | number): string | number {
if (typeof x === 'string') return 0;
return '';
}
method1: () => string;
method2: () => number;
constructor() {
this.method1 = this.method.bind(this, 0);
this.method2 = this.method.bind(this, '');
}
}
π Actual behavior
in method1's definition, typescript only reads one of the two method signatures (the first one) when you use bind on it.
π Expected behavior
TypeScript should read all the available signatures when you call the bind method on your method. Because that's the purpose of method overloads.
Metadata
Metadata
Assignees
Labels
DuplicateAn existing issue was already createdAn existing issue was already created