Unverified Commit 5dae98ea authored by Shu Ding's avatar Shu Ding Committed by GitHub

Add more JSDoc to types (#46897)

Fixes NEXT-540.
parent 422b3b01
......@@ -144,6 +144,10 @@ export interface ExperimentalConfig {
nextScriptWorkers?: boolean
scrollRestoration?: boolean
externalDir?: boolean
/**
* The App Router (app directory) enables support for layouts, Server Components, streaming, and colocated data fetching.
* @see https://beta.nextjs.org/docs/api-reference/next.config.js#appdir
*/
appDir?: boolean
amp?: {
optimizer?: any
......@@ -184,7 +188,10 @@ export interface ExperimentalConfig {
adjustFontFallbacks?: boolean
adjustFontFallbacksWithSizeAdjust?: boolean
// A list of packages that should be treated as external in the RSC server build
/**
* A list of packages that should be treated as external in the RSC server build.
* @see https://beta.nextjs.org/docs/api-reference/next.config.js#servercomponentsexternalpackages
*/
serverComponentsExternalPackages?: string[]
fontLoaders?: Array<{ loader: string; options?: any }>
......@@ -209,10 +216,18 @@ export interface ExperimentalConfig {
/** in `MB` */
memoryLimit?: number
}
/**
* For use with `@next/mdx`. Compile MDX files using the new Rust compiler.
* @see https://beta.nextjs.org/docs/api-reference/next.config.js#mdxrs
*/
mdxRs?: boolean
// Generate Route types and enable type checking for Link and Router.push, etc.
// This option requires `appDir` to be enabled first.
/**
* Generate Route types and enable type checking for Link and Router.push, etc.
* This option requires `appDir` to be enabled first.
* @see https://beta.nextjs.org/docs/api-reference/next.config.js#typedroutes
*/
typedRoutes?: boolean
/**
......@@ -554,7 +569,11 @@ export interface NextConfig extends Record<string, any> {
*/
output?: 'standalone' | 'export'
// A list of packages that should always be transpiled and bundled in the server
/**
* Automatically transpile and bundle dependencies from local packages (like monorepos) or from external dependencies (`node_modules`). This replaces the
* `next-transpile-modules` package.
* @see [transpilePackages](https://beta.nextjs.org/docs/api-reference/next.config.js#transpilepackages)
*/
transpilePackages?: string[]
skipMiddlewareUrlNormalize?: boolean
......
......@@ -138,6 +138,10 @@ export {
export type PreviewData = string | false | object | undefined
/**
* Context object passed into `getStaticProps`.
* @link https://nextjs.org/docs/api-reference/data-fetching/get-static-props#context-parameter
*/
export type GetStaticPropsContext<
Params extends ParsedUrlQuery = ParsedUrlQuery,
Preview extends PreviewData = PreviewData
......@@ -150,11 +154,26 @@ export type GetStaticPropsContext<
defaultLocale?: string
}
/**
* The return type of `getStaticProps`.
* @link https://nextjs.org/docs/api-reference/data-fetching/get-static-props#getstaticprops-return-values
*/
export type GetStaticPropsResult<Props> =
| { props: Props; revalidate?: number | boolean }
| { redirect: Redirect; revalidate?: number | boolean }
| { notFound: true; revalidate?: number | boolean }
/**
* Static Site Generation feature for Next.js.
* @link https://nextjs.org/docs/basic-features/data-fetching/get-static-props
* @link https://nextjs.org/docs/basic-features/typescript#static-generation-and-server-side-rendering
* @example
* ```ts
* export const getStaticProps: GetStaticProps = async (context) => {
* // ...
* }
* ```
*/
export type GetStaticProps<
Props extends { [key: string]: any } = { [key: string]: any },
Params extends ParsedUrlQuery = ParsedUrlQuery,
......@@ -173,6 +192,10 @@ export type GetStaticPathsContext = {
defaultLocale?: string
}
/**
* The return type of `getStaticPaths`.
* @link https://nextjs.org/docs/api-reference/data-fetching/get-static-paths#getstaticpaths-return-values
*/
export type GetStaticPathsResult<
Params extends ParsedUrlQuery = ParsedUrlQuery
> = {
......@@ -180,10 +203,25 @@ export type GetStaticPathsResult<
fallback: boolean | 'blocking'
}
/**
* Define a list of paths to be statically generated if dynamic routes exist.
* @link https://nextjs.org/docs/basic-features/data-fetching/get-static-paths
* @link https://nextjs.org/docs/basic-features/typescript#static-generation-and-server-side-rendering
* @example
* ```ts
* export const getStaticPaths: GetStaticPaths = async () => {
* // ...
* }
* ```
*/
export type GetStaticPaths<Params extends ParsedUrlQuery = ParsedUrlQuery> = (
context: GetStaticPathsContext
) => Promise<GetStaticPathsResult<Params>> | GetStaticPathsResult<Params>
/**
* Context object passed into `getServerSideProps`.
* @link https://nextjs.org/docs/api-reference/data-fetching/get-server-side-props#context-parameter
*/
export type GetServerSidePropsContext<
Params extends ParsedUrlQuery = ParsedUrlQuery,
Preview extends PreviewData = PreviewData
......@@ -202,11 +240,25 @@ export type GetServerSidePropsContext<
defaultLocale?: string
}
/**
* The return type of `getServerSideProps`.
* @link https://nextjs.org/docs/api-reference/data-fetching/get-server-side-props#getserversideprops-return-values
*/
export type GetServerSidePropsResult<Props> =
| { props: Props | Promise<Props> }
| { redirect: Redirect }
| { notFound: true }
/**
* Server-side Rendering feature for Next.js.
* @link https://nextjs.org/docs/basic-features/data-fetching/get-server-side-props
* @link https://nextjs.org/docs/basic-features/typescript#static-generation-and-server-side-rendering
* @example
* ```ts
* export const getServerSideProps: GetServerSideProps = async (context) => {
* // ...
* }
*/
export type GetServerSideProps<
Props extends { [key: string]: any } = { [key: string]: any },
Params extends ParsedUrlQuery = ParsedUrlQuery,
......
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