Skip to content

fix(query-devtools): remove experimentalDts to prevent solid-js type leak#10442

Open
namgi2386 wants to merge 1 commit intoTanStack:mainfrom
namgi2386:fix/query-devtools-solid-js-type-leak
Open

fix(query-devtools): remove experimentalDts to prevent solid-js type leak#10442
namgi2386 wants to merge 1 commit intoTanStack:mainfrom
namgi2386:fix/query-devtools-solid-js-type-leak

Conversation

@namgi2386
Copy link
Copy Markdown

@namgi2386 namgi2386 commented Apr 10, 2026

Fixes #10421

Remove experimentalDts: true from packages/query-devtools/tsup.config.ts to prevent internal solid-js types from being exposed in the bundled .d.ts file, which causes TypeScript errors in React projects.


Problem

When using @tanstack/react-query-devtools (v5.96.2+) in a React project, running tsc produces errors for solid-js types:

error TS2307: Cannot find module 'solid-js' or its corresponding type declarations.
error TS2307: Cannot find module '@solid-primitives/storage' or its corresponding type declarations.

This occurs despite solid-js not being a dependency of React projects.

Root Cause

PR #10253 ("ref: ts cutoff") introduced experimentalDts: true across tsup configurations to improve TypeScript version support (5.4+). However:

  1. experimentalDts: true uses @microsoft/api-extractor for deeper type analysis
  2. api-extractor traces JSX type references through jsxImportSource: "solid-js" setting
  3. The resulting bundled .d.ts file includes import { JSX } from 'solid-js'
  4. React projects don't have solid-js installed → TypeScript error

Note: This is not intended as criticism of PR #10253. That PR had valid goals (TypeScript modernization) but didn't account for framework-neutral packages exposing internal implementation details.


Solution

Revert to rollup-plugin-dts (the previous dts: true approach) by removing the two lines added in PR #10253:

// Before
tsup_options.forEach((tsup_option) => {
  tsup_option.outDir = 'build'
  tsup_option.experimentalDts = true   // ← Remove
  delete tsup_option.dts               // ← Remove
})

// After
tsup_options.forEach((tsup_option) => {
  tsup_option.outDir = 'build'
})

Why This Works

  • rollup-plugin-dts treats external packages (solid-js) as external during bundling
  • solid-js types are not included in the final .d.ts file
  • Public API types (TanstackQueryDevtools, DevtoolsButtonPosition, etc.) are preserved
  • Reverts to the behavior of v5.91.3 where this issue did not exist

🎯 Changes

File Modified:

  • packages/query-devtools/tsup.config.ts (2 lines removed)

File Added:

  • .changeset/fix-solid-js-type-leak.md (changeset entry for patch release)

✅ Testing

Build Verification:

# Build succeeds
pnpm --filter @tanstack/query-devtools build

# Verify solid-js is not in bundled .d.ts
grep "solid-js\|solid-primitives" packages/query-devtools/build/index.d.ts
# → No output (success)

# Verify public API types are present
grep "TanstackQueryDevtools\|DevtoolsButtonPosition\|Theme" packages/query-devtools/build/index.d.ts
# → Types found (success)

React Project Type Check:

# React project with @tanstack/react-query-devtools
npx tsc --noEmit
# → No errors (previously showed 6 solid-js errors)

Test Results:

  • ✅ Existing test suite passes (npx nx run @tanstack/query-devtools:test:lib)
  • ✅ Build validation passes (pnpm run test:build)
  • ✅ Multi-version TypeScript validation passes (test:types:ts54~ts60)

📝 Changeset

A changeset has been created for automatic version management:

Package: @tanstack/query-devtools
Type: patch
Description: Fix solid-js types leaking into bundled .d.ts file

🚀 Release Impact

  • Affected Package: @tanstack/query-devtools
  • Impact Level: Patch (bug fix)
  • Breaking Changes: None
  • Migration Required: No (fixes broken type checking)
  • Consumers Affected: All React projects using @tanstack/react-query-devtools (v5.96.2+)

📚 Related Issues


💬 Additional Context

Why Not Update query-devtools To Use solid-query-devtools Approach?

@tanstack/solid-query-devtools also has experimentalDts: true but doesn't have this issue because:

  • It's a SolidJS-specific package
  • Consumers always have solid-js installed
  • Exposing solid-js types is expected and correct

@tanstack/query-devtools is different:

  • Framework-neutral implementation (SolidJS internally, but generic public API)
  • Used in React, Vue, Svelte, Angular projects
  • Internal implementation details must be hidden from consumers

Checklist

  • Read and followed CONTRIBUTING.md guidelines
  • Tested locally with pnpm --filter @tanstack/query-devtools build
  • Verified no solid-js references in bundled .d.ts
  • Verified public API types are preserved
  • Tested React project type checking
  • Created changeset with pnpm changeset
  • Commit follows conventional commit format: fix(query-devtools): ...

Author Notes

