Make ExportedModulesFromDeclarationEmit as ReadonlyArray of symbols combining exportSpecifiers emitted and dynamic import type nodes written

This commit is contained in:
Sheetal Nandi 2018-08-01 12:37:39 -07:00
parent f7bc8e18e8
commit 51837bb59a
4 changed files with 14 additions and 24 deletions

View file

@ -260,7 +260,7 @@ namespace ts.BuilderState {
if (emitOutput.outputFiles && emitOutput.outputFiles.length > 0) {
latestSignature = computeHash(emitOutput.outputFiles[0].text);
if (exportedModulesMapCache && latestSignature !== prevSignature) {
updateExportedModules(programOfThisState, sourceFile, emitOutput.exportedModulesFromDeclarationEmit, exportedModulesMapCache);
updateExportedModules(sourceFile, emitOutput.exportedModulesFromDeclarationEmit, exportedModulesMapCache);
}
}
else {
@ -276,20 +276,14 @@ namespace ts.BuilderState {
/**
* Coverts the declaration emit result into exported modules map
*/
function updateExportedModules(programOfThisState: Program, sourceFile: SourceFile, exportedModulesFromDeclarationEmit: ExportedModulesFromDeclarationEmit | undefined, exportedModulesMapCache: ComputingExportedModulesMap) {
function updateExportedModules(sourceFile: SourceFile, exportedModulesFromDeclarationEmit: ExportedModulesFromDeclarationEmit | undefined, exportedModulesMapCache: ComputingExportedModulesMap) {
if (!exportedModulesFromDeclarationEmit) {
exportedModulesMapCache.set(sourceFile.path, false);
return;
}
const checker = programOfThisState.getTypeChecker();
let exportedModules: Map<true> | undefined;
exportedModulesFromDeclarationEmit.exportedModuleSpecifiers.forEach(importName =>
addExportedModule(getReferencedFileFromImportLiteral(checker, importName)));
exportedModulesFromDeclarationEmit.exportedModuleSymbolsUsingImportTypeNodes.forEach(symbol =>
addExportedModule(getReferencedFileFromImportedModuleSymbol(symbol)));
exportedModulesFromDeclarationEmit.forEach(symbol => addExportedModule(getReferencedFileFromImportedModuleSymbol(symbol)));
exportedModulesMapCache.set(sourceFile.path, exportedModules || false);
function addExportedModule(exportedModulePath: Path | undefined) {

View file

@ -27784,7 +27784,8 @@ namespace ts {
setAccessor,
getAccessor
};
}
},
getSymbolAtLocation
};
function isInHeritageClause(node: PropertyAccessEntityNameExpression) {

View file

@ -37,8 +37,7 @@ namespace ts {
let lateMarkedStatements: LateVisibilityPaintedStatement[] | undefined;
let lateStatementReplacementMap: Map<VisitResult<LateVisibilityPaintedStatement>>;
let suppressNewDiagnosticContexts: boolean;
let exportedModuleSpecifiers: StringLiteralLike[] | undefined;
let exportedModuleSymbolsUsingImportTypeNodes: Symbol[] | undefined;
let exportedModulesFromDeclarationEmit: Symbol[] | undefined;
const host = context.getEmitHost();
const symbolTracker: SymbolTracker = {
@ -120,7 +119,7 @@ namespace ts {
function trackExternalModuleSymbolOfImportTypeNode(symbol: Symbol) {
if (!isBundledEmit) {
(exportedModuleSymbolsUsingImportTypeNodes || (exportedModuleSymbolsUsingImportTypeNodes = [])).push(symbol);
(exportedModulesFromDeclarationEmit || (exportedModulesFromDeclarationEmit = [])).push(symbol);
}
}
@ -233,12 +232,7 @@ namespace ts {
combinedStatements = setTextRange(createNodeArray([...combinedStatements, createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, createNamedExports([]), /*moduleSpecifier*/ undefined)]), combinedStatements);
}
const updated = updateSourceFileNode(node, combinedStatements, /*isDeclarationFile*/ true, references, getFileReferencesForUsedTypeReferences(), node.hasNoDefaultLib);
if (exportedModuleSpecifiers || exportedModuleSymbolsUsingImportTypeNodes) {
updated.exportedModulesFromDeclarationEmit = {
exportedModuleSpecifiers: exportedModuleSpecifiers || emptyArray,
exportedModuleSymbolsUsingImportTypeNodes: exportedModuleSymbolsUsingImportTypeNodes || emptyArray
};
}
updated.exportedModulesFromDeclarationEmit = exportedModulesFromDeclarationEmit;
return updated;
function getFileReferencesForUsedTypeReferences() {
@ -506,7 +500,10 @@ namespace ts {
}
}
else {
(exportedModuleSpecifiers || (exportedModuleSpecifiers = [])).push(input);
const symbol = resolver.getSymbolAtLocation(input);
if (symbol) {
(exportedModulesFromDeclarationEmit || (exportedModulesFromDeclarationEmit = [])).push(symbol);
}
}
}
return input;

View file

@ -2629,10 +2629,7 @@ namespace ts {
}
/*@internal*/
export interface ExportedModulesFromDeclarationEmit {
exportedModuleSpecifiers: ReadonlyArray<StringLiteralLike>;
exportedModuleSymbolsUsingImportTypeNodes: ReadonlyArray<Symbol>;
}
export type ExportedModulesFromDeclarationEmit = ReadonlyArray<Symbol>;
export interface Bundle extends Node {
kind: SyntaxKind.Bundle;
@ -3375,6 +3372,7 @@ namespace ts {
isLiteralConstDeclaration(node: VariableDeclaration | PropertyDeclaration | PropertySignature | ParameterDeclaration): boolean;
getJsxFactoryEntity(location?: Node): EntityName | undefined;
getAllAccessorDeclarations(declaration: AccessorDeclaration): AllAccessorDeclarations;
getSymbolAtLocation(node: Node): Symbol | undefined;
}
export const enum SymbolFlags {