@@ -96,7 +96,6 @@ namespace ts.Completions {
96
96
}
97
97
98
98
interface SymbolOriginInfoObjectLiteralMethod extends SymbolOriginInfo {
99
- importAdder : codefix . ImportAdder ,
100
99
insertText : string ,
101
100
labelDetails : CompletionEntryLabelDetails ,
102
101
isSnippet ?: true ,
@@ -780,17 +779,13 @@ namespace ts.Completions {
780
779
}
781
780
782
781
if ( origin && originIsObjectLiteralMethod ( origin ) ) {
783
- let importAdder ;
784
- ( { insertText, isSnippet, importAdder, labelDetails } = origin ) ;
782
+ ( { insertText, isSnippet, labelDetails } = origin ) ;
785
783
if ( ! preferences . useLabelDetailsInCompletionEntries ) {
786
784
name = name + labelDetails . detail ;
787
785
labelDetails = undefined ;
788
786
}
789
787
source = CompletionSource . ObjectLiteralMethodSnippet ;
790
788
sortText = SortText . SortBelow ( sortText ) ;
791
- if ( importAdder . hasFixes ( ) ) {
792
- hasAction = true ;
793
- }
794
789
}
795
790
796
791
if ( isJsxIdentifierExpected && ! isRightOfOpenTag && preferences . includeCompletionsWithSnippetText && preferences . jsxAttributeCompletionStyle && preferences . jsxAttributeCompletionStyle !== "none" ) {
@@ -1072,14 +1067,13 @@ namespace ts.Completions {
1072
1067
options : CompilerOptions ,
1073
1068
preferences : UserPreferences ,
1074
1069
formatContext : formatting . FormatContext | undefined ,
1075
- ) : { insertText : string , isSnippet ?: true , importAdder : codefix . ImportAdder , labelDetails : CompletionEntryLabelDetails } | undefined {
1070
+ ) : { insertText : string , isSnippet ?: true , labelDetails : CompletionEntryLabelDetails } | undefined {
1076
1071
const isSnippet = preferences . includeCompletionsWithSnippetText || undefined ;
1077
1072
let insertText : string = name ;
1078
1073
1079
1074
const sourceFile = enclosingDeclaration . getSourceFile ( ) ;
1080
- const importAdder = codefix . createImportAdder ( sourceFile , program , preferences , host ) ;
1081
1075
1082
- const method = createObjectLiteralMethod ( symbol , enclosingDeclaration , sourceFile , program , host , preferences , importAdder ) ;
1076
+ const method = createObjectLiteralMethod ( symbol , enclosingDeclaration , sourceFile , program , host , preferences ) ;
1083
1077
if ( ! method ) {
1084
1078
return undefined ;
1085
1079
}
@@ -1115,7 +1109,7 @@ namespace ts.Completions {
1115
1109
method . type ) ;
1116
1110
const labelDetails = { detail : signaturePrinter . printNode ( EmitHint . Unspecified , methodSignature , sourceFile ) } ;
1117
1111
1118
- return { isSnippet, insertText, importAdder , labelDetails } ;
1112
+ return { isSnippet, insertText, labelDetails } ;
1119
1113
1120
1114
} ;
1121
1115
@@ -1126,14 +1120,12 @@ namespace ts.Completions {
1126
1120
program : Program ,
1127
1121
host : LanguageServiceHost ,
1128
1122
preferences : UserPreferences ,
1129
- importAdder : codefix . ImportAdder ,
1130
1123
) : MethodDeclaration | undefined {
1131
1124
const declarations = symbol . getDeclarations ( ) ;
1132
1125
if ( ! ( declarations && declarations . length ) ) {
1133
1126
return undefined ;
1134
1127
}
1135
1128
const checker = program . getTypeChecker ( ) ;
1136
- const scriptTarget = getEmitScriptTarget ( program . getCompilerOptions ( ) ) ;
1137
1129
const declaration = declarations [ 0 ] ;
1138
1130
const name = getSynthesizedDeepClone ( getNameOfDeclaration ( declaration ) , /*includeTrivia*/ false ) as PropertyName ;
1139
1131
const type = checker . getWidenedType ( checker . getTypeOfSymbolAtLocation ( symbol , enclosingDeclaration ) ) ;
@@ -1163,15 +1155,10 @@ namespace ts.Completions {
1163
1155
// We don't support overloads in object literals.
1164
1156
return undefined ;
1165
1157
}
1166
- let typeNode = checker . typeToTypeNode ( effectiveType , enclosingDeclaration , builderFlags , codefix . getNoopSymbolTrackerWithResolver ( { program, host } ) ) ;
1158
+ const typeNode = checker . typeToTypeNode ( effectiveType , enclosingDeclaration , builderFlags , codefix . getNoopSymbolTrackerWithResolver ( { program, host } ) ) ;
1167
1159
if ( ! typeNode || ! isFunctionTypeNode ( typeNode ) ) {
1168
1160
return undefined ;
1169
1161
}
1170
- const importableReference = codefix . tryGetAutoImportableReferenceFromTypeNode ( typeNode , scriptTarget ) ;
1171
- if ( importableReference ) {
1172
- typeNode = importableReference . typeNode ;
1173
- codefix . importSymbols ( importAdder , importableReference . symbols ) ;
1174
- }
1175
1162
1176
1163
let body ;
1177
1164
if ( preferences . includeCompletionsWithSnippetText ) {
@@ -1183,15 +1170,25 @@ namespace ts.Completions {
1183
1170
body = factory . createBlock ( [ ] , /* multiline */ true ) ;
1184
1171
}
1185
1172
1173
+ const parameters = typeNode . parameters . map ( typedParam =>
1174
+ factory . createParameterDeclaration (
1175
+ /*decorators*/ undefined ,
1176
+ /*modifiers*/ undefined ,
1177
+ typedParam . dotDotDotToken ,
1178
+ typedParam . name ,
1179
+ typedParam . questionToken ,
1180
+ /*type*/ undefined ,
1181
+ typedParam . initializer ,
1182
+ ) ) ;
1186
1183
return factory . createMethodDeclaration (
1187
1184
/*decorators*/ undefined ,
1188
1185
/*modifiers*/ undefined ,
1189
1186
/*asteriskToken*/ undefined ,
1190
1187
name ,
1191
1188
/*questionToken*/ undefined ,
1192
- ( typeNode as FunctionTypeNode ) . typeParameters ,
1193
- ( typeNode as FunctionTypeNode ) . parameters ,
1194
- ( typeNode as FunctionTypeNode ) . type ,
1189
+ /* typeParameters*/ undefined ,
1190
+ parameters ,
1191
+ /* type*/ undefined ,
1195
1192
body ) ;
1196
1193
}
1197
1194
default :
@@ -1732,29 +1729,6 @@ namespace ts.Completions {
1732
1729
}
1733
1730
}
1734
1731
1735
- if ( source === CompletionSource . ObjectLiteralMethodSnippet ) {
1736
- const enclosingDeclaration = tryGetObjectLikeCompletionContainer ( contextToken ) as ObjectLiteralExpression ;
1737
- const { importAdder } = getEntryForObjectLiteralMethodCompletion (
1738
- symbol ,
1739
- name ,
1740
- enclosingDeclaration ,
1741
- program ,
1742
- host ,
1743
- compilerOptions ,
1744
- preferences ,
1745
- formatContext ) ! ;
1746
- if ( importAdder . hasFixes ( ) ) {
1747
- const changes = textChanges . ChangeTracker . with ( { host, formatContext, preferences } , importAdder . writeFixes ) ;
1748
- return {
1749
- sourceDisplay : undefined ,
1750
- codeActions : [ {
1751
- changes,
1752
- description : diagnosticToString ( [ Diagnostics . Includes_imports_of_types_referenced_by_0 , name ] ) ,
1753
- } ] ,
1754
- } ;
1755
- }
1756
- }
1757
-
1758
1732
if ( originIsTypeOnlyAlias ( origin ) ) {
1759
1733
const codeAction = codefix . getPromoteTypeOnlyCompletionAction (
1760
1734
sourceFile ,
0 commit comments