react-spectrum icon indicating copy to clipboard operation
react-spectrum copied to clipboard

`@react-aria/utils` should not depend on `@types/node`.

Open quisido opened this issue 2 weeks ago โ€ข 1 comments

Provide a general summary of the issue here

This one function, getOwnerWindow, references typeof global, which is only defined by @types/node (and is not a dependency).

๐Ÿค” Expected Behavior?

Projects that do not build for Node should be able to use React ARIA.

๐Ÿ˜ฏ Current Behavior

Projects that do not build for Node must install and include @types/node in order to build, due to this one function.

๐Ÿ’ Possible Solution

  1. Remove typeof global and keep it as just Window.
  2. Include /// <reference types="node" /> at the top of the domHelpers.ts file so that its definition is included in that file but not required by consumers to install project-wide. a. Possibly add @types/node as a dependency of @react-aria/utils.

I prefer option 1; but if this is really needed, then please go with option 2 so that @types/node does not need to be project-wide for consumers.

๐Ÿ”ฆ Context

When using React ARIA as a dependency of a non-Node project, this creates a build error: Cannot find name 'global'..

๐Ÿ–ฅ๏ธ Steps to Reproduce

  1. Create a new project.
  2. Configure TypeScript to not use external types and to check libaries.
    {
      "compilerOptions": {
        "skipLibCheck": false,
        "typeRoots": [],
        "types": []
      }
    }
    
  3. Install React ARIA as a dependency.
  4. Import a React ARIA component.
  5. tsc

Version

latest

What browsers are you seeing the problem on?

Other

If other, please specify.

build environment

What operating system are you using?

Linux

๐Ÿงข Your Company/Team

No response

๐Ÿ•ท Tracking Issue

No response

quisido avatar Nov 26 '25 22:11 quisido