Skip to content

Commit

Permalink
allow @types/node disallowed globals to be assigned to if the symbol …
Browse files Browse the repository at this point in the history
…was previously created in the @types/node pkg
  • Loading branch information
dsherret committed Jan 31, 2025
1 parent 092705f commit 4829ac9
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions cli/tsc/00_typescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -11352,16 +11352,31 @@ function createDenoForkContext({
function mergeGlobalSymbolTable(node, source, unidirectional = false) {
const sourceFile = getSourceFileOfNode(node);
const isNodeFile = hasNodeSourceFile(sourceFile);
const isTypesNodeSourceFile = isNodeFile && sourceFile.path.endsWith(".d.ts") && sourceFile.path.includes("/@types/node/");
const isTypesNodeSourceFile = isNodeFile && isTypesNodePkgPath(sourceFile.path);
source.forEach((sourceSymbol, id) => {
const target = isNodeFile ? getGlobalsForName(id) : globals;
const targetSymbol = target.get(id);
if (isTypesNodeSourceFile && targetSymbol !== void 0 && typesNodeIgnorableNames.has(id)) {
if (isTypesNodeSourceFile && targetSymbol !== void 0 && typesNodeIgnorableNames.has(id) && !symbolHasAnyTypesNodePkgDecl(targetSymbol)) {
return;
}
target.set(id, targetSymbol ? mergeSymbol(targetSymbol, sourceSymbol, unidirectional) : sourceSymbol);
});
}
function symbolHasAnyTypesNodePkgDecl(symbol) {
if (symbol.declarations) {
for (const decl of symbol.declarations) {
const sourceFile = getSourceFileOfNode(decl);
const isNodeFile = hasNodeSourceFile(sourceFile);
if (isNodeFile && isTypesNodePkgPath(sourceFile.path)) {
return true;
}
}
}
return false;
}
function isTypesNodePkgPath(path) {
return path.endsWith(".d.ts") && path.includes("/@types/node/");
}
function createNodeGlobalsSymbolTable() {
return new Proxy(globals, {
get(target, prop, receiver) {
Expand Down

0 comments on commit 4829ac9

Please sign in to comment.