prismicio / prismic-types

Type definitions for Prismic content, models, and APIs
https://prismic.io/docs/technologies/javascript
Apache License 2.0
11 stars 4 forks source link

fix: support union with image thumbnails, fixes #27 #29

Closed lihbr closed 2 years ago

lihbr commented 2 years ago

Types of changes

Description

Union with image thumbnails were not handled correctly with TypeScript. This PR fixes it by refactoring the type, extending the root image object with thumbnails, and wrapping it with Omit<> to prevent TypeScript from considering the refactored type as an array (found by @angeloashmore).

Just created a PR to make sure we're aligned on it before moving forward with this "hacky" method. The goal of @prismicio/types being to provide types as close and precise as possible to what Prismic API responses can be.

Resolves: #27

Checklist:

angeloashmore commented 2 years ago

This looks good to me. What do you think about adding a comment about why Omit is used (just a // comment, not in the TSDoc)?