Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: set a better type for the default image loader (#41639)
## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have a helpful link attached, see `contributing.md` ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have a helpful link attached, see `contributing.md` ## Documentation / Examples - [ ] Make sure the linting passes by running `pnpm lint` - [ ] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md) Co-authored-by: Steven <229881+styfle@users.noreply.github.com>
- Loading branch information
1 parent
17a4f6a
commit 8678865
Showing
5 changed files
with
41 additions
and
11 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
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
11 changes: 11 additions & 0 deletions
11
test/integration/next-image-new/typescript/components/image-with-loader.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,11 @@ | ||
import Image from 'next/image' | ||
import type { ImageProps, ImageLoader, ImageLoaderProps } from 'next/image' | ||
|
||
function myLoader({ src, width, quality }: ImageLoaderProps): string { | ||
return `https://example.com/${src}?w=${width}&q=${quality || 75}` | ||
} | ||
const loader: ImageLoader = myLoader | ||
|
||
export function ImageWithLoader(props: Omit<ImageProps, 'loader'>) { | ||
return <Image loader={loader} {...props} /> | ||
} |
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
8678865
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stats from current release
Default Build (Increase detected⚠️ )
General Overall increase⚠️
Client Bundles (main, webpack) Overall increase⚠️
Legacy Client Bundles (polyfills)
Client Pages Overall increase⚠️
Client Build Manifests
Rendered Page Sizes Overall decrease ✓
Edge SSR bundle Size Overall decrease ✓
Middleware size Overall increase⚠️
Diffs
Diff for page.js
Diff for middleware-b..-manifest.js
Diff for middleware-r..-manifest.js
Diff for middleware.js
Diff too large to display
Diff for edge-ssr.js
Diff too large to display
Diff for _buildManifest.js
Diff for _app-HASH.js
Diff for _error-HASH.js
Diff for amp-HASH.js
Diff for css-HASH.js
Diff for dynamic-HASH.js
Diff for edge-ssr-HASH.js
Diff for head-HASH.js
Diff for hooks-HASH.js
Diff for image-HASH.js
Diff too large to display
Diff for index-HASH.js
Diff for link-HASH.js
Diff for routerDirect-HASH.js
Diff for script-HASH.js
Diff for withRouter-HASH.js
Diff for 240-HASH.js
Diff too large to display
Diff for 456.HASH.js
Diff for app-internals-HASH.js
Diff for page-4c12490cfee340ec.js
Diff for page-56479ca3a9a78787.js
Diff for layout-0e1a2..8ddbedde1.js
Diff for layout-48798..abc1dd85a.js
Diff for framework-HASH.js
Diff for main-HASH.js
Diff too large to display
Diff for main-app-HASH.js
Diff too large to display
Diff for webpack-HASH.js
Diff for index.html
Diff for link.html
Diff for withRouter.html