Open EricWVGG opened 1 year ago
I love the plugin but am having the same issue with Typescript. Just using // @ts-ignore
above the urlPrefix for now as the studio will still compile without issue, but I would like to not have to do this.
Pretty easy fix. They just need to pass options into the component
components: { input: (props) => CustomSlugInput(props, prefixer), },
can you explain what do you mean by the prefixer
Pretty easy fix. They just need to pass options into the component
components: { input: (props) => CustomSlugInput(props, prefixer), },
You just need to add to your index.d.ts:
declare module 'sanity' {
interface SlugOptions {
urlPrefix?: string
}
}
Sanity 3 has new Typescript helpers —
defineType()
anddefineField()
for defining documents, objects, and fields.These helpers convert schemas into rich Typescript objects, along with all the usual advantages that come with that. It makes writing custom validators and "hidden" rules much easier and more feature-rich. (I imagine it has enormous advantages for writing custom components, as well.)
Unfortunately, these types do not allow custom options in schema objects, so this fails the Typescript validator:
… IMO @sanity-io should be typing options as
Record<string, any>
to allow for custom properties, but for whatever reason that's strict right now.