Skip to content

Commit f5e2338

Browse files
committed
chore(deps): update nextjs-routes
1 parent 86a55f2 commit f5e2338

File tree

3 files changed

+63
-16
lines changed

3 files changed

+63
-16
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
"nanoid": "4.0.2",
8585
"next": "13.2.4",
8686
"next-http-proxy-middleware": "1.2.5",
87-
"nextjs-routes": "1.0.9",
87+
"nextjs-routes": "2.0.0",
8888
"node-fetch": "3.3.1",
8989
"notistack": "2.0.8",
9090
"plotly.js-basic-dist": "2.20.0",

pnpm-lock.yaml

Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

types/nextjs-routes.d.ts

Lines changed: 57 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
// THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
22
// This file will be automatically regenerated when your Next.js server is running.
3-
// nextjs-routes version: 1.0.8
3+
// nextjs-routes version: 2.0.0
44
/* eslint-disable */
55

66
// prettier-ignore
77
declare module "nextjs-routes" {
8+
import type {
9+
GetServerSidePropsContext as NextGetServerSidePropsContext,
10+
GetServerSidePropsResult as NextGetServerSidePropsResult
11+
} from "nextjs";
12+
813
export type Route =
914
| DynamicRoute<"/api/as-api/[...asProxy]", { "asProxy": string[] }>
1015
| DynamicRoute<"/api/auth/[...auth0]", { "auth0": string[] }>
@@ -67,6 +72,33 @@ declare module "nextjs-routes" {
6772
* route({ pathname: "/foos/[foo]", query: { foo: "bar" }}) will produce "/foos/bar".
6873
*/
6974
export declare function route(r: Route): string;
75+
76+
/**
77+
* Nearly identical to GetServerSidePropsContext from next, but further narrows
78+
* types based on nextjs-route's route data.
79+
*/
80+
export type GetServerSidePropsContext<
81+
Pathname extends Route["pathname"] = Route["pathname"],
82+
Preview extends NextGetServerSidePropsContext["previewData"] = NextGetServerSidePropsContext["previewData"]
83+
> = Omit<NextGetServerSidePropsContext, 'params' | 'query' | 'defaultLocale' | 'locale' | 'locales'> & {
84+
params: Extract<Route, { pathname: Pathname }>["query"];
85+
query: Query;
86+
defaultLocale?: undefined;
87+
locale?: Locale;
88+
locales?: undefined;
89+
};
90+
91+
/**
92+
* Nearly identical to GetServerSideProps from next, but further narrows
93+
* types based on nextjs-route's route data.
94+
*/
95+
export type GetServerSideProps<
96+
Props extends { [key: string]: any } = { [key: string]: any },
97+
Pathname extends Route["pathname"] = Route["pathname"],
98+
Preview extends NextGetServerSideProps["previewData"] = NextGetServerSideProps["previewData"]
99+
> = (
100+
context: GetServerSidePropsContext<Pathname, Preview>
101+
) => Promise<NextGetServerSidePropsResult<Props>>
70102
}
71103

72104
// prettier-ignore
@@ -81,13 +113,12 @@ declare module "next/link" {
81113
} from "react";
82114
export * from "next/dist/client/link";
83115

84-
type Query = { query?: { [key: string]: string | string[] | undefined } };
85116
type StaticRoute = Exclude<Route, { query: any }>["pathname"];
86117

87118
export interface LinkProps
88119
extends Omit<NextLinkProps, "href" | "locale">,
89120
AnchorHTMLAttributes<HTMLAnchorElement> {
90-
href: Route | StaticRoute | Query;
121+
href: Route | StaticRoute | Omit<Route, "pathname">
91122
locale?: false;
92123
}
93124

@@ -115,34 +146,49 @@ declare module "next/router" {
115146

116147
type NextTransitionOptions = NonNullable<Parameters<Router["push"]>[2]>;
117148
type StaticRoute = Exclude<Route, { query: any }>["pathname"];
118-
type Query = { query?: { [key: string]: string | string[] | undefined } };
119149

120150
interface TransitionOptions extends Omit<NextTransitionOptions, "locale"> {
121151
locale?: false;
122152
}
123153

154+
type PathnameAndQuery<Pathname> = Required<
155+
Pick<Extract<Route, { pathname: Pathname }>, "pathname" | "query">
156+
>;
157+
158+
type AutomaticStaticOptimizedQuery<PaQ> = Omit<PaQ, "query"> & {
159+
query: Partial<PaQ["query"]>;
160+
};
161+
162+
type BaseRouter<PaQ> =
163+
| ({ isReady: false } & AutomaticStaticOptimizedQuery<PaQ>)
164+
| ({ isReady: true } & PaQ);
165+
124166
export type NextRouter<P extends Route["pathname"] = Route["pathname"]> =
125-
Extract<Route, { pathname: P }> &
167+
BaseRouter<PathnameAndQuery<P>> &
126168
Omit<
127169
Router,
128-
| "push"
129-
| "replace"
130-
| "locale"
131-
| "locales"
132170
| "defaultLocale"
133171
| "domainLocales"
172+
| "isReady"
173+
| "locale"
174+
| "locales"
175+
| "pathname"
176+
| "push"
177+
| "query"
178+
| "replace"
179+
| "route"
134180
> & {
135181
defaultLocale?: undefined;
136182
domainLocales?: undefined;
137183
locale?: Locale;
138184
locales?: undefined;
139185
push(
140-
url: Route | StaticRoute | Query,
186+
url: Route | StaticRoute | Omit<Route, "pathname">,
141187
as?: string,
142188
options?: TransitionOptions
143189
): Promise<boolean>;
144190
replace(
145-
url: Route | StaticRoute | Query,
191+
url: Route | StaticRoute | Omit<Route, "pathname">,
146192
as?: string,
147193
options?: TransitionOptions
148194
): Promise<boolean>;

0 commit comments

Comments
 (0)