diff --git a/src/services/codefixes/importFixes.ts b/src/services/codefixes/importFixes.ts index c3e6087839bd9..485fc02727990 100644 --- a/src/services/codefixes/importFixes.ts +++ b/src/services/codefixes/importFixes.ts @@ -847,9 +847,10 @@ namespace ts.codefix { const checker = program.getTypeChecker(); const compilerOptions = program.getCompilerOptions(); const symbolName = getSymbolName(sourceFile, checker, symbolToken, compilerOptions); - // "default" is a keyword and not a legal identifier for the import, so we don't expect it here - Debug.assert(symbolName !== InternalSymbolName.Default, "'default' isn't a legal identifier and couldn't occur here"); - + // "default" is a keyword and not a legal identifier for the import, but appears as an identifier. + if (symbolName === InternalSymbolName.Default) { + return undefined; + } const isValidTypeOnlyUseSite = isValidTypeOnlyAliasUseSite(symbolToken); const useRequire = shouldUseRequire(sourceFile, program); const exportInfo = getExportInfos(symbolName, isJSXTagName(symbolToken), getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, program, useAutoImportProvider, host, preferences); diff --git a/tests/cases/fourslash/addAllMissingImportsNoCrash2.ts b/tests/cases/fourslash/addAllMissingImportsNoCrash2.ts new file mode 100644 index 0000000000000..9e1dfaa1fa834 --- /dev/null +++ b/tests/cases/fourslash/addAllMissingImportsNoCrash2.ts @@ -0,0 +1,8 @@ +/// + +// @Filename: file1.ts +//// export { /**/default }; + +goTo.marker(); + +verify.not.codeFixAllAvailable("fixMissingImport");