mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 04:43:37 -05:00
fix quick fix infer parameter types from usage in js file
This commit is contained in:
@@ -340,7 +340,9 @@ namespace ts.textChanges {
|
||||
}
|
||||
|
||||
public insertJsdocCommentBefore(sourceFile: SourceFile, node: HasJSDoc, tag: JSDoc): void {
|
||||
const fnStart = node.getStart(sourceFile);
|
||||
const fnStart = node.kind === SyntaxKind.ArrowFunction
|
||||
? node.parent.parent.getStart(sourceFile)
|
||||
: node.getStart(sourceFile);
|
||||
if (node.jsDoc) {
|
||||
for (const jsdoc of node.jsDoc) {
|
||||
this.deleteRange(sourceFile, {
|
||||
|
||||
18
tests/cases/fourslash/codeFixInferFromUsageArrowJS.ts
Normal file
18
tests/cases/fourslash/codeFixInferFromUsageArrowJS.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
// @allowJs: true
|
||||
// @checkJs: true
|
||||
// @noEmit: true
|
||||
// @noImplicitAny: true
|
||||
// @Filename: test.js
|
||||
|
||||
////const foo = x => x.y + 1;
|
||||
|
||||
verify.codeFix({
|
||||
description: "Infer parameter types from usage",
|
||||
index: 0,
|
||||
newFileContent:
|
||||
`/**
|
||||
* @param {{ y: number; }} x
|
||||
*/
|
||||
const foo = x => x.y + 1;`,
|
||||
});
|
||||
Reference in New Issue
Block a user