Repository navigation
fix(react): declare @types/react as an optional peer dependency - #1418
Open
abdul-karim-mia wants to merge 1 commit into
Open
abdul-karim-mia wants to merge 1 commit into
abdul-karim-mia wants to merge 1 commit into
Conversation
Closes tailwindlabs#1417 Signed-off-by: Abdul karim mia <97598943+abdul-karim-mia@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1417.
Summary
@heroicons/reactships type declaration files (.d.ts) that import fromreact(import * as React from 'react').Under strict or isolated installation layouts (such as pnpm with
virtualStoreType: global, Yarn PnP, or Bun's isolated linker), packages resolve dependencies and peer dependencies from their real disk locations. Because@types/reactwas not declared as a peer dependency, TypeScript resolvesreactto the untypedreact/index.jsfile rather than@types/react/index.d.ts. As a result, React types in@heroicons/reactcomponents can degrade toanyor trigger compiler errors (e.g.TS7006: Parameter 'x' implicitly has an 'any' type).Solution
Declare
@types/reactas an optional peer dependency inreact/package.json:"optional": trueunderpeerDependenciesMetaso plain JavaScript consumers never receive peer dependency warnings.*to accommodate any supported React version (16, 17, 18, 19) without restrictive version bounds.@tanstack/react-query,@radix-ui/*,recharts#7710,react-router).Verification
npm run lint(node ./scripts/verify-names.js): passed (All good!).node ./scripts/build.js react: rebuilt cleanly with 0 errors and preserved exports.npx prettier --check react/package.json: formatted cleanly.