From f00205279cd53d7efb963a786e577092ba3729ec Mon Sep 17 00:00:00 2001 From: Angelo Ashmore Date: Wed, 5 Jul 2023 13:06:22 -1000 Subject: [PATCH] fix: prevent `` "Element type is invalid" error (#79) * fix: prevent `` "Element type is invalid" error * fix: compat with TypeScript < 4.9 * fix: actual fix for TypeScript < 4.9 --- src/PrismicNextImage.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/PrismicNextImage.tsx b/src/PrismicNextImage.tsx index 6468e7e..86c4cab 100644 --- a/src/PrismicNextImage.tsx +++ b/src/PrismicNextImage.tsx @@ -142,8 +142,16 @@ export const PrismicNextImage = ({ ); } + // TODO: Remove once https://github.com/vercel/next.js/issues/52216 is resolved. + // `next/image` seems to be affected by a default + named export bundling bug. + let ResolvedImage = Image; + if ("default" in ResolvedImage) { + ResolvedImage = (ResolvedImage as unknown as { default: typeof Image }) + .default; + } + return ( -