mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-19 01:33:15 -05:00
Include reexported names in list of exported names (#38809)
This commit is contained in:
@@ -339,37 +339,6 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
for (const externalImport of moduleInfo.externalImports) {
|
||||
if (externalImport.kind !== SyntaxKind.ExportDeclaration) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!externalImport.exportClause) {
|
||||
// export * from ...
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isNamedExports(externalImport.exportClause)) {
|
||||
for (const element of externalImport.exportClause.elements) {
|
||||
// write name of indirectly exported entry, i.e. 'export {x} from ...'
|
||||
exportedNames.push(
|
||||
createPropertyAssignment(
|
||||
createLiteral(idText(element.name || element.propertyName)),
|
||||
createTrue()
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
else {
|
||||
exportedNames.push(
|
||||
createPropertyAssignment(
|
||||
createLiteral(idText(externalImport.exportClause.name)),
|
||||
createTrue()
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const exportedNamesStorageRef = createUniqueName("exportedNames");
|
||||
statements.push(
|
||||
createVariableStatement(
|
||||
|
||||
@@ -112,26 +112,22 @@ namespace ts {
|
||||
// export * as ns from "mod"
|
||||
// export { x, y } from "mod"
|
||||
externalImports.push(<ExportDeclaration>node);
|
||||
if (isNamedExports((node as ExportDeclaration).exportClause!)) {
|
||||
addExportedNamesForExportDeclaration(node as ExportDeclaration);
|
||||
}
|
||||
else {
|
||||
const name = ((node as ExportDeclaration).exportClause as NamespaceExport).name;
|
||||
if (!uniqueExports.get(idText(name))) {
|
||||
multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), name);
|
||||
uniqueExports.set(idText(name), true);
|
||||
exportedNames = append(exportedNames, name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
// export { x, y }
|
||||
for (const specifier of cast((<ExportDeclaration>node).exportClause, isNamedExports).elements) {
|
||||
if (!uniqueExports.get(idText(specifier.name))) {
|
||||
const name = specifier.propertyName || specifier.name;
|
||||
exportSpecifiers.add(idText(name), specifier);
|
||||
|
||||
const decl = resolver.getReferencedImportDeclaration(name)
|
||||
|| resolver.getReferencedValueDeclaration(name);
|
||||
|
||||
if (decl) {
|
||||
multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(decl), specifier.name);
|
||||
}
|
||||
|
||||
uniqueExports.set(idText(specifier.name), true);
|
||||
exportedNames = append(exportedNames, specifier.name);
|
||||
}
|
||||
}
|
||||
addExportedNamesForExportDeclaration(node as ExportDeclaration);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -200,6 +196,25 @@ namespace ts {
|
||||
}
|
||||
|
||||
return { externalImports, exportSpecifiers, exportEquals, hasExportStarsToExportValues, exportedBindings, exportedNames, externalHelpersImportDeclaration };
|
||||
|
||||
function addExportedNamesForExportDeclaration(node: ExportDeclaration) {
|
||||
for (const specifier of cast(node.exportClause, isNamedExports).elements) {
|
||||
if (!uniqueExports.get(idText(specifier.name))) {
|
||||
const name = specifier.propertyName || specifier.name;
|
||||
exportSpecifiers.add(idText(name), specifier);
|
||||
|
||||
const decl = resolver.getReferencedImportDeclaration(name)
|
||||
|| resolver.getReferencedValueDeclaration(name);
|
||||
|
||||
if (decl) {
|
||||
multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(decl), specifier.name);
|
||||
}
|
||||
|
||||
uniqueExports.set(idText(specifier.name), true);
|
||||
exportedNames = append(exportedNames, specifier.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function collectExportedVariableInfo(decl: VariableDeclaration | BindingElement, uniqueExports: Map<boolean>, exportedNames: Identifier[] | undefined) {
|
||||
|
||||
Reference in New Issue
Block a user