From 0e641632c38383a1d67aa610867496f64ae423ca Mon Sep 17 00:00:00 2001 From: David Sherret Date: Mon, 28 Oct 2024 17:43:41 -0400 Subject: [PATCH] fix(check): expose more globals from @types/node (#26603) Extracted out of https://github.com/denoland/deno/pull/26558 Closes https://github.com/denoland/deno/issues/26578 --- cli/tsc/99_main_compiler.js | 6 ------ tests/specs/npm/compare_globals/__test__.jsonc | 4 ++-- .../compare_globals/{compare_globals => }/main.out | 3 ++- .../npm/compare_globals/{compare_globals => }/main.ts | 11 +++++++++-- 4 files changed, 13 insertions(+), 11 deletions(-) rename tests/specs/npm/compare_globals/{compare_globals => }/main.out (90%) rename tests/specs/npm/compare_globals/{compare_globals => }/main.ts (84%) diff --git a/cli/tsc/99_main_compiler.js b/cli/tsc/99_main_compiler.js index e3a0bee597..6011dece76 100644 --- a/cli/tsc/99_main_compiler.js +++ b/cli/tsc/99_main_compiler.js @@ -1337,18 +1337,12 @@ delete Object.prototype.__proto__; "console", "Console", "ErrorConstructor", - "exports", "gc", "Global", "ImportMeta", "localStorage", - "module", - "NodeModule", - "NodeRequire", - "process", "queueMicrotask", "RequestInit", - "require", "ResponseInit", "sessionStorage", "setImmediate", diff --git a/tests/specs/npm/compare_globals/__test__.jsonc b/tests/specs/npm/compare_globals/__test__.jsonc index e096ddeb22..96458306a7 100644 --- a/tests/specs/npm/compare_globals/__test__.jsonc +++ b/tests/specs/npm/compare_globals/__test__.jsonc @@ -1,4 +1,4 @@ { - "args": "run --allow-read --check=all compare_globals/main.ts", - "output": "compare_globals/main.out" + "args": "run --allow-read --check=all main.ts", + "output": "main.out" } diff --git a/tests/specs/npm/compare_globals/compare_globals/main.out b/tests/specs/npm/compare_globals/main.out similarity index 90% rename from tests/specs/npm/compare_globals/compare_globals/main.out rename to tests/specs/npm/compare_globals/main.out index 5be6125b08..290e9c3b23 100644 --- a/tests/specs/npm/compare_globals/compare_globals/main.out +++ b/tests/specs/npm/compare_globals/main.out @@ -8,10 +8,11 @@ Download http://localhost:4260/@denotest/globals/1.0.0.tgz Download http://localhost:4260/@types/node/node-22.5.4.tgz Download http://localhost:4260/undici-types/undici-types-6.19.8.tgz [UNORDERED_END] -Check file:///[WILDCARD]/compare_globals/main.ts +Check file:///[WILDCARD]/main.ts true true [] +process equals process true setTimeout 1 false setTimeout 2 function setTimeout 3 function diff --git a/tests/specs/npm/compare_globals/compare_globals/main.ts b/tests/specs/npm/compare_globals/main.ts similarity index 84% rename from tests/specs/npm/compare_globals/compare_globals/main.ts rename to tests/specs/npm/compare_globals/main.ts index 9482798d8c..308ce9b23f 100644 --- a/tests/specs/npm/compare_globals/compare_globals/main.ts +++ b/tests/specs/npm/compare_globals/main.ts @@ -5,10 +5,17 @@ console.log(globals.global === globals.globalThis); // @ts-expect-error even though these are the same object, they have different types console.log(globals.globalThis === globalThis); console.log(globals.process.execArgv); +console.log("process equals process", process === globals.process); type AssertTrue = never; -type _TestNoProcessGlobal = AssertTrue< - typeof globalThis extends { process: any } ? false : true +type _TestHasProcessGlobal = AssertTrue< + typeof globalThis extends { process: any } ? true : false +>; +type _TestProcessGlobalVersion = AssertTrue< + typeof process.versions.node extends string ? true : false +>; +type _TestNoBufferGlogal = AssertTrue< + typeof globalThis extends { Buffer: any } ? false : true >; type _TestHasNodeJsGlobal = NodeJS.Architecture;