@@ -22,7 +22,7 @@ namespace ts.codefix {
22
22
return ;
23
23
}
24
24
25
- addUndefinedType ( changes , diag . file , propertyDeclaration , propertyDeclaration . type ) ;
25
+ addUndefinedType ( changes , diag . file , propertyDeclaration ) ;
26
26
} ) ;
27
27
} ,
28
28
} ) ;
@@ -43,15 +43,14 @@ namespace ts.codefix {
43
43
}
44
44
45
45
function getActionsForAddMissingUndefinedType ( context : CodeFixContext , token : Identifier , propertyDeclaration : PropertyDeclaration ) : CodeFixAction [ ] | undefined {
46
- const typeNode = propertyDeclaration . type ;
47
46
const description = formatStringFromArgs ( getLocaleSpecificMessage ( Diagnostics . Declare_property_0 ) , [ token . text ] ) ;
48
- const changes = textChanges . ChangeTracker . with ( context , t => addUndefinedType ( t , context . sourceFile , propertyDeclaration , typeNode ) ) ;
47
+ const changes = textChanges . ChangeTracker . with ( context , t => addUndefinedType ( t , context . sourceFile , propertyDeclaration ) ) ;
49
48
const action = { description, changes, fixId } ;
50
49
return [ action ] ;
51
50
}
52
51
53
- function addUndefinedType ( changeTracker : textChanges . ChangeTracker , propertyDeclarationSourceFile : SourceFile , propertyDeclaration : PropertyDeclaration , typeNode : TypeNode ) : void {
54
- const newTypeNode = createUnionTypeNode ( [ typeNode , createKeywordTypeNode ( SyntaxKind . UndefinedKeyword ) ] ) ;
52
+ function addUndefinedType ( changeTracker : textChanges . ChangeTracker , propertyDeclarationSourceFile : SourceFile , propertyDeclaration : PropertyDeclaration ) : void {
53
+ const newTypeNode = createUnionTypeNode ( [ propertyDeclaration . type , createKeywordTypeNode ( SyntaxKind . UndefinedKeyword ) ] ) ;
55
54
changeTracker . replaceNode ( propertyDeclarationSourceFile , propertyDeclaration . type , newTypeNode ) ;
56
55
}
57
56
}
0 commit comments