Skip to content

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

@quisido

Description

@quisido

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions