Skip to content

@sanity-client version 7.0.0 type errorΒ #2475

@leeuwd

Description

@leeuwd

Describe the bug

Using next-sanity where the @sanity/client dependency is updated to version 7.0.0 (https://github.com/sanity-io/client/tree/v7.0.0), Typescript type errors appear.

To Reproduce

Steps to reproduce the behavior:

import { ClientConfig, createClient, QueryParams, defineLive } from 'next-sanity'

export const sanityClientConfig: ClientConfig = {
  projectId: process.env.NEXT_PUBLIC_SANITY_PROJECT_ID,
  dataset: process.env.NEXT_PUBLIC_SANITY_PROJECT_DATASET || 'production',
  perspective: 'published'
}

export const sanityClient = createClient(sanityClientConfig)

export const { sanityFetch, SanityLive } = defineLive({
  client: sanityClient,
  browserToken: readToken,
  serverToken: readToken,
})

Typescript error:

web:typecheck: ../../packages/sanity/src/live.ts:12:3 - error TS2322: Type 'import("[REDACTED]/monorepo/node_modules/.pnpm/@[email protected]/node_modules/@sanity/client/dist/index").SanityClient' is not assignable to type 'import("[REDACTED]/monorepo/node_modules/.pnpm/@[email protected][email protected]/node_modules/@sanity/client/dist/index").SanityClient'.
web:typecheck:   Property '#private' in type 'SanityClient' refers to a different member that cannot be accessed from within type 'SanityClient'.
web:typecheck: 
web:typecheck: 12   client: sanityClient,
web:typecheck:      ~~~~~~
web:typecheck: 
web:typecheck:   ../../node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected][email protected]_react-d_09b4da6144152aa4728ba37f85ceda23/node_modules/@sanity/next-loader/dist/index.server-only.d.ts:146:3
web:typecheck:     146   client: SanityClient
web:typecheck:           ~~~~~~
web:typecheck:     The expected type comes from property 'client' which is declared here on type 'DefineSanityLiveOptions'

Expected behavior

No type errors.

Screenshots

Image

Which versions of Sanity are you using?

@sanity/client version 7.0.0 (i.e. latest)
next-sanity version 9.10.2 (i.e. latest)

What operating system are you using?

macOS 15.4.1

Which versions of Node.js / npm are you running?

11.2.0
v22.14.0

Additional context

Turborepo monorepo.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions