prismicio / prismic-helpers

Set of helpers to manage Prismic data
https://prismic.io/docs/technical-reference/prismicio-helpers
Apache License 2.0
15 stars 9 forks source link

`isFilled.image` does not work with `ImageField` out of the box #45

Closed sylvaingi closed 2 years ago

sylvaingi commented 2 years ago

Hello! Seems like a new variation of https://github.com/prismicio/prismic-helpers/issues/41 cropped up in the latest @prismicio packages.

Versions

Steps to reproduce

type Doc = {
  image: ImageField;
};

const d: Doc = { image: {} };

isFilled.image(d.image);

/*
  Argument of type 'Simplify<(EmptyImageFieldImage | FilledImageFieldImage) & Record<never, EmptyImageFieldImage | FilledImageFieldImage>>' is not assignable to parameter of type 'Simplify<(EmptyImageFieldImage | FilledImageFieldImage) & Record<string, EmptyImageFieldImage | FilledImageFieldImage>> | null | undefined'.
*/

What is expected?

isFilled.image shouldn't require a generic argument to be passed in order to typecheck.

What is actually happening?

Code does not typecheck. isFilled.image<null>(d.image); can be used as a workaround.

lihbr commented 2 years ago

Hey there, thank you so much for opening an issue again!

The image field type has indeed been giving us some trouble for some time now (as you might have followed on @prismicio/types repository) and we hope to see it stabilize.

We'll try to have a look at that quickly!

lihbr commented 2 years ago

Released in 2.2.1, thanks again for your contribution! 🙏