Skip to content

Declare @types/react for next-themes - #649

Merged
dferber90 merged 1 commit into
mainfrom
fix/next-themes-react-types
Nov 26, 2026
Merged

dferber90 merged 1 commit into
mainfrom
fix/next-themes-react-types

Conversation

@dferber90

Copy link
Copy Markdown
Collaborator

The flags-sdk-snippets build sometimes fails with:

app/layout.tsx(34,10): error TS2322: ... Property 'children' does not exist on type 'IntrinsicAttributes & ThemeProviderProps'.

Cause

next-themes imports React types but does not declare @types/react. Its types find React only through pnpm's hoisted link node_modules/.pnpm/node_modules/@types/react.

main has two versions of @types/react (18.3.28 and 19.2.14), and pnpm hoists 18.3.28. The standard branch has only 19.2.14. When a build restores a cache from a build with the other lockfile, pnpm removes the old package and its hoisted link, but it does not create a new link. Without React types, ThemeProviderProps has no children.

I reproduced this locally: a clean install of main, then pnpm install --frozen-lockfile on changeset-release/standard. The hoisted link was missing after the install, and tsc gave the same 3 errors.

Fix

A packageExtensions entry in pnpm-workspace.yaml declares @types/react as an optional peer of next-themes, so pnpm links it directly. With the hoisted link removed, examples/snippets gives no next-themes errors.

🤖 Generated with Claude Code

next-themes imports React types but does not declare @types/react, so
its types depended on pnpm's hoisted @types/react. When Vercel restores
a build cache from a lockfile with another @types/react version, pnpm
removes the old hoisted link and does not create a new one. Then
ThemeProviderProps has no `children`, and the snippets build fails.

With packageExtensions, pnpm links @types/react directly to next-themes.

Co-Authored-By: Claude <noreply@anthropic.com>
@vercel

vercel Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
flags-playground Ready Ready Preview, v0 Nov 26, 2026 12:29pm UTC
flags-sdk-dev Ready Ready Preview, v0 Nov 26, 2026 12:29pm UTC
flags-sdk-flagsmith Ready Ready Preview, v0 Nov 26, 2026 12:29pm UTC
flags-sdk-growthbook Ready Ready Preview, v0 Nov 26, 2026 12:29pm UTC
flags-sdk-launchdarkly Ready Ready Preview, v0 Nov 26, 2026 12:29pm UTC
flags-sdk-openfeature Ready Ready Preview, v0 Nov 26, 2026 12:29pm UTC
flags-sdk-posthog Ready Ready Preview, v0 Nov 26, 2026 12:29pm UTC
flags-sdk-reflag Ready Ready Preview, v0 Nov 26, 2026 12:29pm UTC
flags-sdk-snippets Ready Ready Preview, v0 Nov 26, 2026 12:29pm UTC
flags-sdk-statsig Ready Ready Preview, v0 Nov 26, 2026 12:29pm UTC
flags-sdk-sveltekit-snippets Ready Ready Preview, v0 Nov 26, 2026 12:29pm UTC
shirt-shop Ready Ready Preview, v0 Nov 26, 2026 12:29pm UTC
shirt-shop-api Ready Ready Preview, v0 Nov 26, 2026 12:29pm UTC

@dferber90
dferber90 merged commit 724cabb into main Nov 26, 2026
30 checks passed
@dferber90
dferber90 deleted the fix/next-themes-react-types branch November 26, 2026 12:52

This branch was successfully deployed

14 active deployments
Preview – flags-sdk-dev — 39ec8cd1 Deployed Nov 26, 2026 by vercel[bot]
Preview – flags-sdk-sveltekit-snippets — 39ec8cd1 Deployed Nov 26, 2026 by vercel[bot]
Preview – flags-sdk-growthbook — 39ec8cd1 Deployed Nov 26, 2026 by vercel[bot]
Preview – shirt-shop — 39ec8cd1 Deployed Nov 26, 2026 by vercel[bot]
Preview – flags-sdk-launchdarkly — 39ec8cd1 Deployed Nov 26, 2026 by vercel[bot]
Preview – flags-sdk-snippets — 39ec8cd1 Deployed Nov 26, 2026 by vercel[bot]
Preview – flags-sdk-statsig — 39ec8cd1 Deployed Nov 26, 2026 by vercel[bot]
Preview – flags-sdk-flagsmith — 39ec8cd1 Deployed Nov 26, 2026 by vercel[bot]
Preview – flags-sdk-posthog — 39ec8cd1 Deployed Nov 26, 2026 by vercel[bot]
Preview – flags-sdk-reflag — 39ec8cd1 Deployed Nov 26, 2026 by vercel[bot]
Preview – flags-sdk-vercel — 39ec8cd1 Deployed Nov 26, 2026 by vercel[bot]
Preview – flags-playground — 39ec8cd1 Deployed Nov 26, 2026 by vercel[bot]
Preview – flags-sdk-openfeature — 39ec8cd1 Deployed Nov 26, 2026 by vercel[bot]
Preview – shirt-shop-api — 39ec8cd1 Deployed Nov 26, 2026 by vercel[bot]
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.

2 participants