Skip to content

Suggestion: support function overloading in type annotation comments #21921

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

Closed
douglas-treadwell opened this issue Feb 13, 2018 · 3 comments
Closed
Labels
Duplicate An existing issue was already created

Comments

@douglas-treadwell
Copy link

I'm adding type annotations to a JS codebase, and one problematic case I've come across is that I cannot overload function signatures using comment-based annotations.

/** @type {(flag: true) => integer;} */
/** @type {(flag: false) => string;} */
function getResult(asInteger) {
   // do stuff here
}

The workaround for now would be splitting the function into two functions, or type-casting at each use of the function. So far my choice will be to split the function.

@mhegazy mhegazy added Suggestion An idea for TypeScript Domain: JSDoc Relates to JSDoc parsing and type generation Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature labels Feb 13, 2018
@goodmind
Copy link

Isn't this the same issue? #407

@mhegazy
Copy link
Contributor

mhegazy commented Mar 27, 2018

indeed. closing in favor of #407

@mhegazy mhegazy added Duplicate An existing issue was already created and removed Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Domain: JSDoc Relates to JSDoc parsing and type generation Suggestion An idea for TypeScript labels Mar 27, 2018
@typescript-bot
Copy link
Collaborator

Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.

@microsoft microsoft locked and limited conversation to collaborators Jul 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

4 participants