-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
FixedA PR has been merged for this issueA PR has been merged for this issueSuggestionAn idea for TypeScriptAn idea for TypeScript
Description
Hi, consider this bit of code:
class Bar {
public bar: string;
}
interface IFoo {
doFoo(type: any, bar: any): void;
doFoo(type: "Quux", bar: Bar): string;
}
We use it like this:
var foo: IFoo;
var result:string = foo.doFoo("Quux", new Bar()); // fine
However, while still specifying "Quux", if we pass any type other than new Bar() for the second argument, the compiler falls back to the non-overloaded method:
// Error TS2011: Cannot convert 'void' to 'string'.
var result2: string = foo.doFoo("Quux", "bar");
I think this is a bit unfortunate. We are missing an opportunity to verify that the additional arguments also match the overloaded signature.
Ideally the following
foo.doFoo("Quux", "bar");
should generate error TS2082: Supplied parameters do not match any signature of call target
See further discussion on the old codeplex site.
Metadata
Metadata
Assignees
Labels
FixedA PR has been merged for this issueA PR has been merged for this issueSuggestionAn idea for TypeScriptAn idea for TypeScript