-
Notifications
You must be signed in to change notification settings - Fork 12.8k
String Literal issue with function overloads #8251
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
What you have in the OP has no error (well, except for a missing The code in the handbook does not have the (Using npm 1.8.10 which I believe corresponds to VS 1.8.30.0) |
The example doesn't produce an error as @Arnavion points out. We made a change to such behavior. The behavior is in the "typescript@next". |
Thanks @Arnavion and @yuit for taking the time to answer my question. Apparently I changed the code when I copy & pasted removing the issue. Code generating the error function createElement(tagName: "img"): HTMLImageElement;
function createElement(tagName: "input"): HTMLInputElement;
// ... more overloads ...
function createElement(tagName: string): Element {
// ... code goes here ...
return;
} Code with no error function createElement(tagName: "img"): HTMLImageElement;
function createElement(tagName: "input"): HTMLInputElement;
function createElement(tagName: string): Element;
// ... more overloads ...
function createElement(tagName: string): Element {
// ... code goes here ...
return;
} |
This was fixed in #6075. |
TypeScript Version:
TypeScript 1.8.30.0
Issue
The following code (copy & paste from the TypeScript documentation) doesn't work. It generates a compiler error.
While, just moving the most general signature at the tip of the list will compile correctly.
The text was updated successfully, but these errors were encountered: