Skip to content
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

"Infer parameter type from usage" produces oddly formatted output #38979

Open
lumaxis opened this issue Jun 8, 2020 · 0 comments
Open

"Infer parameter type from usage" produces oddly formatted output #38979

lumaxis opened this issue Jun 8, 2020 · 0 comments
Labels
Bug A bug in TypeScript
Milestone

Comments

@lumaxis
Copy link

lumaxis commented Jun 8, 2020

When using the "Infer parameter types from usage" quick fix in VS Code, TypeScript sometimes injects the JSDoc type annotation right in the middle of the code. The resulting code looks odd and broken.

TypeScript Version: 4.0.0-dev.20200607

Search Terms:
infer all from usage

Code
Using "Infer parameter type from usage" on this code:

function doSomething(things) {
  const states = things.filter(thing => true);
}

produces this output:

function doSomething(things) {
  const /**
     * @param {any} thing
     */
 states = things.filter(thing => true);
}

Expected behavior:

TypeScript produces annotated code that is not weirdly broken into different lines

Actual behavior:

TypeScript produces annotated code that looks odd and has the JSDoc comment injected in the middle of code

Playground Link: Not sure if this functionality is available in the Playground

Related Issues: N/A

@RyanCavanaugh RyanCavanaugh added the Bug A bug in TypeScript label Jun 15, 2020
@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone Jun 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript
Projects
None yet
Development

No branches or pull requests

2 participants