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
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:
produces this output:
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