Skip to content

Duplicate @tanstack/query-core causes type errors with Bun package manager #10426

@piotrkulpinski

Description

@piotrkulpinski

Description

When using @tanstack/react-query@5.96.2 alongside packages that depend on @tanstack/query-core (e.g. @orpc/tanstack-query), Bun creates a nested duplicate of @tanstack/query-core inside node_modules/@tanstack/react-query/node_modules/, even when the versions are identical (both 5.96.2).

This causes TypeScript type errors because the two copies produce incompatible types (different QueryClient class instances from different module paths):

Type 'MutationObserverOptions<...>' is not assignable to type 'UseMutationOptions<...>'.
  Types of property 'onError' are incompatible.
    ...
    Property '#private' in type 'QueryClient' refers to a different member
    that cannot be accessed from within type 'QueryClient'.

Reproduction

  1. Create a project with Bun as the package manager
  2. Install @tanstack/react-query@^5.96.2 and any package that depends on @tanstack/query-core (e.g. @orpc/tanstack-query)
  3. Run bun install
  4. Observe node_modules/@tanstack/react-query/node_modules/@tanstack/query-core/ exists as a separate copy
  5. TypeScript reports type incompatibilities between the two QueryClient classes

Expected behavior

@tanstack/query-core should be hoisted to a single copy in node_modules/@tanstack/query-core/, even when multiple packages depend on it.

Environment

  • Bun: 1.3.9+
  • @tanstack/react-query: 5.96.2
  • @tanstack/query-core: 5.96.2 (duplicated)
  • TypeScript: 6.0.2

Workaround

Adding @tanstack/query-core as a direct dependency or using "overrides" in package.json forces deduplication.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions