diff --git a/packages/gatsby-plugin-image/src/components/hooks.ts b/packages/gatsby-plugin-image/src/components/hooks.ts index ce2bd9c5f99fd..038823ce15f97 100644 --- a/packages/gatsby-plugin-image/src/components/hooks.ts +++ b/packages/gatsby-plugin-image/src/components/hooks.ts @@ -27,8 +27,8 @@ export type IGatsbyImageDataParent = T & { export type IGatsbyImageParent = T & { gatsbyImage: IGatsbyImageData } -export type FileNode = Node & { - childImageSharp?: IGatsbyImageDataParent +export type FileNode = Partial & { + childImageSharp?: IGatsbyImageDataParent> } const isGatsbyImageData = ( @@ -54,7 +54,10 @@ export type ImageDataLike = | IGatsbyImageParent | IGatsbyImageData -export const getImage = (node: ImageDataLike): IGatsbyImageData | undefined => { +export const getImage = ( + node: ImageDataLike | null +): IGatsbyImageData | undefined => { + // This checks both for gatsbyImageData and gatsbyImage if (isGatsbyImageData(node)) { return node }