Skip to content

Commit 51837bb

Browse files
committed
Make ExportedModulesFromDeclarationEmit as ReadonlyArray of symbols combining exportSpecifiers emitted and dynamic import type nodes written
1 parent f7bc8e1 commit 51837bb

File tree

4 files changed

+14
-24
lines changed

4 files changed

+14
-24
lines changed

src/compiler/builderState.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ namespace ts.BuilderState {
260260
if (emitOutput.outputFiles && emitOutput.outputFiles.length > 0) {
261261
latestSignature = computeHash(emitOutput.outputFiles[0].text);
262262
if (exportedModulesMapCache && latestSignature !== prevSignature) {
263-
updateExportedModules(programOfThisState, sourceFile, emitOutput.exportedModulesFromDeclarationEmit, exportedModulesMapCache);
263+
updateExportedModules(sourceFile, emitOutput.exportedModulesFromDeclarationEmit, exportedModulesMapCache);
264264
}
265265
}
266266
else {
@@ -276,20 +276,14 @@ namespace ts.BuilderState {
276276
/**
277277
* Coverts the declaration emit result into exported modules map
278278
*/
279-
function updateExportedModules(programOfThisState: Program, sourceFile: SourceFile, exportedModulesFromDeclarationEmit: ExportedModulesFromDeclarationEmit | undefined, exportedModulesMapCache: ComputingExportedModulesMap) {
279+
function updateExportedModules(sourceFile: SourceFile, exportedModulesFromDeclarationEmit: ExportedModulesFromDeclarationEmit | undefined, exportedModulesMapCache: ComputingExportedModulesMap) {
280280
if (!exportedModulesFromDeclarationEmit) {
281281
exportedModulesMapCache.set(sourceFile.path, false);
282282
return;
283283
}
284284

285-
const checker = programOfThisState.getTypeChecker();
286285
let exportedModules: Map<true> | undefined;
287-
288-
exportedModulesFromDeclarationEmit.exportedModuleSpecifiers.forEach(importName =>
289-
addExportedModule(getReferencedFileFromImportLiteral(checker, importName)));
290-
exportedModulesFromDeclarationEmit.exportedModuleSymbolsUsingImportTypeNodes.forEach(symbol =>
291-
addExportedModule(getReferencedFileFromImportedModuleSymbol(symbol)));
292-
286+
exportedModulesFromDeclarationEmit.forEach(symbol => addExportedModule(getReferencedFileFromImportedModuleSymbol(symbol)));
293287
exportedModulesMapCache.set(sourceFile.path, exportedModules || false);
294288

295289
function addExportedModule(exportedModulePath: Path | undefined) {

src/compiler/checker.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27784,7 +27784,8 @@ namespace ts {
2778427784
setAccessor,
2778527785
getAccessor
2778627786
};
27787-
}
27787+
},
27788+
getSymbolAtLocation
2778827789
};
2778927790

2779027791
function isInHeritageClause(node: PropertyAccessEntityNameExpression) {

src/compiler/transformers/declarations.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ namespace ts {
3737
let lateMarkedStatements: LateVisibilityPaintedStatement[] | undefined;
3838
let lateStatementReplacementMap: Map<VisitResult<LateVisibilityPaintedStatement>>;
3939
let suppressNewDiagnosticContexts: boolean;
40-
let exportedModuleSpecifiers: StringLiteralLike[] | undefined;
41-
let exportedModuleSymbolsUsingImportTypeNodes: Symbol[] | undefined;
40+
let exportedModulesFromDeclarationEmit: Symbol[] | undefined;
4241

4342
const host = context.getEmitHost();
4443
const symbolTracker: SymbolTracker = {
@@ -120,7 +119,7 @@ namespace ts {
120119

121120
function trackExternalModuleSymbolOfImportTypeNode(symbol: Symbol) {
122121
if (!isBundledEmit) {
123-
(exportedModuleSymbolsUsingImportTypeNodes || (exportedModuleSymbolsUsingImportTypeNodes = [])).push(symbol);
122+
(exportedModulesFromDeclarationEmit || (exportedModulesFromDeclarationEmit = [])).push(symbol);
124123
}
125124
}
126125

@@ -233,12 +232,7 @@ namespace ts {
233232
combinedStatements = setTextRange(createNodeArray([...combinedStatements, createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, createNamedExports([]), /*moduleSpecifier*/ undefined)]), combinedStatements);
234233
}
235234
const updated = updateSourceFileNode(node, combinedStatements, /*isDeclarationFile*/ true, references, getFileReferencesForUsedTypeReferences(), node.hasNoDefaultLib);
236-
if (exportedModuleSpecifiers || exportedModuleSymbolsUsingImportTypeNodes) {
237-
updated.exportedModulesFromDeclarationEmit = {
238-
exportedModuleSpecifiers: exportedModuleSpecifiers || emptyArray,
239-
exportedModuleSymbolsUsingImportTypeNodes: exportedModuleSymbolsUsingImportTypeNodes || emptyArray
240-
};
241-
}
235+
updated.exportedModulesFromDeclarationEmit = exportedModulesFromDeclarationEmit;
242236
return updated;
243237

244238
function getFileReferencesForUsedTypeReferences() {
@@ -506,7 +500,10 @@ namespace ts {
506500
}
507501
}
508502
else {
509-
(exportedModuleSpecifiers || (exportedModuleSpecifiers = [])).push(input);
503+
const symbol = resolver.getSymbolAtLocation(input);
504+
if (symbol) {
505+
(exportedModulesFromDeclarationEmit || (exportedModulesFromDeclarationEmit = [])).push(symbol);
506+
}
510507
}
511508
}
512509
return input;

src/compiler/types.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2629,10 +2629,7 @@ namespace ts {
26292629
}
26302630

26312631
/*@internal*/
2632-
export interface ExportedModulesFromDeclarationEmit {
2633-
exportedModuleSpecifiers: ReadonlyArray<StringLiteralLike>;
2634-
exportedModuleSymbolsUsingImportTypeNodes: ReadonlyArray<Symbol>;
2635-
}
2632+
export type ExportedModulesFromDeclarationEmit = ReadonlyArray<Symbol>;
26362633

26372634
export interface Bundle extends Node {
26382635
kind: SyntaxKind.Bundle;
@@ -3375,6 +3372,7 @@ namespace ts {
33753372
isLiteralConstDeclaration(node: VariableDeclaration | PropertyDeclaration | PropertySignature | ParameterDeclaration): boolean;
33763373
getJsxFactoryEntity(location?: Node): EntityName | undefined;
33773374
getAllAccessorDeclarations(declaration: AccessorDeclaration): AllAccessorDeclarations;
3375+
getSymbolAtLocation(node: Node): Symbol | undefined;
33783376
}
33793377

33803378
export const enum SymbolFlags {

0 commit comments

Comments
 (0)