sanity-typed-schema-builder icon indicating copy to clipboard operation
sanity-typed-schema-builder copied to clipboard

Fully typing PortableTextBlock in block

Open mckelveygreg opened this issue 3 years ago • 3 comments

I'm attempting to do some pretty complicated block annotations, but this seems to be in the unknown typed portion of the library.

Are there different rules that apply here? I'm having to spread s.<type> instead of using the normal type: s.<type> syntax.

It was working ok, until I started using a custom input that doesn't seem to like the array that I'm updating?

I'm having a hard time figuring out to make a codesandbox reproduction for this as well. Not sure how to setup sanity in something like that.

TLDR;

  • looking for tips for custom annotations
  • looking for sanity codesandbox / stackblitz templates

mckelveygreg avatar Oct 18 '22 18:10 mckelveygreg

The reason this library is giving you trouble is because I'm not really doing anything in the block types for this. You'll either have to create your own type (which is possible) or make a pull request to make s.block more feature complete. Admittedly, I don't really have time anytime soon to address this, and it looks like it might be a hefty amount of work. I'm noticing that it's not even attempted to be typed in @sanity/types (it's actually incorrectly typed as being an array any[]).

saiichihashimoto avatar Jan 05 '23 05:01 saiichihashimoto

After #186 , the block types are a lot more filled out!

mckelveygreg avatar Jan 12 '23 16:01 mckelveygreg

@mckelveygreg, not sure why the block types would be different... they were wrong in @sanity/types so I was overriding them (you can see the overrides here: https://github.com/saiichihashimoto/sanity-typed-schema-builder/blob/master/src/block/index.ts) We never got rid of the overrides, so the block types should be the same. Not sure how this issue got fixed but, if it did, that's awesome 🙃

image

I'm going to reopen this issue. I had assumed it to do with the generics that PortableTextBlock comes with. Currently, it uses the default, which isn't narrowed or widened to what someone might be adding to sanity.

saiichihashimoto avatar Jan 12 '23 18:01 saiichihashimoto