1
1
/* @internal */
2
2
namespace ts . codefix {
3
+ const fixName = "addMissingMember" ;
3
4
const errorCodes = [
4
5
Diagnostics . Property_0_does_not_exist_on_type_1 . code ,
5
6
Diagnostics . Property_0_does_not_exist_on_type_1_Did_you_mean_2 . code ,
@@ -75,7 +76,7 @@ namespace ts.codefix {
75
76
function getActionsForAddMissingMemberInJavaScriptFile ( context : CodeFixContext , classDeclarationSourceFile : SourceFile , classDeclaration : ClassLikeDeclaration , tokenName : string , makeStatic : boolean ) : CodeFixAction | undefined {
76
77
const changes = textChanges . ChangeTracker . with ( context , t => addMissingMemberInJs ( t , classDeclarationSourceFile , classDeclaration , tokenName , makeStatic ) ) ;
77
78
return changes . length === 0 ? undefined
78
- : createCodeFixAction ( changes , [ makeStatic ? Diagnostics . Initialize_static_property_0 : Diagnostics . Initialize_property_0_in_the_constructor , tokenName ] , fixId , Diagnostics . Add_all_missing_members ) ;
79
+ : createCodeFixAction ( fixName , changes , [ makeStatic ? Diagnostics . Initialize_static_property_0 : Diagnostics . Initialize_property_0_in_the_constructor , tokenName ] , fixId , Diagnostics . Add_all_missing_members ) ;
79
80
}
80
81
81
82
function addMissingMemberInJs ( changeTracker : textChanges . ChangeTracker , classDeclarationSourceFile : SourceFile , classDeclaration : ClassLikeDeclaration , tokenName : string , makeStatic : boolean ) : void {
@@ -120,7 +121,7 @@ namespace ts.codefix {
120
121
121
122
function createAddPropertyDeclarationAction ( context : CodeFixContext , classDeclarationSourceFile : SourceFile , classDeclaration : ClassLikeDeclaration , makeStatic : boolean , tokenName : string , typeNode : TypeNode ) : CodeFixAction {
122
123
const changes = textChanges . ChangeTracker . with ( context , t => addPropertyDeclaration ( t , classDeclarationSourceFile , classDeclaration , tokenName , typeNode , makeStatic ) ) ;
123
- return createCodeFixAction ( changes , [ makeStatic ? Diagnostics . Declare_static_property_0 : Diagnostics . Declare_property_0 , tokenName ] , fixId , Diagnostics . Add_all_missing_members ) ;
124
+ return createCodeFixAction ( fixName , changes , [ makeStatic ? Diagnostics . Declare_static_property_0 : Diagnostics . Declare_property_0 , tokenName ] , fixId , Diagnostics . Add_all_missing_members ) ;
124
125
}
125
126
126
127
function addPropertyDeclaration ( changeTracker : textChanges . ChangeTracker , classDeclarationSourceFile : SourceFile , classDeclaration : ClassLikeDeclaration , tokenName : string , typeNode : TypeNode , makeStatic : boolean ) : void {
@@ -153,7 +154,7 @@ namespace ts.codefix {
153
154
154
155
const changes = textChanges . ChangeTracker . with ( context , t => t . insertNodeAtClassStart ( classDeclarationSourceFile , classDeclaration , indexSignature ) ) ;
155
156
// No fixId here because code-fix-all currently only works on adding individual named properties.
156
- return createCodeFixActionNoFixId ( changes , [ Diagnostics . Add_index_signature_for_property_0 , tokenName ] ) ;
157
+ return createCodeFixActionNoFixId ( fixName , changes , [ Diagnostics . Add_index_signature_for_property_0 , tokenName ] ) ;
157
158
}
158
159
159
160
function getActionForMethodDeclaration (
@@ -167,7 +168,7 @@ namespace ts.codefix {
167
168
preferences : UserPreferences ,
168
169
) : CodeFixAction | undefined {
169
170
const changes = textChanges . ChangeTracker . with ( context , t => addMethodDeclaration ( t , classDeclarationSourceFile , classDeclaration , token , callExpression , makeStatic , inJs , preferences ) ) ;
170
- return createCodeFixAction ( changes , [ makeStatic ? Diagnostics . Declare_static_method_0 : Diagnostics . Declare_method_0 , token . text ] , fixId , Diagnostics . Add_all_missing_members ) ;
171
+ return createCodeFixAction ( fixName , changes , [ makeStatic ? Diagnostics . Declare_static_method_0 : Diagnostics . Declare_method_0 , token . text ] , fixId , Diagnostics . Add_all_missing_members ) ;
171
172
}
172
173
173
174
function addMethodDeclaration (
0 commit comments