Found while implementing objectui#6779 (PR #6808), out of that card's scope and filed rather than fixed.
What
packages/components/src/global.d.ts declares a browser shim for the process global:
// Global process for browser environmentsdeclareconstprocess: {env: {NODE_ENV: string;};};packages/components/tsconfig.test.json sets "types": ["node", "@testing-library/jest-dom"], so @types/node IS in the test project. But the ambient declare const process above wins over the node global, and — because @types/node spells its module as export = process — it also becomes what import process from 'node:process' resolves to.
Measured, three spellings, same package
Trying to read the repo root in a test under packages/components/src/:
| spelling | result |
|---|
process.cwd() | error TS2339: Property 'cwd' does not exist on type '{ env: { NODE_ENV: string; }; }' |
import process from 'node:process' then process.cwd() | same TS2339 |
import nodeProcess from 'node:process' then nodeProcess.cwd() | same TS2339 |
Runtime is plain node in every case and all three work; only the declaration is wrong. The workaround PR #6808 used, with the reasoning written out at the call site:
(globalThisasunknownas{process: {cwd(): string}}).process.cwd()Why it is worth recording
The failure mode is a confusing, self-contradicting diagnostic: types: ["node"] is configured, the import resolves, and the compiler still says the property is missing. The obvious next moves — importing the module, renaming the binding — both fail identically, so the cost is a real detour each time. It is also asymmetric with the rest of the repo: packages/i18n tests read their ratchet baselines with the plain join(process.cwd(), 'scripts/...') idiom, which simply does not compile in packages/components.
Not urgent: nothing is broken at runtime, and the workaround is local and documented.
Possible directions (not a recommendation — this needs a look, not a guess)
- Narrow the shim to
src only, so the test project keeps the real node global. The shim exists for browser builds; the test project is not one. - Or move it inside a
declare global block scoped so it augments rather than replaces NodeJS.Process. - Or leave it and add a one-line comment at the declaration pointing at this issue, so the next person loses minutes instead of a detour.
Whoever picks this up should check whether the shim is still load-bearing at all — tsconfig.json already excludes tests, so the shim's audience is the package source.
Generated by Claude Code
Found while implementing objectui#6779 (PR #6808), out of that card's scope and filed rather than fixed.
What
packages/components/src/global.d.tsdeclares a browser shim for theprocessglobal:packages/components/tsconfig.test.jsonsets"types": ["node", "@testing-library/jest-dom"], so@types/nodeIS in the test project. But the ambientdeclare const processabove wins over the node global, and — because@types/nodespells its module asexport = process— it also becomes whatimport process from 'node:process'resolves to.Measured, three spellings, same package
Trying to read the repo root in a test under
packages/components/src/:process.cwd()error TS2339: Property 'cwd' does not exist on type '{ env: { NODE_ENV: string; }; }'import process from 'node:process'thenprocess.cwd()import nodeProcess from 'node:process'thennodeProcess.cwd()Runtime is plain node in every case and all three work; only the declaration is wrong. The workaround PR #6808 used, with the reasoning written out at the call site:
Why it is worth recording
The failure mode is a confusing, self-contradicting diagnostic:
types: ["node"]is configured, the import resolves, and the compiler still says the property is missing. The obvious next moves — importing the module, renaming the binding — both fail identically, so the cost is a real detour each time. It is also asymmetric with the rest of the repo:packages/i18ntests read their ratchet baselines with the plainjoin(process.cwd(), 'scripts/...')idiom, which simply does not compile inpackages/components.Not urgent: nothing is broken at runtime, and the workaround is local and documented.
Possible directions (not a recommendation — this needs a look, not a guess)
srconly, so the test project keeps the real node global. The shim exists for browser builds; the test project is not one.declare globalblock scoped so it augments rather than replacesNodeJS.Process.Whoever picks this up should check whether the shim is still load-bearing at all —
tsconfig.jsonalready excludes tests, so the shim's audience is the package source.Generated by Claude Code