prismicio / prismic-react

React components and hooks to fetch and present Prismic content
https://prismic.io/docs/technologies/homepage-reactjs
Apache License 2.0
154 stars 40 forks source link

Update types for HTMLSerializer, RichTextBlock, and RichTextSpan #69

Closed bitmap closed 3 years ago

bitmap commented 3 years ago

I ran into a few odd errors while trying to write an HTML serializer using these typings. Namely:

I also made text and spans optional on RichTextBlock, because it can be an Elements.image type in some cases, and these have props like url, dimensions, alt, and copyright.

Let me know if I missed anything, I haven't tested every single rich text type yet.

Thanks for putting TypeScript typings in the repo. Much appreciated.

YoannDelpierre commented 3 years ago

https://github.com/prismicio/prismic-reactjs/issues/68

Thanks @bitmap πŸ™

m-leon commented 3 years ago

Would be awesome to have these merged.

bitmap commented 3 years ago

πŸ‘‹ Sorry for the last minute update, I found a few missing properties, namely for media links. I didn't know there was a linkTo prop on image blocks as well.

https://github.com/prismicio/prismic-reactjs/pull/69/commits/6cb8da43857108e37f9670a0232520540b1a8c38

lihbr commented 3 years ago

Thanks for making these changes! This should be addressed by the product team next week~ ☺️

proko commented 3 years ago

Thank you for looking into it! Is there a way to "patch" incorrect types in cases like this? I am stuck with my vercel build failing with Type error: Type '(doc: any) => string' is not assignable to type '() => string'. because of the linkResolver?: () => string; prop of the RitchText component

YoannDelpierre commented 3 years ago

Hi, it seems that the last release which incluses this fix has failed

Any idea when it will be available ?

lihbr commented 3 years ago

Hey @YoannDelpierre, what do you mean?

Last release will be published soon if that's what you're wondering πŸ™‚

YoannDelpierre commented 3 years ago

@lihbr ah yes sorry, I saw that the build is failing on master, good to know if the release is soon published πŸ™

YoannDelpierre commented 3 years ago

Yes I saw your issue @Levino

@lihbr Can you deploy the 1.3.3 πŸ™ ?

levino commented 3 years ago

@YoannDelpierre Thanks for picking this up. I guess your comment should be in #73 so @lihbr gets a little bit more context.

Also, have you seen #74? Maintaining the types here is a bad idea. I am happy to elaborate in #74...