Skip to content

Commit 4437476

Browse files
authored
Merge pull request #21042 from amcasey/cannotFindModule
Make fixCannotFindModule return an empty array if there is no code action
2 parents bc2983d + 47aad0b commit 4437476

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/services/codefixes/fixCannotFindModule.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ namespace ts.codefix {
44
const errorCodes = [Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type.code];
55
registerCodeFix({
66
errorCodes,
7-
getCodeActions: context => [
8-
{ fixId, ...tryGetCodeActionForInstallPackageTypes(context.host, context.sourceFile.fileName, getModuleName(context.sourceFile, context.span.start)) }
9-
],
7+
getCodeActions: context => {
8+
const codeAction = tryGetCodeActionForInstallPackageTypes(context.host, context.sourceFile.fileName, getModuleName(context.sourceFile, context.span.start));
9+
return codeAction && [{ fixId, ...codeAction }];
10+
},
1011
fixIds: [fixId],
1112
getAllCodeActions: context => codeFixAll(context, errorCodes, (_, diag, commands) => {
1213
const pkg = getTypesPackageNameToInstall(context.host, getModuleName(diag.file, diag.start));

0 commit comments

Comments
 (0)