fix quick fix infer parameter types from usage in js file
This commit is contained in:
parent
a9c5a0472f
commit
c9c9f859f3
2 changed files with 21 additions and 1 deletions
|
@ -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;`,
|
||||
});
|
Loading…
Reference in a new issue