@@ -96,7 +96,6 @@ namespace ts.Completions {
9696 }
9797
9898 interface SymbolOriginInfoObjectLiteralMethod extends SymbolOriginInfo {
99- importAdder : codefix . ImportAdder ,
10099 insertText : string ,
101100 labelDetails : CompletionEntryLabelDetails ,
102101 isSnippet ?: true ,
@@ -780,17 +779,13 @@ namespace ts.Completions {
780779 }
781780
782781 if ( origin && originIsObjectLiteralMethod ( origin ) ) {
783- let importAdder ;
784- ( { insertText, isSnippet, importAdder, labelDetails } = origin ) ;
782+ ( { insertText, isSnippet, labelDetails } = origin ) ;
785783 if ( ! preferences . useLabelDetailsInCompletionEntries ) {
786784 name = name + labelDetails . detail ;
787785 labelDetails = undefined ;
788786 }
789787 source = CompletionSource . ObjectLiteralMethodSnippet ;
790788 sortText = SortText . SortBelow ( sortText ) ;
791- if ( importAdder . hasFixes ( ) ) {
792- hasAction = true ;
793- }
794789 }
795790
796791 if ( isJsxIdentifierExpected && ! isRightOfOpenTag && preferences . includeCompletionsWithSnippetText && preferences . jsxAttributeCompletionStyle && preferences . jsxAttributeCompletionStyle !== "none" ) {
@@ -1072,14 +1067,13 @@ namespace ts.Completions {
10721067 options : CompilerOptions ,
10731068 preferences : UserPreferences ,
10741069 formatContext : formatting . FormatContext | undefined ,
1075- ) : { insertText : string , isSnippet ?: true , importAdder : codefix . ImportAdder , labelDetails : CompletionEntryLabelDetails } | undefined {
1070+ ) : { insertText : string , isSnippet ?: true , labelDetails : CompletionEntryLabelDetails } | undefined {
10761071 const isSnippet = preferences . includeCompletionsWithSnippetText || undefined ;
10771072 let insertText : string = name ;
10781073
10791074 const sourceFile = enclosingDeclaration . getSourceFile ( ) ;
1080- const importAdder = codefix . createImportAdder ( sourceFile , program , preferences , host ) ;
10811075
1082- const method = createObjectLiteralMethod ( symbol , enclosingDeclaration , sourceFile , program , host , preferences , importAdder ) ;
1076+ const method = createObjectLiteralMethod ( symbol , enclosingDeclaration , sourceFile , program , host , preferences ) ;
10831077 if ( ! method ) {
10841078 return undefined ;
10851079 }
@@ -1115,7 +1109,7 @@ namespace ts.Completions {
11151109 method . type ) ;
11161110 const labelDetails = { detail : signaturePrinter . printNode ( EmitHint . Unspecified , methodSignature , sourceFile ) } ;
11171111
1118- return { isSnippet, insertText, importAdder , labelDetails } ;
1112+ return { isSnippet, insertText, labelDetails } ;
11191113
11201114 } ;
11211115
@@ -1126,14 +1120,12 @@ namespace ts.Completions {
11261120 program : Program ,
11271121 host : LanguageServiceHost ,
11281122 preferences : UserPreferences ,
1129- importAdder : codefix . ImportAdder ,
11301123 ) : MethodDeclaration | undefined {
11311124 const declarations = symbol . getDeclarations ( ) ;
11321125 if ( ! ( declarations && declarations . length ) ) {
11331126 return undefined ;
11341127 }
11351128 const checker = program . getTypeChecker ( ) ;
1136- const scriptTarget = getEmitScriptTarget ( program . getCompilerOptions ( ) ) ;
11371129 const declaration = declarations [ 0 ] ;
11381130 const name = getSynthesizedDeepClone ( getNameOfDeclaration ( declaration ) , /*includeTrivia*/ false ) as PropertyName ;
11391131 const type = checker . getWidenedType ( checker . getTypeOfSymbolAtLocation ( symbol , enclosingDeclaration ) ) ;
@@ -1163,15 +1155,10 @@ namespace ts.Completions {
11631155 // We don't support overloads in object literals.
11641156 return undefined ;
11651157 }
1166- let typeNode = checker . typeToTypeNode ( effectiveType , enclosingDeclaration , builderFlags , codefix . getNoopSymbolTrackerWithResolver ( { program, host } ) ) ;
1158+ const typeNode = checker . typeToTypeNode ( effectiveType , enclosingDeclaration , builderFlags , codefix . getNoopSymbolTrackerWithResolver ( { program, host } ) ) ;
11671159 if ( ! typeNode || ! isFunctionTypeNode ( typeNode ) ) {
11681160 return undefined ;
11691161 }
1170- const importableReference = codefix . tryGetAutoImportableReferenceFromTypeNode ( typeNode , scriptTarget ) ;
1171- if ( importableReference ) {
1172- typeNode = importableReference . typeNode ;
1173- codefix . importSymbols ( importAdder , importableReference . symbols ) ;
1174- }
11751162
11761163 let body ;
11771164 if ( preferences . includeCompletionsWithSnippetText ) {
@@ -1183,15 +1170,25 @@ namespace ts.Completions {
11831170 body = factory . createBlock ( [ ] , /* multiline */ true ) ;
11841171 }
11851172
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+ ) ) ;
11861183 return factory . createMethodDeclaration (
11871184 /*decorators*/ undefined ,
11881185 /*modifiers*/ undefined ,
11891186 /*asteriskToken*/ undefined ,
11901187 name ,
11911188 /*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 ,
11951192 body ) ;
11961193 }
11971194 default :
@@ -1732,29 +1729,6 @@ namespace ts.Completions {
17321729 }
17331730 }
17341731
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-
17581732 if ( originIsTypeOnlyAlias ( origin ) ) {
17591733 const codeAction = codefix . getPromoteTypeOnlyCompletionAction (
17601734 sourceFile ,
0 commit comments