Skip to content

[next-themes] Declare optional React type peer - #398

Open
sharmila-oai wants to merge 1 commit into
pacocoursey:mainfrom
sharmila-oai:dev/sharmila/next-themes-type-peer
Open

[next-themes] Declare optional React type peer#398
sharmila-oai wants to merge 1 commit into
pacocoursey:mainfrom
sharmila-oai:dev/sharmila/next-themes-type-peer

Conversation

@sharmila-oai

Copy link
Copy Markdown

Summary

Declare @types/react as an optional peer dependency. The published declarations reference React types, so package managers need this relationship to resolve the consumer's installed types. Keeping the peer optional avoids requiring type packages for JavaScript-only consumers.

This fixes lost callback typing with pnpm's global virtual store. With pnpm 11.19.0, next-themes 0.4.6, React 18.3.1, @types/react 18.3.3, and TypeScript 5.5.4, this consumer reports TS7006 without the peer declaration:

import { useTheme } from 'next-themes'

const { setTheme } = useTheme()
setTheme(theme => theme.toUpperCase())

Only the peer declaration and its workspace lockfile entry change.

Verification

  • The same consumer typechecks against a locally packed copy of this change, with the global virtual store enabled and no packageExtensions.
  • pnpm 9.15.9 frozen install, all 29 existing unit tests, and the package build pass.

@sharmila-oai

Copy link
Copy Markdown
Author

@pacocoursey could you take a look?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant