Skip to content

Commit

Permalink
fix(gatsby-image): Fix typings for fixed and fluid props (#24767)
Browse files Browse the repository at this point in the history
Co-authored-by: Matt Kane <[email protected]>
  • Loading branch information
schwartzmj and ascorbic authored Aug 12, 2020
1 parent e6b6268 commit 08e0aa1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
20 changes: 17 additions & 3 deletions packages/gatsby-image/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,15 @@ export interface FluidObject {
media?: string
}

interface GatsbyImageProps {
interface GatsbyImageOptionalProps {
/**
* @deprecated Use `fixed`
*/
resolutions?: FixedObject
/**
* @deprecated Use `fluid`
*/
sizes?: FluidObject
fixed?: FixedObject | FixedObject[]
fluid?: FluidObject | FluidObject[]
fadeIn?: boolean
durationFadeIn?: number
title?: string
Expand All @@ -49,6 +53,16 @@ interface GatsbyImageProps {
loading?: `auto` | `lazy` | `eager`
draggable?: boolean
}

interface GatsbyImageFluidProps extends GatsbyImageOptionalProps {
fluid: FluidObject | FluidObject[]
}

interface GatsbyImageFixedProps extends GatsbyImageOptionalProps {
fixed: FixedObject | FixedObject[]
}

export type GatsbyImageProps = GatsbyImageFluidProps | GatsbyImageFixedProps

export default class GatsbyImage extends React.Component<
GatsbyImageProps,
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby-image/withIEPolyfill/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from "react"

import GatsbyImage, { GatsbyImageProps } from "../index"

interface GatsbyImageWithIEPolyfillProps extends GatsbyImageProps {
type GatsbyImageWithIEPolyfillProps = GatsbyImageProps & {
objectFit?: `fill` | `contain` | `cover` | `none` | `scale-down`
objectPosition?: string
}
Expand Down

1 comment on commit 08e0aa1

@Erythros
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How's this a fix? Defining childImageSharp: GatsbyImageProps ; now won't work anymore with childImageSharp.fixed.
Instead, we need to use childImageSharp: GatsbyImageFixedProps; (similar for fluid, of course)

Please sign in to comment.