55
66// prettier-ignore
77declare module "nextjs-routes" {
8- import type {
9- GetServerSidePropsContext as NextGetServerSidePropsContext ,
10- GetServerSidePropsResult as NextGetServerSidePropsResult
11- } from "nextjs" ;
12-
138 export type Route =
149 | StaticRoute < "/404" >
1510 | StaticRoute < "/account/api-key" >
@@ -112,33 +107,6 @@ declare module "nextjs-routes" {
112107 * route({ pathname: "/foos/[foo]", query: { foo: "bar" }}) will produce "/foos/bar".
113108 */
114109 export declare function route ( r : Route ) : string ;
115-
116- /**
117- * Nearly identical to GetServerSidePropsContext from next, but further narrows
118- * types based on nextjs-route's route data.
119- */
120- export type GetServerSidePropsContext <
121- Pathname extends Route [ "pathname" ] = Route [ "pathname" ] ,
122- Preview extends NextGetServerSidePropsContext [ "previewData" ] = NextGetServerSidePropsContext [ "previewData" ]
123- > = Omit < NextGetServerSidePropsContext , 'params' | 'query' | 'defaultLocale' | 'locale' | 'locales' > & {
124- params : Extract < Route , { pathname : Pathname } > [ "query" ] ;
125- query : Query ;
126- defaultLocale ?: undefined ;
127- locale ?: Locale ;
128- locales ?: undefined ;
129- } ;
130-
131- /**
132- * Nearly identical to GetServerSideProps from next, but further narrows
133- * types based on nextjs-route's route data.
134- */
135- export type GetServerSideProps <
136- Props extends { [ key : string ] : any } = { [ key : string ] : any } ,
137- Pathname extends Route [ "pathname" ] = Route [ "pathname" ] ,
138- Preview extends NextGetServerSideProps [ "previewData" ] = NextGetServerSideProps [ "previewData" ]
139- > = (
140- context : GetServerSidePropsContext < Pathname , Preview >
141- ) => Promise < NextGetServerSidePropsResult < Props > >
142110}
143111
144112// prettier-ignore
@@ -153,12 +121,13 @@ declare module "next/link" {
153121 } from "react" ;
154122 export * from "next/dist/client/link" ;
155123
124+ type Query = { query ?: { [ key : string ] : string | string [ ] | undefined } } ;
156125 type StaticRoute = Exclude < Route , { query : any } > [ "pathname" ] ;
157126
158127 export interface LinkProps
159128 extends Omit < NextLinkProps , "href" | "locale" > ,
160129 AnchorHTMLAttributes < HTMLAnchorElement > {
161- href : Route | StaticRoute | Omit < Route , "pathname" >
130+ href : Route | StaticRoute | Query ;
162131 locale ?: false ;
163132 }
164133
@@ -186,6 +155,7 @@ declare module "next/router" {
186155
187156 type NextTransitionOptions = NonNullable < Parameters < Router [ "push" ] > [ 2 ] > ;
188157 type StaticRoute = Exclude < Route , { query : any } > [ "pathname" ] ;
158+ type Query = { query ?: { [ key : string ] : string | string [ ] | undefined } } ;
189159
190160 interface TransitionOptions extends Omit < NextTransitionOptions , "locale" > {
191161 locale ?: false ;
@@ -207,12 +177,12 @@ declare module "next/router" {
207177 locale ?: Locale ;
208178 locales ?: undefined ;
209179 push (
210- url : Route | StaticRoute | Omit < Route , "pathname" > ,
180+ url : Route | StaticRoute | Query ,
211181 as ?: string ,
212182 options ?: TransitionOptions
213183 ) : Promise < boolean > ;
214184 replace (
215- url : Route | StaticRoute | Omit < Route , "pathname" > ,
185+ url : Route | StaticRoute | Query ,
216186 as ?: string ,
217187 options ?: TransitionOptions
218188 ) : Promise < boolean > ;
0 commit comments