Declare @types/react as an optional peer dependency
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- react, typescript
- Domain
- build-system
Research direction
Start by checking the package manifests for @dnd-kit/core, @dnd-kit/sortable, and @dnd-kit/utilities, then compare their React peer dependency ranges and peer dependency metadata. Reproduce the resolution issue with the pnpm commands in the issue and inspect the TypeScript trace. Done when each affected package declares optional @types/react and the reproduction resolves React types correctly.
Written by the indexing model from the issue text.
Description
Summary
@dnd-kit/core, @dnd-kit/sortable, @dnd-kit/utilities ship type declarations that import from react but don't declare @types/react.
With an install layout where packages live outside the project, such as pnpm's global virtual store (virtualStoreType: global), TypeScript resolves react from the package's real path. The react peer is linked next to the package, @types/react is not, so TypeScript picks the untyped react/index.js and every React type in these declarations silently becomes any.
Consumers see it as errors in their own code, for example TS7006: Parameter 'x' implicitly has an 'any' type on callback parameters, or component props that lose children and className. Under pnpm's default layout it only works through pnpm's hidden hoisting fallback (node_modules/.pnpm/node_modules).
Affected versions: @dnd-kit/[email protected], @dnd-kit/[email protected], @dnd-kit/[email protected]
Reproduction
pnpm 12.18.0:
mkdir repro && cd repro
echo '{ "name": "repro", "private": true }' > package.json
echo 'virtualStoreType: global' > pnpm-workspace.yaml
pnpm add @dnd-kit/core react react-dom @types/react typescript
echo 'import "@dnd-kit/core";' > index.ts
pnpm exec tsc --noEmit --traceResolution --module esnext --moduleResolution bundler --jsx react-jsx index.ts | grep "Module name 'react' was"
Expected: react resolves to @types/react/index.d.ts.
Actual: .../pnpm/store/v11/links/@/react/<version>/<hash>/node_modules/react/index.js
Suggested fix
"peerDependencies": {
"@types/react": "*"
},
"peerDependenciesMeta": {
"@types/react": { "optional": true }
}
Optional, so JavaScript consumers are unaffected. The range can mirror the existing react peer range. react-router, @tanstack/react-query and recharts (recharts#7710) do the same.
Consumer-side workarounds until then: pnpm's addMissingPeerTypes (pnpm 12.12+) or packageExtensions. Related: pnpm/pnpm#9739.
- Dominant language
- TypeScript
- Stars
- 17.8k
- Forks
- 934
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 7
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from clauderic/dnd-kit
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 1 day
-
Accessibility plugin does O(n²) DOM reads when many draggables mountPossibly taken @dev-noman claimed this 5 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Accessibilty plugin statuses are always in `document.body`Possibly taken @dev-noman claimed this 4 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
clauderic/dnd-kit#2185 · 1 comment ·
Maintainers usually reply within 1 day
-
DndContext does not detach the active sensor when it unmounts mid-dragPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
clauderic/dnd-kit#2179 · 1 comment ·
Maintainers usually reply within 1 day
-
bug experimental react triage:done
Difficulty 1/5 Under an hour Newbie friendliness 65/100
clauderic/dnd-kit#1654 · 5 comments ·
Maintainers usually reply within 1 day
All issues in clauderic/dnd-kit
Similar issues
-
kind:defect
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
mux-labs/mux-frontend#1240 ·
Maintainers usually reply within 1 day
-
area: agents-mcp priority: normal
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
Maintainers usually reply within 1 day
-
Wait for the IDS correction dialog to settle in the stale-audit testPossibly taken @louistrue claimed this today. Openready
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
Hono path parameters with a regex pattern keep the pattern in the OpenAPI pathPossibly taken @0z5a claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
cloudflare/chanfana#400 ·
Maintainers usually reply within 1 day