Unverified Commit 0ce55e3f authored by SleeplessOne1917's avatar SleeplessOne1917 Committed by GitHub

Chore: Remove redundant intersection type (#52453)

### What?
The type definition of `ImgProps` is the following:
```typescript
export type ImgProps = Omit<ImageProps, 'src' | 'alt' | 'loader'> & {
  loading: LoadingValue
  width: number | undefined
  height: number | undefined
  style: NonNullable<JSX.IntrinsicElements['img']['style']>
  sizes: string | undefined
  srcSet: string | undefined
  src: string
}
```

`ImgProps` is then used as part of the definition of the `ImageElementProps` type. For the latter, `Omit<ImageProps, 'src' | 'alt' | 'loader'>` is intersected with `ImgProps` even though the intersection with that type is already part `ImgProps`'s definition. This PR removes the redundancy.

### Why?
I was looking at how Next.js implemented it's optimized image component to create something similar for a WASM framework when I noticed this typing and got confused. I figured making a PR would be the polite thing to do.

### How?
Removed redundant part of type definition.
parent b4508953
...@@ -44,15 +44,14 @@ type ImgElementWithDataProp = HTMLImageElement & { ...@@ -44,15 +44,14 @@ type ImgElementWithDataProp = HTMLImageElement & {
'data-loaded-src': string | undefined 'data-loaded-src': string | undefined
} }
type ImageElementProps = Omit<ImageProps, 'src' | 'alt' | 'loader'> & type ImageElementProps = ImgProps & {
ImgProps & { unoptimized: boolean
unoptimized: boolean placeholder: PlaceholderValue
placeholder: PlaceholderValue onLoadRef: React.MutableRefObject<OnLoad | undefined>
onLoadRef: React.MutableRefObject<OnLoad | undefined> onLoadingCompleteRef: React.MutableRefObject<OnLoadingComplete | undefined>
onLoadingCompleteRef: React.MutableRefObject<OnLoadingComplete | undefined> setBlurComplete: (b: boolean) => void
setBlurComplete: (b: boolean) => void setShowAltText: (b: boolean) => void
setShowAltText: (b: boolean) => void }
}
// See https://stackoverflow.com/q/39777833/266535 for why we use this ref // See https://stackoverflow.com/q/39777833/266535 for why we use this ref
// handler instead of the img's onLoad attribute. // handler instead of the img's onLoad attribute.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment