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

Open Beginner friendly
#3,865 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
68/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
react, typescript
Domain
frontend

Research direction

Start by checking the @headlessui/react package.json and its peerDependencies declaration. Add the missing @types/react peer dependency, then verify the package resolves the imported React types with pnpm hoisting disabled; done means the reported TypeScript error no longer occurs.

Written by the indexing model from the issue text.

Description

@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.

Dominant language
TypeScript
Stars
28.7k
Forks
1.2k
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from tailwindlabs/headlessui

All issues in tailwindlabs/headlessui

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.