Skip to content

Commit 929a74e

Browse files
committed
fix Params and SearchParams types being broken
well, they weren't technically broken but in Promise form they weren't useful. Signed-off-by: Vu Van Dung <[email protected]>
1 parent a1d4048 commit 929a74e

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

packages/nextjs-route-types/src/get-file-content.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export const getFileContent: GetFileContent = (path, children) => {
4646
const parallelRoutes = getParallelRoutesFromChildren(children);
4747
const layoutPropsTsInterfaceContent = parallelRoutes
4848
.map(route => ` "${route}": ReactNode`)
49-
.concat(" params: Params")
49+
.concat(" params: Promise<Params>")
5050
.join(";\n")
5151
.trim();
5252
return `
@@ -55,11 +55,11 @@ import type { ReactNode } from "react";
5555
5656
type EmptyObject = Record<string, never>;
5757
58-
export type SearchParams = Promise<Record<string, string | string[] | undefined>>;
59-
export type Params = Promise<${params.length ? `{\n ${paramsTsInterfaceContent};\n}` : "EmptyObject"}>;
58+
export type SearchParams = Record<string, string | string[] | undefined>;
59+
export type Params = ${params.length ? `{\n ${paramsTsInterfaceContent};\n}` : "EmptyObject"};
6060
6161
export type DefaultProps = {
62-
params: Params;
62+
params: Promise<Params>;
6363
};
6464
export type ErrorProps = {
6565
error: Error & { digest?: string };
@@ -69,13 +69,13 @@ export type LayoutProps = {\n ${layoutPropsTsInterfaceContent};\n};
6969
export type LoadingProps = EmptyObject;
7070
export type NotFoundProps = EmptyObject;
7171
export type PageProps = {
72-
params: Params;
73-
searchParams: SearchParams;
72+
params: Promise<Params>;
73+
searchParams: Promise<SearchParams>;
7474
};
7575
export type TemplateProps = LayoutProps;
7676
7777
export type RouteHandlerContext = {
78-
params: Params;
78+
params: Promise<Params>;
7979
};
8080
type HandlerReturn = Response | Promise<Response>;
8181
export type RouteHandler = (request: NextRequest, context: RouteHandlerContext) => HandlerReturn;

0 commit comments

Comments
 (0)