Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Feb 28, 2022

Conversation

lihbr
Copy link
Member

@lihbr lihbr commented Feb 25, 2022

Types of changes

  • Chore (a non-breaking change which is related to package maintenance)
  • Bug fix (a non-breaking change which fixes an issue)
  • New feature (a non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

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:

  • My change requires an update to the official documentation.
  • All TSDoc comments are up-to-date and new ones have been added where necessary.
  • All new and existing tests are passing.

@angeloashmore
Copy link
Member

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)?

@lihbr lihbr merged commit 32d0a9a into master Feb 28, 2022
@lihbr lihbr deleted the fix/support-union-with-image-thumbnails branch February 28, 2022 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ImageField<ThumbnailNames> works with a single string literal, but not a union
2 participants