Store symbol table map key in CachedSymbolExportInfo (#45289)

* Store symbol table map key in CachedSymbolExportInfo

* Remove debug assertion

* Filter out known symbols (again) and private identifiers
This commit is contained in:
Andrew Branch
2021-08-04 16:31:47 -07:00
committed by GitHub
parent 2bae169306
commit f80bc3f5f0
6 changed files with 61 additions and 21 deletions

View File

@@ -581,6 +581,7 @@ namespace ts {
getEmitResolver,
getExportsOfModule: getExportsOfModuleAsArray,
getExportsAndPropertiesOfModule,
forEachExportAndPropertyOfModule,
getSymbolWalker: createGetSymbolWalker(
getRestTypeOfSignature,
getTypePredicateOfSignature,
@@ -3532,6 +3533,24 @@ namespace ts {
return exports;
}
function forEachExportAndPropertyOfModule(moduleSymbol: Symbol, cb: (symbol: Symbol, key: __String) => void): void {
const exports = getExportsOfModule(moduleSymbol);
exports.forEach((symbol, key) => {
if (!isReservedMemberName(key)) {
cb(symbol, key);
}
});
const exportEquals = resolveExternalModuleSymbol(moduleSymbol);
if (exportEquals !== moduleSymbol) {
const type = getTypeOfSymbol(exportEquals);
if (shouldTreatPropertiesOfExternalModuleAsExports(type)) {
getPropertiesOfType(type).forEach(symbol => {
cb(symbol, symbol.escapedName);
});
}
}
}
function tryGetMemberInModuleExports(memberName: __String, moduleSymbol: Symbol): Symbol | undefined {
const symbolTable = getExportsOfModule(moduleSymbol);
if (symbolTable) {

View File

@@ -4225,6 +4225,7 @@ namespace ts {
getExportsOfModule(moduleSymbol: Symbol): Symbol[];
/** Unlike `getExportsOfModule`, this includes properties of an `export =` value. */
/* @internal */ getExportsAndPropertiesOfModule(moduleSymbol: Symbol): Symbol[];
/* @internal */ forEachExportAndPropertyOfModule(moduleSymbol: Symbol, cb: (symbol: Symbol, key: __String) => void): void;
getJsxIntrinsicTagNamesAt(location: Node): Symbol[];
isOptionalParameter(node: ParameterDeclaration): boolean;
getAmbientModules(): Symbol[];

View File

@@ -3289,6 +3289,10 @@ namespace ts {
return startsWith(symbol.escapedName as string, "__@");
}
export function isPrivateIdentifierSymbol(symbol: Symbol): boolean {
return startsWith(symbol.escapedName as string, "__#");
}
/**
* Includes the word "Symbol" with unicode escapes
*/