Skip to content

@headlessui/react fails with pnpm strict mode — missing peerDependency on @types/react #3865

@baraknaveh

Description

@baraknaveh

@headlessui/react@2.2.9 ships .d.ts files that import from react:

import * as React from 'react';

TypeScript resolves these types through @types/react, but the package only declares react and react-dom as peer dependencies — not @types/react. This works in flat node_modules layouts (npm, yarn) because @types/react is hoisted from the consuming project. When pnpm hoisting is disabled (hoist: false), TypeScript cannot find the React types and fails with:

error TS2307: Cannot find module 'react' or its corresponding type declarations.

Workaround:

packageExtensions:
  "@headlessui/react@2":
    peerDependencies:
      "@types/react": "*"

Suggested fix: Add @types/react to peerDependencies in @headlessui/react's package.json.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions