sanity icon indicating copy to clipboard operation
sanity copied to clipboard

Wrong type when using image-url like in the example?

Open silvio-e opened this issue 1 year ago • 2 comments

Following example from here:

import imageUrlBuilder from '@sanity/image-url'

export default defineNuxtPlugin(() => {
  const builder = imageUrlBuilder(useSanity().config) // <-- here is the problem
  function urlFor(source) {
    return builder.image(source).auto('format')
  }
  return {
    provide: { urlFor }
  }
})

Doesn't work for me as the type seems wrong:

Argument of type 'SanityConfiguration' is not assignable to parameter of type 'SanityClientLike | SanityProjectDetails | SanityModernClientLike | undefined'.
  Type 'SanityConfiguration' is not assignable to type 'SanityProjectDetails'.
    Types of property 'dataset' are incompatible.
      Type 'string | undefined' is not assignable to type 'string'.
        Type 'undefined' is not assignable to type 'string'.ts(2345)

Should this work?

silvio-e avatar Oct 05 '23 15:10 silvio-e