Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
### Description This changes the strict TS types to a looser implementation such that the user can pass `src` without TS errors. ### Pros vs Cons - **Pros**: better support for wrapping `next/image` so that TS won't report false errors - **Cons**: using `src: string` without `blurDataURL` will no longer show TS errors and instead fail with a runtime error ### Issues - Fixes #26892 - Related to #26991
- Loading branch information
Showing
5 changed files
with
47 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
test/integration/image-component/typescript/components/image-dynamic-src.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import React from 'react' | ||
import Image, { ImageProps } from 'next/image' | ||
|
||
type DynamicSrcImageProps = ImageProps & { | ||
id: string | ||
srcString?: string | ||
} | ||
|
||
export function DynamicSrcImage({ | ||
srcString, | ||
src, | ||
...props | ||
}: DynamicSrcImageProps) { | ||
const newSrc = srcString || src | ||
return <Image {...props} src={newSrc} /> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters