@@ -241,7 +241,6 @@ import {
241241 getAllJSDocTags,
242242 getAllowSyntheticDefaultImports,
243243 getAncestor,
244- getAnyImportSyntax,
245244 getAssignedExpandoInitializer,
246245 getAssignmentDeclarationKind,
247246 getAssignmentDeclarationPropertyAccessKind,
@@ -329,6 +328,7 @@ import {
329328 getModeForUsageLocation,
330329 getModifiers,
331330 getModuleInstanceState,
331+ getModuleSpecifierForImportOrExport,
332332 getNameFromImportAttribute,
333333 getNameFromIndexInfo,
334334 getNameOfDeclaration,
@@ -1477,14 +1477,15 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
14771477 var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : ObjectFlags.FreshLiteral;
14781478 var exactOptionalPropertyTypes = compilerOptions.exactOptionalPropertyTypes;
14791479
1480- var { hasVisibleDeclarations, isEntityNameVisible } = createEntityVisibilityChecker({
1480+ var { hasVisibleDeclarations, isEntityNameVisible, collectLinkedAliases } = createEntityVisibilityChecker({
14811481 defaultSymbolAccessibility: SymbolAccessibility.NotAccessible,
14821482 isThisAccessible,
14831483 isDeclarationVisible,
14841484 markDeclarationAsVisible(declaration) {
14851485 getNodeLinks(declaration).isVisible = true;
14861486 },
14871487 resolveName,
1488+ getTargetOfExportSpecifier,
14881489 });
14891490 var checkBinaryExpression = createCheckBinaryExpression();
14901491 var emitResolver = createResolver();
@@ -4168,23 +4169,6 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
41684169 return exportDefaultSymbol;
41694170 }
41704171
4171- function getModuleSpecifierForImportOrExport(node: ImportEqualsDeclaration | ImportClause | NamespaceImport | ImportOrExportSpecifier): Expression | undefined {
4172- switch (node.kind) {
4173- case SyntaxKind.ImportClause:
4174- return node.parent.moduleSpecifier;
4175- case SyntaxKind.ImportEqualsDeclaration:
4176- return isExternalModuleReference(node.moduleReference) ? node.moduleReference.expression : undefined;
4177- case SyntaxKind.NamespaceImport:
4178- return node.parent.parent.moduleSpecifier;
4179- case SyntaxKind.ImportSpecifier:
4180- return node.parent.parent.parent.moduleSpecifier;
4181- case SyntaxKind.ExportSpecifier:
4182- return node.parent.parent.moduleSpecifier;
4183- default:
4184- return Debug.assertNever(node);
4185- }
4186- }
4187-
41884172 function reportNonDefaultExport(moduleSymbol: Symbol, node: ImportClause) {
41894173 if (moduleSymbol.exports?.has(node.symbol.escapedName)) {
41904174 error(
@@ -10367,48 +10351,6 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
1036710351 return false;
1036810352 }
1036910353
10370- function collectLinkedAliases(node: Identifier, setVisibility?: boolean): Node[] | undefined {
10371- let exportSymbol: Symbol | undefined;
10372- if (node.parent && node.parent.kind === SyntaxKind.ExportAssignment) {
10373- exportSymbol = resolveName(node, node.escapedText, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Alias, /*nameNotFoundMessage*/ undefined, node, /*isUse*/ false);
10374- }
10375- else if (node.parent.kind === SyntaxKind.ExportSpecifier) {
10376- exportSymbol = getTargetOfExportSpecifier(node.parent as ExportSpecifier, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Alias);
10377- }
10378- let result: Node[] | undefined;
10379- let visited: Set<number> | undefined;
10380- if (exportSymbol) {
10381- visited = new Set();
10382- visited.add(getSymbolId(exportSymbol));
10383- buildVisibleNodeList(exportSymbol.declarations);
10384- }
10385- return result;
10386-
10387- function buildVisibleNodeList(declarations: Declaration[] | undefined) {
10388- forEach(declarations, declaration => {
10389- const resultNode = getAnyImportSyntax(declaration) || declaration;
10390- if (setVisibility) {
10391- getNodeLinks(declaration).isVisible = true;
10392- }
10393- else {
10394- result = result || [];
10395- pushIfUnique(result, resultNode);
10396- }
10397-
10398- if (isInternalModuleImportEqualsDeclaration(declaration)) {
10399- // Add the referenced top container visible
10400- const internalModuleReference = declaration.moduleReference as Identifier | QualifiedName;
10401- const firstIdentifier = getFirstIdentifier(internalModuleReference);
10402- const importSymbol = resolveName(declaration, firstIdentifier.escapedText, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false);
10403- if (importSymbol && visited) {
10404- if (tryAddToSet(visited, getSymbolId(importSymbol))) {
10405- buildVisibleNodeList(importSymbol.declarations);
10406- }
10407- }
10408- }
10409- });
10410- }
10411- }
1041210354
1041310355 /**
1041410356 * Push an entry on the type resolution stack. If an entry with the given target and the given property name
0 commit comments