mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-15 11:35:42 -06:00
Prevent crash on code fixes on default keyword (#48028)
This commit is contained in:
parent
1f52ca8441
commit
4abad556be
@ -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);
|
||||
|
||||
8
tests/cases/fourslash/addAllMissingImportsNoCrash2.ts
Normal file
8
tests/cases/fourslash/addAllMissingImportsNoCrash2.ts
Normal file
@ -0,0 +1,8 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @Filename: file1.ts
|
||||
//// export { /**/default };
|
||||
|
||||
goTo.marker();
|
||||
|
||||
verify.not.codeFixAllAvailable("fixMissingImport");
|
||||
Loading…
x
Reference in New Issue
Block a user