@@ -7,8 +7,10 @@ import {
7
7
factory ,
8
8
firstDefined ,
9
9
getHostSignatureFromJSDoc ,
10
+ getJSDocHost ,
10
11
getJSDocTags ,
11
12
getTokenAtPosition ,
13
+ HasJSDoc ,
12
14
Identifier ,
13
15
isIdentifier ,
14
16
isJSDocParameterTag ,
@@ -69,9 +71,9 @@ registerCodeFix({
69
71
}
70
72
} ) ;
71
73
72
- function getDeleteAction ( context : CodeFixContext , { name, signature , jsDocParameterTag } : Info ) {
74
+ function getDeleteAction ( context : CodeFixContext , { name, jsDocHost , jsDocParameterTag } : Info ) {
73
75
const changes = textChanges . ChangeTracker . with ( context , changeTracker =>
74
- changeTracker . filterJSDocTags ( context . sourceFile , signature , t => t !== jsDocParameterTag ) ) ;
76
+ changeTracker . filterJSDocTags ( context . sourceFile , jsDocHost , t => t !== jsDocParameterTag ) ) ;
75
77
return createCodeFixAction (
76
78
deleteUnmatchedParameter ,
77
79
changes ,
@@ -113,6 +115,7 @@ function getRenameAction(context: CodeFixContext, { name, signature, jsDocParame
113
115
}
114
116
115
117
interface Info {
118
+ readonly jsDocHost : HasJSDoc ;
116
119
readonly signature : SignatureDeclaration ;
117
120
readonly jsDocParameterTag : JSDocParameterTag ;
118
121
readonly name : Identifier ;
@@ -122,9 +125,10 @@ function getInfo(sourceFile: SourceFile, pos: number): Info | undefined {
122
125
const token = getTokenAtPosition ( sourceFile , pos ) ;
123
126
if ( token . parent && isJSDocParameterTag ( token . parent ) && isIdentifier ( token . parent . name ) ) {
124
127
const jsDocParameterTag = token . parent ;
128
+ const jsDocHost = getJSDocHost ( jsDocParameterTag ) ;
125
129
const signature = getHostSignatureFromJSDoc ( jsDocParameterTag ) ;
126
- if ( signature ) {
127
- return { signature, name : token . parent . name , jsDocParameterTag } ;
130
+ if ( jsDocHost && signature ) {
131
+ return { jsDocHost , signature, name : token . parent . name , jsDocParameterTag } ;
128
132
}
129
133
}
130
134
return undefined ;
0 commit comments