-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Open
Labels
In DiscussionNot yet reached consensusNot yet reached consensusSuggestionAn idea for TypeScriptAn idea for TypeScript
Description
As far as I see, the TS compiler still sees a string literal type of a single literal as an old style "string parameter" thing. I thought that the concept of string literal types should replace overloading on string parameters, but seems that it doesn't.
That complicates things, and results in a "strange" behaviour in overload resolution:
class A256 {
m(a): any;
m(a: "a" | "b"): string;
m(a: "c"): string;
m(a): any {}
}
var foo1 = new A256().m("a"); // 'any'
var foo2 = new A256().m("c"); // 'string'
What should be the correct logic with string literal types in overload resolution?
Shouldn't overloads with unions of literals precede the others as well, when resolving overloads?
Metadata
Metadata
Assignees
Labels
In DiscussionNot yet reached consensusNot yet reached consensusSuggestionAn idea for TypeScriptAn idea for TypeScript