Skip to content

Commit c749068

Browse files
committed
fix: fix crash in import all missing imports codeaction when ignoreAutoImports setting filtered all imports for at least one symbol
1 parent 41cfff0 commit c749068

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

typescript/src/codeFixes.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ export default (proxy: ts.LanguageService, languageService: ts.LanguageService,
185185
}),
186186
({ fix }) => sortFn(fix.moduleSpecifier),
187187
)
188+
if (!fixes[0]) throw new Error('No fixes')
188189
return fixes[0]
189190
}) as any,
190191
),
@@ -196,7 +197,12 @@ export default (proxy: ts.LanguageService, languageService: ts.LanguageService,
196197
},
197198
),
198199
)
199-
importAdder.addImportFromDiagnostic({ ...diagnostic, file: sourceFile as any } as any, context)
200+
try {
201+
importAdder.addImportFromDiagnostic({ ...diagnostic, file: sourceFile as any } as any, context)
202+
} catch (err) {
203+
if (err.message === 'No fixes') continue
204+
throw err
205+
}
200206
} finally {
201207
for (const unpatch of toUnpatch) {
202208
unpatch()

0 commit comments

Comments
 (0)