New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve types for <Image />
and responseLimit
#40863
Changes from 4 commits
9002c1d
41bf5b3
2b48831
f73ba5a
8400ca9
f496180
563c4db
e35879d
1565b04
f79a201
e0f7813
1d26e99
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,6 +61,22 @@ export type Redirect = | |
*/ | ||
export type NextPage<P = {}, IP = P> = NextComponentType<NextPageContext, IP, P> | ||
|
||
export type FileSizeSuffix = `${ | ||
| 'k' | ||
| 'K' | ||
| 'm' | ||
| 'M' | ||
| 'g' | ||
| 'G' | ||
| 't' | ||
| 'T' | ||
| 'p' | ||
| 'P'}${'b' | 'B'}` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems to restrictive because it doesnt work with
Lets add tests for this to ensure all cases are covered There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
export type SizeLimit = number | `${number}${FileSizeSuffix}` | ||
|
||
export type ResponseLimit = SizeLimit | boolean | ||
|
||
/** | ||
* `Config` type, use it for export const config | ||
*/ | ||
|
@@ -72,12 +88,16 @@ export type PageConfig = { | |
* any string format supported by `bytes`, for example `1000`, `'500kb'` or | ||
* `'3mb'`. | ||
*/ | ||
responseLimit?: number | string | boolean | ||
responseLimit?: ResponseLimit | ||
/** | ||
* The byte limit of the body. This is the number of bytes or any string | ||
* format supported by `bytes`, for example `1000`, `'500kb'` or `'3mb'`. | ||
*/ | ||
bodyParser?: { sizeLimit?: number | string } | false | ||
bodyParser?: | ||
| { | ||
sizeLimit?: SizeLimit | ||
} | ||
| false | ||
/** | ||
* Flag to disable warning "API page resolved | ||
* without sending a response", due to explicitly | ||
|
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.
The changes to
next/image
andnext/future/image
look good. Feel free to move that in a separate PR so we can merge it in.Also add a test to invalid.tsx and valid.tsx fixture here: https://github.com/vercel/next.js/tree/canary/test/integration/image-future/typescript/pages
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.
Cheers, have added some tests there!