@@ -183,7 +183,7 @@ registerCodeFix({
183
183
184
184
addCodeAction ( addInlineTypeAssertion , fixes , context , TypePrintMode . Full , f => f . addInlineAssertion ( context . span ) ) ;
185
185
addCodeAction ( addInlineTypeAssertion , fixes , context , TypePrintMode . Relative , f => f . addInlineAssertion ( context . span ) ) ;
186
- addCodeAction ( addAnnotationFix , fixes , context , TypePrintMode . Widened , f => f . addInlineAssertion ( context . span ) ) ;
186
+ addCodeAction ( addInlineTypeAssertion , fixes , context , TypePrintMode . Widened , f => f . addInlineAssertion ( context . span ) ) ;
187
187
188
188
addCodeAction ( extractExpression , fixes , context , TypePrintMode . Full , f => f . extractAsVariable ( context . span ) ) ;
189
189
@@ -237,7 +237,6 @@ function withContext<T>(
237
237
const sourceFile : SourceFile = context . sourceFile ;
238
238
const program = context . program ;
239
239
const typeChecker : TypeChecker = program . getTypeChecker ( ) ;
240
- const emitResolver = typeChecker . getEmitResolver ( ) ;
241
240
const scriptTarget = getEmitScriptTarget ( program . getCompilerOptions ( ) ) ;
242
241
const importAdder = createImportAdder ( context . sourceFile , context . program , context . preferences , context . host ) ;
243
242
const fixedNodes = new Set < Node > ( ) ;
@@ -887,7 +886,7 @@ function withContext<T>(
887
886
type = widenedType ;
888
887
}
889
888
890
- if ( isParameter ( node ) && emitResolver . requiresAddingImplicitUndefined ( node ) ) {
889
+ if ( isParameter ( node ) && typeChecker . requiresAddingImplicitUndefined ( node ) ) {
891
890
type = typeChecker . getUnionType ( [ typeChecker . getUndefinedType ( ) , type ] , UnionReduction . None ) ;
892
891
}
893
892
const flags = (
@@ -1108,26 +1107,26 @@ function withContext<T>(
1108
1107
setEmitFlags ( node , EmitFlags . None ) ;
1109
1108
return result ;
1110
1109
}
1111
- }
1112
1110
1113
- // Some --isolatedDeclarations errors are not present on the node that directly needs type annotation, so look in the
1114
- // ancestors to look for node that needs type annotation. This function can return undefined if the AST is ill-formed.
1115
- function findAncestorWithMissingType ( node : Node ) : Node | undefined {
1116
- return findAncestor ( node , n => {
1117
- return canHaveTypeAnnotation . has ( n . kind ) &&
1118
- ( ( ! isObjectBindingPattern ( n ) && ! isArrayBindingPattern ( n ) ) || isVariableDeclaration ( n . parent ) ) ;
1119
- } ) ;
1120
- }
1121
-
1122
- function findBestFittingNode ( node : Node , span : TextSpan ) {
1123
- while ( node && node . end < span . start + span . length ) {
1124
- node = node . parent ;
1125
- }
1126
- while ( node . parent . pos === node . pos && node . parent . end === node . end ) {
1127
- node = node . parent ;
1111
+ // Some --isolatedDeclarations errors are not present on the node that directly needs type annotation, so look in the
1112
+ // ancestors to look for node that needs type annotation. This function can return undefined if the AST is ill-formed.
1113
+ function findAncestorWithMissingType ( node : Node ) : Node | undefined {
1114
+ return findAncestor ( node , n => {
1115
+ return canHaveTypeAnnotation . has ( n . kind ) &&
1116
+ ( ( ! isObjectBindingPattern ( n ) && ! isArrayBindingPattern ( n ) ) || isVariableDeclaration ( n . parent ) ) ;
1117
+ } ) ;
1128
1118
}
1129
- if ( isIdentifier ( node ) && hasInitializer ( node . parent ) && node . parent . initializer ) {
1130
- return node . parent . initializer ;
1119
+
1120
+ function findBestFittingNode ( node : Node , span : TextSpan ) {
1121
+ while ( node && node . end < span . start + span . length ) {
1122
+ node = node . parent ;
1123
+ }
1124
+ while ( node . parent . pos === node . pos && node . parent . end === node . end ) {
1125
+ node = node . parent ;
1126
+ }
1127
+ if ( isIdentifier ( node ) && hasInitializer ( node . parent ) && node . parent . initializer ) {
1128
+ return node . parent . initializer ;
1129
+ }
1130
+ return node ;
1131
1131
}
1132
- return node ;
1133
1132
}
0 commit comments