@@ -10,27 +10,24 @@ namespace ts.codefix {
1010 const propertyDeclaration = getPropertyDeclaration ( context . sourceFile , context . span . start ) ;
1111 if ( ! propertyDeclaration ) return ;
1212
13- const newLineCharacter = getNewLineOrDefaultFromHost ( context . host , context . formatContext . options ) ;
1413 const result = [
1514 getActionForAddMissingUndefinedType ( context , propertyDeclaration ) ,
16- getActionForAddMissingDefiniteAssignmentAssertion ( context , propertyDeclaration , newLineCharacter )
15+ getActionForAddMissingDefiniteAssignmentAssertion ( context , propertyDeclaration )
1716 ] ;
1817
19- append ( result , getActionForAddMissingInitializer ( context , propertyDeclaration , newLineCharacter ) ) ;
18+ append ( result , getActionForAddMissingInitializer ( context , propertyDeclaration ) ) ;
2019
2120 return result ;
2221 } ,
2322 fixIds : [ fixIdAddDefiniteAssignmentAssertions , fixIdAddUndefinedType , fixIdAddInitializer ] ,
2423 getAllCodeActions : context => {
25- const newLineCharacter = getNewLineOrDefaultFromHost ( context . host , context . formatContext . options ) ;
26-
2724 return codeFixAll ( context , errorCodes , ( changes , diag ) => {
2825 const propertyDeclaration = getPropertyDeclaration ( diag . file , diag . start ) ;
2926 if ( ! propertyDeclaration ) return ;
3027
3128 switch ( context . fixId ) {
3229 case fixIdAddDefiniteAssignmentAssertions :
33- addDefiniteAssignmentAssertion ( changes , diag . file , propertyDeclaration , newLineCharacter ) ;
30+ addDefiniteAssignmentAssertion ( changes , diag . file , propertyDeclaration ) ;
3431 break ;
3532 case fixIdAddUndefinedType :
3633 addUndefinedType ( changes , diag . file , propertyDeclaration ) ;
@@ -40,7 +37,7 @@ namespace ts.codefix {
4037 const initializer = getInitializer ( checker , propertyDeclaration ) ;
4138 if ( ! initializer ) return ;
4239
43- addInitializer ( changes , diag . file , propertyDeclaration , initializer , newLineCharacter ) ;
40+ addInitializer ( changes , diag . file , propertyDeclaration , initializer ) ;
4441 break ;
4542 default :
4643 Debug . fail ( JSON . stringify ( context . fixId ) ) ;
@@ -54,13 +51,13 @@ namespace ts.codefix {
5451 return isIdentifier ( token ) ? cast ( token . parent , isPropertyDeclaration ) : undefined ;
5552 }
5653
57- function getActionForAddMissingDefiniteAssignmentAssertion ( context : CodeFixContext , propertyDeclaration : PropertyDeclaration , newLineCharacter : string ) : CodeFixAction {
54+ function getActionForAddMissingDefiniteAssignmentAssertion ( context : CodeFixContext , propertyDeclaration : PropertyDeclaration ) : CodeFixAction {
5855 const description = formatStringFromArgs ( getLocaleSpecificMessage ( Diagnostics . Add_definite_assignment_assertion_to_property_0 ) , [ propertyDeclaration . getText ( ) ] ) ;
59- const changes = textChanges . ChangeTracker . with ( context , t => addDefiniteAssignmentAssertion ( t , context . sourceFile , propertyDeclaration , newLineCharacter ) ) ;
56+ const changes = textChanges . ChangeTracker . with ( context , t => addDefiniteAssignmentAssertion ( t , context . sourceFile , propertyDeclaration ) ) ;
6057 return { description, changes, fixId : fixIdAddDefiniteAssignmentAssertions } ;
6158 }
6259
63- function addDefiniteAssignmentAssertion ( changeTracker : textChanges . ChangeTracker , propertyDeclarationSourceFile : SourceFile , propertyDeclaration : PropertyDeclaration , newLineCharacter : string ) : void {
60+ function addDefiniteAssignmentAssertion ( changeTracker : textChanges . ChangeTracker , propertyDeclarationSourceFile : SourceFile , propertyDeclaration : PropertyDeclaration ) : void {
6461 const property = updateProperty (
6562 propertyDeclaration ,
6663 propertyDeclaration . decorators ,
@@ -70,7 +67,7 @@ namespace ts.codefix {
7067 propertyDeclaration . type ,
7168 propertyDeclaration . initializer
7269 ) ;
73- changeTracker . replaceNode ( propertyDeclarationSourceFile , propertyDeclaration , property , { suffix : newLineCharacter } ) ;
70+ changeTracker . replaceNode ( propertyDeclarationSourceFile , propertyDeclaration , property ) ;
7471 }
7572
7673 function getActionForAddMissingUndefinedType ( context : CodeFixContext , propertyDeclaration : PropertyDeclaration ) : CodeFixAction {
@@ -85,17 +82,17 @@ namespace ts.codefix {
8582 changeTracker . replaceNode ( propertyDeclarationSourceFile , propertyDeclaration . type , createUnionTypeNode ( types ) ) ;
8683 }
8784
88- function getActionForAddMissingInitializer ( context : CodeFixContext , propertyDeclaration : PropertyDeclaration , newLineCharacter : string ) : CodeFixAction | undefined {
85+ function getActionForAddMissingInitializer ( context : CodeFixContext , propertyDeclaration : PropertyDeclaration ) : CodeFixAction | undefined {
8986 const checker = context . program . getTypeChecker ( ) ;
9087 const initializer = getInitializer ( checker , propertyDeclaration ) ;
9188 if ( ! initializer ) return undefined ;
9289
9390 const description = formatStringFromArgs ( getLocaleSpecificMessage ( Diagnostics . Add_initializer_to_property_0 ) , [ propertyDeclaration . name . getText ( ) ] ) ;
94- const changes = textChanges . ChangeTracker . with ( context , t => addInitializer ( t , context . sourceFile , propertyDeclaration , initializer , newLineCharacter ) ) ;
91+ const changes = textChanges . ChangeTracker . with ( context , t => addInitializer ( t , context . sourceFile , propertyDeclaration , initializer ) ) ;
9592 return { description, changes, fixId : fixIdAddInitializer } ;
9693 }
9794
98- function addInitializer ( changeTracker : textChanges . ChangeTracker , propertyDeclarationSourceFile : SourceFile , propertyDeclaration : PropertyDeclaration , initializer : Expression , newLineCharacter : string ) : void {
95+ function addInitializer ( changeTracker : textChanges . ChangeTracker , propertyDeclarationSourceFile : SourceFile , propertyDeclaration : PropertyDeclaration , initializer : Expression ) : void {
9996 const property = updateProperty (
10097 propertyDeclaration ,
10198 propertyDeclaration . decorators ,
@@ -105,7 +102,7 @@ namespace ts.codefix {
105102 propertyDeclaration . type ,
106103 initializer
107104 ) ;
108- changeTracker . replaceNode ( propertyDeclarationSourceFile , propertyDeclaration , property , { suffix : newLineCharacter } ) ;
105+ changeTracker . replaceNode ( propertyDeclarationSourceFile , propertyDeclaration , property ) ;
109106 }
110107
111108 function getInitializer ( checker : TypeChecker , propertyDeclaration : PropertyDeclaration ) : Expression | undefined {
0 commit comments