sanity-io / sanity-plugin-hotspot-array

A configurable Custom Input for Arrays that will add and update items by clicking on an Image
MIT License
23 stars 8 forks source link

@sanity/types imageHotspot declare module not working #16

Closed rafaelderolez closed 10 months ago

rafaelderolez commented 1 year ago

The module declaration to allow imageHotspot into ArrayOptions does not seem to work.

Schema

defineField({
  name: 'hotspots',
  type: 'array',
  options: {
    imageHotspot: { 
      imagePath: 'image',
      descriptionPath: 'label',
    },
  },
  of: [
    {
      // spot object here
    }
  ]
})

Error

I get the following TypeScript error:

Type '{ imageHotspot: { imagePath: string; descriptionPath: string; }; }'
is not assignable to type 'ArrayOptions<unknown>'.

Object literal may only specify known properties, and 'imageHotspot'
does not exist in type 'ArrayOptions<unknown>'.

When adding the declaration manually into my project, the error above disappears.

import { ImageHotspotOptions } from 'sanity-plugin-hotspot-array';

declare module '@sanity/types' {
  export interface ArrayOptions {
    imageHotspot?: ImageHotspotOptions
  }
}

Relevant dependencies:

"sanity": "^3.16.4"
"typescript": "^5.2.2"
"sanity-plugin-hotspot-array": "^1.0.1",
piersolenski commented 1 year ago

I don't know who this @rafaelderolez guy is but he always writes such great, concise issues. Cheers @rafaelderolez, you're doing the Lord's work.

ciruz commented 11 months ago

@rafaelderolez we had the same error, after updating sanity to 3.20.2 the error is finally gone.

rafaelderolez commented 10 months ago

@rafaelderolez we had the same error, after updating sanity to 3.20.2 the error is finally gone.

@ciruz You're right! I was able to remove the manual declare module previously mentioned without errors. Closing!

piersolenski commented 10 months ago

I'm not sure who this @rafaelderolez guy is, but the way he closes an issue just gets my juices going. Thanks, @rafaelderolez .