This is my first contribution to TanStack/query. I've thoroughly verified the fix works in a real React project scenario and doesn't break existing functionality. I'm ready for any requested changes or clarifications during review.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed TypeScript type definitions that were incorrectly including framework-specific types in React consumer packages.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 10, 2026

📝 Walkthrough

Walkthrough

The changes fix TypeScript type declaration leakage in @tanstack/query-devtools where Solid.js types were appearing in bundled .d.ts files consumed by React projects. The fix removes experimentalDts: true and related dts configuration from the build setup to prevent Solid internal types from being exposed.

Changes

Cohort / File(s) Summary
Changeset Documentation
.changeset/fix-solid-js-type-leak.md
Adds a patch release changeset documenting the fix for Solid.js type leakage in generated TypeScript declarations.
Build Configuration
packages/query-devtools/tsup.config.ts
Removes experimentalDts: true setting and deletion of dts from tsup options, allowing default dts handling and preventing Solid.js type exposure in React consumer bundles.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 A rabbit hops with glee so bright,
Solid types no longer steal the light!
Clean declarations, React's delight,
Types now flow with pure insight! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix(query-devtools): remove experimentalDts to prevent solid-js type leak' directly and accurately describes the main change—removing experimentalDts to fix solid-js type leakage.
Description check ✅ Passed The PR description is thorough and comprehensive, covering problem statement, root cause analysis, solution with code examples, testing verification, changeset, and release impact with clear organization.
Linked Issues check ✅ Passed The PR fully addresses Issue #10421 by removing experimentalDts to prevent solid-js types from leaking into the bundled .d.ts file, eliminating TypeScript errors in React projects.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing Issue #10421: only tsup.config.ts and a changeset file were modified with no extraneous alterations.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.changeset/fix-solid-js-type-leak.md:
- Around line 7-9: The same dts leakage fix needs applying to
packages/solid-query-devtools: open packages/solid-query-devtools/tsup.config.ts
and remove the experimentalDts: true setting and the delete tsup_option.dts
statement so tsup does not bundle d.ts for solid-js; instead ensure the build
uses rollup-plugin-dts (or the existing rollup dts path) which treats solid-js
as external—mirror the exact change made for `@tanstack/query-devtools` by
deleting the experimentalDts flag and the tsup_option.dts deletion so types are
not emitted/bundled into the package.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 90b1cc0e-e188-4bbf-aa09-df347c2429e0

📥 Commits

Reviewing files that changed from the base of the PR and between 5048e86 and c5a2f2b.

📒 Files selected for processing (2)
  • .changeset/fix-solid-js-type-leak.md
  • packages/query-devtools/tsup.config.ts
💤 Files with no reviewable changes (1)
  • packages/query-devtools/tsup.config.ts

Comment on lines +7 to +9
Remove `experimentalDts: true` and `delete tsup_option.dts` from tsup.config.ts to prevent solid-js internal types from being exposed to React projects. Reverts to rollup-plugin-dts which correctly treats solid-js as external.

Fixes #10421
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Check if solid-query-devtools build output contains similar type leakage issues

# Check if solid-query-devtools has the same tsup config pattern
echo "=== Checking solid-query-devtools tsup.config.ts ==="
cat packages/solid-query-devtools/tsup.config.ts

# Check the current build output for type imports (if build exists)
echo -e "\n=== Checking for solid-js imports in solid-query-devtools build output ==="
if [ -f packages/solid-query-devtools/build/index.d.ts ]; then
  rg -n "from ['\"]solid-js|from ['\"]@solid-primitives" packages/solid-query-devtools/build/index.d.ts || echo "No solid-js imports found in build output"
else
  echo "Build output does not exist. Run 'pnpm build' in solid-query-devtools to verify."
fi

# Compare with query-devtools tsup config to see the difference
echo -e "\n=== Comparing with query-devtools tsup.config.ts ==="
cat packages/query-devtools/tsup.config.ts

Repository: TanStack/query

Length of output: 1384


Consider applying the same fix to solid-query-devtools.

The changeset correctly documents the fix for @tanstack/query-devtools. However, packages/solid-query-devtools/tsup.config.ts (lines 19-20) contains the identical problematic pattern (experimentalDts: true and delete tsup_option.dts). Since the issue (#10421) is about dts bundling causing type leakage, solid-query-devtools is susceptible to the same problem and should receive the same fix. Either include it in this PR or open a separate issue to track it.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.changeset/fix-solid-js-type-leak.md around lines 7 - 9, The same dts
leakage fix needs applying to packages/solid-query-devtools: open
packages/solid-query-devtools/tsup.config.ts and remove the experimentalDts:
true setting and the delete tsup_option.dts statement so tsup does not bundle
d.ts for solid-js; instead ensure the build uses rollup-plugin-dts (or the
existing rollup dts path) which treats solid-js as external—mirror the exact
change made for `@tanstack/query-devtools` by deleting the experimentalDts flag
and the tsup_option.dts deletion so types are not emitted/bundled into the
package.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot find module 'solid-js' when typechecking with '@tanstack/query-devtools'

1 participant