Don't track private symbol roots in other files during js declaration emit (#55390)

This commit is contained in:
Wesley Wigham
2023-08-16 14:13:45 -07:00
committed by GitHub
parent 08b2566e5b
commit ffec968d79
5 changed files with 224 additions and 1 deletions

View File

@@ -8456,7 +8456,13 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
// Lookup the root symbol of the chain of refs we'll use to access it and serialize it
const chain = lookupSymbolChainWorker(sym, context, meaning);
if (!(sym.flags & SymbolFlags.Property)) {
includePrivateSymbol(chain[0]);
// Only include referenced privates in the same file. Weird JS aliases may expose privates
// from other files - assume JS transforms will make those available via expected means
const root = chain[0];
const contextFile = getSourceFileOfNode(oldcontext.enclosingDeclaration);
if (some(root.declarations, d => getSourceFileOfNode(d) === contextFile)) {
includePrivateSymbol(root);
}
}
}
else if (oldcontext.tracker.inner?.trackSymbol) {