mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-10 18:04:18 -05:00
fix(48544): allow to convert default exports to names for import type nodes (#48550)
This commit is contained in:
@@ -1193,10 +1193,15 @@ namespace ts.FindAllReferences {
|
||||
cb: (ref: Identifier) => void,
|
||||
): void {
|
||||
const importTracker = createImportTracker(sourceFiles, new Set(sourceFiles.map(f => f.fileName)), checker, cancellationToken);
|
||||
const { importSearches, indirectUsers } = importTracker(exportSymbol, { exportKind: isDefaultExport ? ExportKind.Default : ExportKind.Named, exportingModuleSymbol }, /*isForRename*/ false);
|
||||
const { importSearches, indirectUsers, singleReferences } = importTracker(exportSymbol, { exportKind: isDefaultExport ? ExportKind.Default : ExportKind.Named, exportingModuleSymbol }, /*isForRename*/ false);
|
||||
for (const [importLocation] of importSearches) {
|
||||
cb(importLocation);
|
||||
}
|
||||
for (const singleReference of singleReferences) {
|
||||
if (isIdentifier(singleReference) && isImportTypeNode(singleReference.parent)) {
|
||||
cb(singleReference);
|
||||
}
|
||||
}
|
||||
for (const indirectUser of indirectUsers) {
|
||||
for (const node of getPossibleSymbolReferenceNodes(indirectUser, isDefaultExport ? "default" : exportName)) {
|
||||
// Import specifiers should be handled by importSearches
|
||||
|
||||
@@ -212,6 +212,10 @@ namespace ts.refactor {
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SyntaxKind.ImportType:
|
||||
const importTypeNode = parent as ImportTypeNode;
|
||||
changes.replaceNode(importingSourceFile, parent, factory.createImportTypeNode(importTypeNode.argument, factory.createIdentifier(exportName), importTypeNode.typeArguments, importTypeNode.isTypeOf));
|
||||
break;
|
||||
default:
|
||||
Debug.failBadSyntaxKind(parent);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user