Skip to content

Codefix to annotate with type from jsdoc reformats entire function #22358

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
ghost opened this issue Mar 6, 2018 · 1 comment
Closed

Codefix to annotate with type from jsdoc reformats entire function #22358

ghost opened this issue Mar 6, 2018 · 1 comment
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@ghost
Copy link

ghost commented Mar 6, 2018

TypeScript Version: 2.8.0-dev.20180302

Code

/** @param {number} x */
function f(x) {
    return x+1;
}

Expected behavior:

/** @param {number} x */
function f(x: number) {
    return x+1;
}

Actual behavior:

/** @param {number} x */
function f(x: number) {
    return x + 1;
}

Inferring the type from usage does not have this problem, so we could probably reuse some code from there.

@mhegazy
Copy link
Contributor

mhegazy commented Mar 6, 2018

Inferring the type from usage does not have this problem, so we could probably reuse some code from there.

inferring type from usage adds a text edit and does not use the change tracker, which is wrong really.. so i would not use it as a reference.

Maybe what we need is a new changeTracker method to add a leading comment.. we can use that in the disableJSDiagnostics as well.

@mhegazy mhegazy added the Bug A bug in TypeScript label Mar 6, 2018
@mhegazy mhegazy assigned ghost Mar 6, 2018
@mhegazy mhegazy added this to the TypeScript 2.8 milestone Mar 8, 2018
@mhegazy mhegazy added the Fixed A PR has been merged for this issue label Mar 8, 2018
@ghost ghost closed this as completed in #22404 Mar 8, 2018
@microsoft microsoft locked and limited conversation to collaborators Jul 25, 2018
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

1 participant