Repository: tatethurston/nextjs-routes
Pull request #107 (2022-11-25 19:58:17)

switch from function overloading to unions
function overloading resulted in errors that were more difficult for users to understand


Patch:
diff --git a/examples/intl/nextjs-routes.d.ts b/examples/intl/nextjs-routes.d.ts
index ae34b94..914937f 100644
--- a/examples/intl/nextjs-routes.d.ts
+++ b/examples/intl/nextjs-routes.d.ts
@@ -57,12 +57,10 @@ declare module "next/link" {
   type Query = { query?: { [key: string]: string | string[] | undefined } };
   type StaticRoute = Exclude<Route, { query: any }>["pathname"];
 
-  export interface LinkProps<
-    Href extends Route | StaticRoute | Query = Route | StaticRoute | Query
-  >
+  export interface LinkProps
     extends Omit<NextLinkProps, "href" | "locale">,
       AnchorHTMLAttributes<HTMLAnchorElement> {
-    href: Href;
+    href: Route | StaticRoute | Query;
     locale?: Locale | false;
   }
 
@@ -76,15 +74,7 @@ declare module "next/link" {
     HTMLElement
   >;
 
-  declare function Link(
-    props: PropsWithChildren<LinkProps<Route>>
-  ): LinkReactElement;
-  declare function Link(
-    props: PropsWithChildren<LinkProps<StaticRoute>>
-  ): LinkReactElement;
-  declare function Link(
-    props: PropsWithChildren<LinkProps<Query>>
-  ): LinkReactElement;
+  declare function Link(props: PropsWithChildren<LinkProps>): LinkReactElement;
 
   export default Link;
 }
@@ -98,6 +88,7 @@ declare module "next/router" {
 
   type NextTransitionOptions = NonNullable<Parameters<Router["push"]>[2]>;
   type StaticRoute = Exclude<Route, { query: any }>["pathname"];
+  type Query = { query?: { [key: string]: string | string[] | undefined } };
 
   interface TransitionOptions extends Omit<NextTransitionOptions, "locale"> {
     locale?: Locale | false;
@@ -123,32 +114,12 @@ declare module "next/router" {
           "nl-NL"
         ];
         push(
-          url: Route,
-          as?: string,
-          options?: TransitionOptions
-        ): Promise<boolean>;
-        push(
-          url: StaticRoute,
-          as?: string,
-          options?: TransitionOptions
-        ): Promise<boolean>;
-        push(
-          url: { query?: { [key: string]: string | string[] | undefined } },
-          as?: string,
-          options?: TransitionOptions
-        ): Promise<boolean>;
-        replace(
-          url: Route,
-          as?: string,
-          options?: TransitionOptions
-        ): Promise<boolean>;
-        replace(
-          url: StaticRoute,
+          url: Route | StaticRoute | Query,
           as?: string,
           options?: TransitionOptions
         ): Promise<boolean>;
         replace(
-          url: { query?: { [key: string]: string | string[] | undefined } },
+          url: Route | StaticRoute | Query,
           as?: string,
           options?: TransitionOptions
         ): Promise<boolean>;
diff --git a/examples/typescript/types/nextjs-routes.d.ts b/examples/typescript/types/nextjs-routes.d.ts
index 57ff7a1..89d976d 100644
--- a/examples/typescript/types/nextjs-routes.d.ts
+++ b/examples/typescript/types/nextjs-routes.d.ts
@@ -56,12 +56,10 @@ declare module "next/link" {
   type Query = { query?: { [key: string]: string | string[] | undefined } };
   type StaticRoute = Exclude<Route, { query: any }>["pathname"];
 
-  export interface LinkProps<
-    Href extends Route | StaticRoute | Query = Route | StaticRoute | Query
-  >
+  export interface LinkProps
     extends Omit<NextLinkProps, "href" | "locale">,
       AnchorHTMLAttributes<HTMLAnchorElement> {
-    href: Href;
+    href: Route | StaticRoute | Query;
     locale?: false;
   }
 
@@ -75,15 +73,7 @@ declare module "next/link" {
     HTMLElement
   >;
 
-  declare function Link(
-    props: PropsWithChildren<LinkProps<Route>>
-  ): LinkReactElement;
-  declare function Link(
-    props: PropsWithChildren<LinkProps<StaticRoute>>
-  ): LinkReactElement;
-  declare function Link(
-    props: PropsWithChildren<LinkProps<Query>>
-  ): LinkReactElement;
+  declare function Link(props: PropsWithChildren<LinkProps>): LinkReactElement;
 
   export default Link;
 }
@@ -97,6 +87,7 @@ declare module "next/router" {
 
   type NextTransitionOptions = NonNullable<Parameters<Router["push"]>[2]>;
   type StaticRoute = Exclude<Route, { query: any }>["pathname"];
+  type Query = { query?: { [key: string]: string | string[] | undefined } };
 
   interface TransitionOptions extends Omit<NextTransitionOptions, "locale"> {
     locale?: false;
@@ -118,32 +109,12 @@ declare module "next/router" {
         locale?: Locale;
         locales?: undefined;
         push(
-          url: Route,
-          as?: string,
-          options?: TransitionOptions
-        ): Promise<boolean>;
-        push(
-          url: StaticRoute,
-          as?: string,
-          options?: TransitionOptions
-        ): Promise<boolean>;
-        push(
-          url: { query?: { [key: string]: string | string[] | undefined } },
-          as?: string,
-          options?: TransitionOptions
-        ): Promise<boolean>;
-        replace(
-          url: Route,
-          as?: string,
-          options?: TransitionOptions
-        ): Promise<boolean>;
-        replace(
-          url: StaticRoute,
+          url: Route | StaticRoute | Query,
           as?: string,
           options?: TransitionOptions
         ): Promise<boolean>;
         replace(
-          url: { query?: { [key: string]: string | string[] | undefined } },
+          url: Route | StaticRoute | Query,
           as?: string,
           options?: TransitionOptions
         ): Promise<boolean>;
diff --git a/src/core.ts b/src/core.ts
index d4cbef4..a4a7381 100644
--- a/src/core.ts
+++ b/src/core.ts
@@ -149,12 +149,10 @@ declare module "next/link" {
   type Query = { query?: { [key: string]: string | string[] | undefined } };
   type StaticRoute = Exclude<Route, { query: any }>["pathname"];
 
-  export interface LinkProps<
-    Href extends Route | StaticRoute | Query = Route | StaticRoute | Query
-  >
+  export interface LinkProps
     extends Omit<NextLinkProps, "href" | "locale">,
       AnchorHTMLAttributes<HTMLAnchorElement> {
-    href: Href;
+    href: Route | StaticRoute | Query;
     locale?: ${!i18n.locales.length ? "false" : `Locale | false`};
   }
 
@@ -168,15 +166,7 @@ declare module "next/link" {
     HTMLElement
   >;
 
-  declare function Link(
-    props: PropsWithChildren<LinkProps<Route>>
-  ): LinkReactElement;
-  declare function Link(
-    props: PropsWithChildren<LinkProps<StaticRoute>>
-  ): LinkReactElement;
-  declare function Link(
-    props: PropsWithChildren<LinkProps<Query>>
-  ): LinkReactElement;
+  declare function Link(props: PropsWithChildren<LinkProps>): LinkReactElement;
 
   export default Link;
 }
@@ -190,6 +180,7 @@ declare module "next/router" {
 
   type NextTransitionOptions = NonNullable<Parameters<Router["push"]>[2]>;
   type StaticRoute = Exclude<Route, { query: any }>["pathname"];
+  type Query = { query?: { [key: string]: string | string[] | undefined } };
 
   interface TransitionOptions extends Omit<NextTransitionOptions, "locale"> {
     locale?: ${!i18n.locales.length ? "false" : `Locale | false`};
@@ -217,32 +208,12 @@ declare module "next/router" {
           i18n.locales.length ? `: ${print(i18n.locales, 8)}` : "?: undefined"
         };
         push(
-          url: Route,
-          as?: string,
-          options?: TransitionOptions
-        ): Promise<boolean>;
-        push(
-          url: StaticRoute,
-          as?: string,
-          options?: TransitionOptions
-        ): Promise<boolean>;
-        push(
-          url: { query?: { [key: string]: string | string[] | undefined } },
-          as?: string,
-          options?: TransitionOptions
-        ): Promise<boolean>;
-        replace(
-          url: Route,
-          as?: string,
-          options?: TransitionOptions
-        ): Promise<boolean>;
-        replace(
-          url: StaticRoute,
+          url: Route | StaticRoute | Query,
           as?: string,
           options?: TransitionOptions
         ): Promise<boolean>;
         replace(
-          url: { query?: { [key: string]: string | string[] | undefined } },
+          url: Route | StaticRoute | Query,
           as?: string,
           options?: TransitionOptions
         ): Promise<boolean>;


Test patch:
diff --git a/e2e/nextjs-routes.d.ts b/e2e/nextjs-routes.d.ts
index c0c9466..e1e634b 100644
--- a/e2e/nextjs-routes.d.ts
+++ b/e2e/nextjs-routes.d.ts
@@ -55,12 +55,10 @@ declare module "next/link" {
   type Query = { query?: { [key: string]: string | string[] | undefined } };
   type StaticRoute = Exclude<Route, { query: any }>["pathname"];
 
-  export interface LinkProps<
-    Href extends Route | StaticRoute | Query = Route | StaticRoute | Query
-  >
+  export interface LinkProps
     extends Omit<NextLinkProps, "href" | "locale">,
       AnchorHTMLAttributes<HTMLAnchorElement> {
-    href: Href;
+    href: Route | StaticRoute | Query;
     locale?: false;
   }
 
@@ -74,15 +72,7 @@ declare module "next/link" {
     HTMLElement
   >;
 
-  declare function Link(
-    props: PropsWithChildren<LinkProps<Route>>
-  ): LinkReactElement;
-  declare function Link(
-    props: PropsWithChildren<LinkProps<StaticRoute>>
-  ): LinkReactElement;
-  declare function Link(
-    props: PropsWithChildren<LinkProps<Query>>
-  ): LinkReactElement;
+  declare function Link(props: PropsWithChildren<LinkProps>): LinkReactElement;
 
   export default Link;
 }
@@ -96,6 +86,7 @@ declare module "next/router" {
 
   type NextTransitionOptions = NonNullable<Parameters<Router["push"]>[2]>;
   type StaticRoute = Exclude<Route, { query: any }>["pathname"];
+  type Query = { query?: { [key: string]: string | string[] | undefined } };
 
   interface TransitionOptions extends Omit<NextTransitionOptions, "locale"> {
     locale?: false;
@@ -117,32 +108,12 @@ declare module "next/router" {
         locale?: Locale;
         locales?: undefined;
         push(
-          url: Route,
-          as?: string,
-          options?: TransitionOptions
-        ): Promise<boolean>;
-        push(
-          url: StaticRoute,
-          as?: string,
-          options?: TransitionOptions
-        ): Promise<boolean>;
-        push(
-          url: { query?: { [key: string]: string | string[] | undefined } },
-          as?: string,
-          options?: TransitionOptions
-        ): Promise<boolean>;
-        replace(
-          url: Route,
-          as?: string,
-          options?: TransitionOptions
-        ): Promise<boolean>;
-        replace(
-          url: StaticRoute,
+          url: Route | StaticRoute | Query,
           as?: string,
           options?: TransitionOptions
         ): Promise<boolean>;
         replace(
-          url: { query?: { [key: string]: string | string[] | undefined } },
+          url: Route | StaticRoute | Query,
           as?: string,
           options?: TransitionOptions
         ): Promise<boolean>;
diff --git a/src/__snapshots__/core.test.ts.snap b/src/__snapshots__/core.test.ts.snap
index 9121195..15ba31a 100644
--- a/src/__snapshots__/core.test.ts.snap
+++ b/src/__snapshots__/core.test.ts.snap
@@ -60,12 +60,10 @@ declare module "next/link" {
   type Query = { query?: { [key: string]: string | string[] | undefined } };
   type StaticRoute = Exclude<Route, { query: any }>["pathname"];
 
-  export interface LinkProps<
-    Href extends Route | StaticRoute | Query = Route | StaticRoute | Query
-  >
+  export interface LinkProps
     extends Omit<NextLinkProps, "href" | "locale">,
       AnchorHTMLAttributes<HTMLAnchorElement> {
-    href: Href;
+    href: Route | StaticRoute | Query;
     locale?: false;
   }
 
@@ -79,15 +77,7 @@ declare module "next/link" {
     HTMLElement
   >;
 
-  declare function Link(
-    props: PropsWithChildren<LinkProps<Route>>
-  ): LinkReactElement;
-  declare function Link(
-    props: PropsWithChildren<LinkProps<StaticRoute>>
-  ): LinkReactElement;
-  declare function Link(
-    props: PropsWithChildren<LinkProps<Query>>
-  ): LinkReactElement;
+  declare function Link(props: PropsWithChildren<LinkProps>): LinkReactElement;
 
   export default Link;
 }
@@ -101,6 +91,7 @@ declare module "next/router" {
 
   type NextTransitionOptions = NonNullable<Parameters<Router["push"]>[2]>;
   type StaticRoute = Exclude<Route, { query: any }>["pathname"];
+  type Query = { query?: { [key: string]: string | string[] | undefined } };
 
   interface TransitionOptions extends Omit<NextTransitionOptions, "locale"> {
     locale?: false;
@@ -122,32 +113,12 @@ declare module "next/router" {
         locale?: Locale;
         locales?: undefined;
         push(
-          url: Route,
-          as?: string,
-          options?: TransitionOptions
-        ): Promise<boolean>;
-        push(
-          url: StaticRoute,
-          as?: string,
-          options?: TransitionOptions
-        ): Promise<boolean>;
-        push(
-          url: { query?: { [key: string]: string | string[] | undefined } },
-          as?: string,
-          options?: TransitionOptions
-        ): Promise<boolean>;
-        replace(
-          url: Route,
-          as?: string,
-          options?: TransitionOptions
-        ): Promise<boolean>;
-        replace(
-          url: StaticRoute,
+          url: Route | StaticRoute | Query,
           as?: string,
           options?: TransitionOptions
         ): Promise<boolean>;
         replace(
-          url: { query?: { [key: string]: string | string[] | undefined } },
+          url: Route | StaticRoute | Query,
           as?: string,
           options?: TransitionOptions
         ): Promise<boolean>;
@@ -223,12 +194,10 @@ declare module "next/link" {
   type Query = { query?: { [key: string]: string | string[] | undefined } };
   type StaticRoute = Exclude<Route, { query: any }>["pathname"];
 
-  export interface LinkProps<
-    Href extends Route | StaticRoute | Query = Route | StaticRoute | Query
-  >
+  export interface LinkProps
     extends Omit<NextLinkProps, "href" | "locale">,
       AnchorHTMLAttributes<HTMLAnchorElement> {
-    href: Href;
+    href: Route | StaticRoute | Query;
     locale?: Locale | false;
   }
 
@@ -242,15 +211,7 @@ declare module "next/link" {
     HTMLElement
   >;
 
-  declare function Link(
-    props: PropsWithChildren<LinkProps<Route>>
-  ): LinkReactElement;
-  declare function Link(
-    props: PropsWithChildren<LinkProps<StaticRoute>>
-  ): LinkReactElement;
-  declare function Link(
-    props: PropsWithChildren<LinkProps<Query>>
-  ): LinkReactElement;
+  declare function Link(props: PropsWithChildren<LinkProps>): LinkReactElement;
 
   export default Link;
 }
@@ -264,6 +225,7 @@ declare module "next/router" {
 
   type NextTransitionOptions = NonNullable<Parameters<Router["push"]>[2]>;
   type StaticRoute = Exclude<Route, { query: any }>["pathname"];
+  type Query = { query?: { [key: string]: string | string[] | undefined } };
 
   interface TransitionOptions extends Omit<NextTransitionOptions, "locale"> {
     locale?: Locale | false;
@@ -302,32 +264,12 @@ declare module "next/router" {
           "nl-NL"
         ];
         push(
-          url: Route,
-          as?: string,
-          options?: TransitionOptions
-        ): Promise<boolean>;
-        push(
-          url: StaticRoute,
-          as?: string,
-          options?: TransitionOptions
-        ): Promise<boolean>;
-        push(
-          url: { query?: { [key: string]: string | string[] | undefined } },
-          as?: string,
-          options?: TransitionOptions
-        ): Promise<boolean>;
-        replace(
-          url: Route,
+          url: Route | StaticRoute | Query,
           as?: string,
           options?: TransitionOptions
         ): Promise<boolean>;
         replace(
-          url: StaticRoute,
-          as?: string,
-          options?: TransitionOptions
-        ): Promise<boolean>;
-        replace(
-          url: { query?: { [key: string]: string | string[] | undefined } },
+          url: Route | StaticRoute | Query,
           as?: string,
           options?: TransitionOptions
         ): Promise<boolean>;
@@ -400,12 +342,10 @@ declare module "next/link" {
   type Query = { query?: { [key: string]: string | string[] | undefined } };
   type StaticRoute = Exclude<Route, { query: any }>["pathname"];
 
-  export interface LinkProps<
-    Href extends Route | StaticRoute | Query = Route | StaticRoute | Query
-  >
+  export interface LinkProps
     extends Omit<NextLinkProps, "href" | "locale">,
       AnchorHTMLAttributes<HTMLAnchorElement> {
-    href: Href;
+    href: Route | StaticRoute | Query;
     locale?: false;
   }
 
@@ -419,15 +359,7 @@ declare module "next/link" {
     HTMLElement
   >;
 
-  declare function Link(
-    props: PropsWithChildren<LinkProps<Route>>
-  ): LinkReactElement;
-  declare function Link(
-    props: PropsWithChildren<LinkProps<StaticRoute>>
-  ): LinkReactElement;
-  declare function Link(
-    props: PropsWithChildren<LinkProps<Query>>
-  ): LinkReactElement;
+  declare function Link(props: PropsWithChildren<LinkProps>): LinkReactElement;
 
   export default Link;
 }
@@ -441,6 +373,7 @@ declare module "next/router" {
 
   type NextTransitionOptions = NonNullable<Parameters<Router["push"]>[2]>;
   type StaticRoute = Exclude<Route, { query: any }>["pathname"];
+  type Query = { query?: { [key: string]: string | string[] | undefined } };
 
   interface TransitionOptions extends Omit<NextTransitionOptions, "locale"> {
     locale?: false;
@@ -462,32 +395,12 @@ declare module "next/router" {
         locale?: Locale;
         locales?: undefined;
         push(
-          url: Route,
-          as?: string,
-          options?: TransitionOptions
-        ): Promise<boolean>;
-        push(
-          url: StaticRoute,
-          as?: string,
-          options?: TransitionOptions
-        ): Promise<boolean>;
-        push(
-          url: { query?: { [key: string]: string | string[] | undefined } },
-          as?: string,
-          options?: TransitionOptions
-        ): Promise<boolean>;
-        replace(
-          url: Route,
+          url: Route | StaticRoute | Query,
           as?: string,
           options?: TransitionOptions
         ): Promise<boolean>;
         replace(
-          url: StaticRoute,
-          as?: string,
-          options?: TransitionOptions
-        ): Promise<boolean>;
-        replace(
-          url: { query?: { [key: string]: string | string[] | undefined } },
+          url: Route | StaticRoute | Query,
           as?: string,
           options?: TransitionOptions
         ): Promise<boolean>;
@@ -562,12 +475,10 @@ declare module "next/link" {
   type Query = { query?: { [key: string]: string | string[] | undefined } };
   type StaticRoute = Exclude<Route, { query: any }>["pathname"];
 
-  export interface LinkProps<
-    Href extends Route | StaticRoute | Query = Route | StaticRoute | Query
-  >
+  export interface LinkProps
     extends Omit<NextLinkProps, "href" | "locale">,
       AnchorHTMLAttributes<HTMLAnchorElement> {
-    href: Href;
+    href: Route | StaticRoute | Query;
     locale?: false;
   }
 
@@ -581,15 +492,7 @@ declare module "next/link" {
     HTMLElement
   >;
 
-  declare function Link(
-    props: PropsWithChildren<LinkProps<Route>>
-  ): LinkReactElement;
-  declare function Link(
-    props: PropsWithChildren<LinkProps<StaticRoute>>
-  ): LinkReactElement;
-  declare function Link(
-    props: PropsWithChildren<LinkProps<Query>>
-  ): LinkReactElement;
+  declare function Link(props: PropsWithChildren<LinkProps>): LinkReactElement;
 
   export default Link;
 }
@@ -603,6 +506,7 @@ declare module "next/router" {
 
   type NextTransitionOptions = NonNullable<Parameters<Router["push"]>[2]>;
   type StaticRoute = Exclude<Route, { query: any }>["pathname"];
+  type Query = { query?: { [key: string]: string | string[] | undefined } };
 
   interface TransitionOptions extends Omit<NextTransitionOptions, "locale"> {
     locale?: false;
@@ -624,32 +528,12 @@ declare module "next/router" {
         locale?: Locale;
         locales?: undefined;
         push(
-          url: Route,
-          as?: string,
-          options?: TransitionOptions
-        ): Promise<boolean>;
-        push(
-          url: StaticRoute,
-          as?: string,
-          options?: TransitionOptions
-        ): Promise<boolean>;
-        push(
-          url: { query?: { [key: string]: string | string[] | undefined } },
-          as?: string,
-          options?: TransitionOptions
-        ): Promise<boolean>;
-        replace(
-          url: Route,
-          as?: string,
-          options?: TransitionOptions
-        ): Promise<boolean>;
-        replace(
-          url: StaticRoute,
+          url: Route | StaticRoute | Query,
           as?: string,
           options?: TransitionOptions
         ): Promise<boolean>;
         replace(
-          url: { query?: { [key: string]: string | string[] | undefined } },
+          url: Route | StaticRoute | Query,
           as?: string,
           options?: TransitionOptions
         ): Promise<boolean>;
@@ -722,12 +606,10 @@ declare module "next/link" {
   type Query = { query?: { [key: string]: string | string[] | undefined } };
   type StaticRoute = Exclude<Route, { query: any }>["pathname"];
 
-  export interface LinkProps<
-    Href extends Route | StaticRoute | Query = Route | StaticRoute | Query
-  >
+  export interface LinkProps
     extends Omit<NextLinkProps, "href" | "locale">,
       AnchorHTMLAttributes<HTMLAnchorElement> {
-    href: Href;
+    href: Route | StaticRoute | Query;
     locale?: false;
   }
 
@@ -741,15 +623,7 @@ declare module "next/link" {
     HTMLElement
   >;
 
-  declare function Link(
-    props: PropsWithChildren<LinkProps<Route>>
-  ): LinkReactElement;
-  declare function Link(
-    props: PropsWithChildren<LinkProps<StaticRoute>>
-  ): LinkReactElement;
-  declare function Link(
-    props: PropsWithChildren<LinkProps<Query>>
-  ): LinkReactElement;
+  declare function Link(props: PropsWithChildren<LinkProps>): LinkReactElement;
 
   export default Link;
 }
@@ -763,6 +637,7 @@ declare module "next/router" {
 
   type NextTransitionOptions = NonNullable<Parameters<Router["push"]>[2]>;
   type StaticRoute = Exclude<Route, { query: any }>["pathname"];
+  type Query = { query?: { [key: string]: string | string[] | undefined } };
 
   interface TransitionOptions extends Omit<NextTransitionOptions, "locale"> {
     locale?: false;
@@ -784,32 +659,12 @@ declare module "next/router" {
         locale?: Locale;
         locales?: undefined;
         push(
-          url: Route,
-          as?: string,
-          options?: TransitionOptions
-        ): Promise<boolean>;
-        push(
-          url: StaticRoute,
-          as?: string,
-          options?: TransitionOptions
-        ): Promise<boolean>;
-        push(
-          url: { query?: { [key: string]: string | string[] | undefined } },
+          url: Route | StaticRoute | Query,
           as?: string,
           options?: TransitionOptions
         ): Promise<boolean>;
         replace(
-          url: Route,
-          as?: string,
-          options?: TransitionOptions
-        ): Promise<boolean>;
-        replace(
-          url: StaticRoute,
-          as?: string,
-          options?: TransitionOptions
-        ): Promise<boolean>;
-        replace(
-          url: { query?: { [key: string]: string | string[] | undefined } },
+          url: Route | StaticRoute | Query,
           as?: string,
           options?: TransitionOptions
         ): Promise<boolean>;
@@ -882,12 +737,10 @@ declare module "next/link" {
   type Query = { query?: { [key: string]: string | string[] | undefined } };
   type StaticRoute = Exclude<Route, { query: any }>["pathname"];
 
-  export interface LinkProps<
-    Href extends Route | StaticRoute | Query = Route | StaticRoute | Query
-  >
+  export interface LinkProps
     extends Omit<NextLinkProps, "href" | "locale">,
       AnchorHTMLAttributes<HTMLAnchorElement> {
-    href: Href;
+    href: Route | StaticRoute | Query;
     locale?: false;
   }
 
@@ -901,15 +754,7 @@ declare module "next/link" {
     HTMLElement
   >;
 
-  declare function Link(
-    props: PropsWithChildren<LinkProps<Route>>
-  ): LinkReactElement;
-  declare function Link(
-    props: PropsWithChildren<LinkProps<StaticRoute>>
-  ): LinkReactElement;
-  declare function Link(
-    props: PropsWithChildren<LinkProps<Query>>
-  ): LinkReactElement;
+  declare function Link(props: PropsWithChildren<LinkProps>): LinkReactElement;
 
   export default Link;
 }
@@ -923,6 +768,7 @@ declare module "next/router" {
 
   type NextTransitionOptions = NonNullable<Parameters<Router["push"]>[2]>;
   type StaticRoute = Exclude<Route, { query: any }>["pathname"];
+  type Query = { query?: { [key: string]: string | string[] | undefined } };
 
   interface TransitionOptions extends Omit<NextTransitionOptions, "locale"> {
     locale?: false;
@@ -944,32 +790,12 @@ declare module "next/router" {
         locale?: Locale;
         locales?: undefined;
         push(
-          url: Route,
-          as?: string,
-          options?: TransitionOptions
-        ): Promise<boolean>;
-        push(
-          url: StaticRoute,
-          as?: string,
-          options?: TransitionOptions
-        ): Promise<boolean>;
-        push(
-          url: { query?: { [key: string]: string | string[] | undefined } },
-          as?: string,
-          options?: TransitionOptions
-        ): Promise<boolean>;
-        replace(
-          url: Route,
-          as?: string,
-          options?: TransitionOptions
-        ): Promise<boolean>;
-        replace(
-          url: StaticRoute,
+          url: Route | StaticRoute | Query,
           as?: string,
           options?: TransitionOptions
         ): Promise<boolean>;
         replace(
-          url: { query?: { [key: string]: string | string[] | undefined } },
+          url: Route | StaticRoute | Query,
           as?: string,
           options?: TransitionOptions
         ): Promise<boolean>;
@@ -1042,12 +868,10 @@ declare module "next/link" {
   type Query = { query?: { [key: string]: string | string[] | undefined } };
   type StaticRoute = Exclude<Route, { query: any }>["pathname"];
 
-  export interface LinkProps<
-    Href extends Route | StaticRoute | Query = Route | StaticRoute | Query
-  >
+  export interface LinkProps
     extends Omit<NextLinkProps, "href" | "locale">,
       AnchorHTMLAttributes<HTMLAnchorElement> {
-    href: Href;
+    href: Route | StaticRoute | Query;
     locale?: false;
   }
 
@@ -1061,15 +885,7 @@ declare module "next/link" {
     HTMLElement
   >;
 
-  declare function Link(
-    props: PropsWithChildren<LinkProps<Route>>
-  ): LinkReactElement;
-  declare function Link(
-    props: PropsWithChildren<LinkProps<StaticRoute>>
-  ): LinkReactElement;
-  declare function Link(
-    props: PropsWithChildren<LinkProps<Query>>
-  ): LinkReactElement;
+  declare function Link(props: PropsWithChildren<LinkProps>): LinkReactElement;
 
   export default Link;
 }
@@ -1083,6 +899,7 @@ declare module "next/router" {
 
   type NextTransitionOptions = NonNullable<Parameters<Router["push"]>[2]>;
   type StaticRoute = Exclude<Route, { query: any }>["pathname"];
+  type Query = { query?: { [key: string]: string | string[] | undefined } };
 
   interface TransitionOptions extends Omit<NextTransitionOptions, "locale"> {
     locale?: false;
@@ -1104,32 +921,12 @@ declare module "next/router" {
         locale?: Locale;
         locales?: undefined;
         push(
-          url: Route,
-          as?: string,
-          options?: TransitionOptions
-        ): Promise<boolean>;
-        push(
-          url: StaticRoute,
-          as?: string,
-          options?: TransitionOptions
-        ): Promise<boolean>;
-        push(
-          url: { query?: { [key: string]: string | string[] | undefined } },
-          as?: string,
-          options?: TransitionOptions
-        ): Promise<boolean>;
-        replace(
-          url: Route,
+          url: Route | StaticRoute | Query,
           as?: string,
           options?: TransitionOptions
         ): Promise<boolean>;
         replace(
-          url: StaticRoute,
-          as?: string,
-          options?: TransitionOptions
-        ): Promise<boolean>;
-        replace(
-          url: { query?: { [key: string]: string | string[] | undefined } },
+          url: Route | StaticRoute | Query,
           as?: string,
           options?: TransitionOptions
         ): Promise<boolean>;
@@ -1202,12 +999,10 @@ declare module "next/link" {
   type Query = { query?: { [key: string]: string | string[] | undefined } };
   type StaticRoute = Exclude<Route, { query: any }>["pathname"];
 
-  export interface LinkProps<
-    Href extends Route | StaticRoute | Query = Route | StaticRoute | Query
-  >
+  export interface LinkProps
     extends Omit<NextLinkProps, "href" | "locale">,
       AnchorHTMLAttributes<HTMLAnchorElement> {
-    href: Href;
+    href: Route | StaticRoute | Query;
     locale?: false;
   }
 
@@ -1221,15 +1016,7 @@ declare module "next/link" {
     HTMLElement
   >;
 
-  declare function Link(
-    props: PropsWithChildren<LinkProps<Route>>
-  ): LinkReactElement;
-  declare function Link(
-    props: PropsWithChildren<LinkProps<StaticRoute>>
-  ): LinkReactElement;
-  declare function Link(
-    props: PropsWithChildren<LinkProps<Query>>
-  ): LinkReactElement;
+  declare function Link(props: PropsWithChildren<LinkProps>): LinkReactElement;
 
   export default Link;
 }
@@ -1243,6 +1030,7 @@ declare module "next/router" {
 
   type NextTransitionOptions = NonNullable<Parameters<Router["push"]>[2]>;
   type StaticRoute = Exclude<Route, { query: any }>["pathname"];
+  type Query = { query?: { [key: string]: string | string[] | undefined } };
 
   interface TransitionOptions extends Omit<NextTransitionOptions, "locale"> {
     locale?: false;
@@ -1264,32 +1052,12 @@ declare module "next/router" {
         locale?: Locale;
         locales?: undefined;
         push(
-          url: Route,
-          as?: string,
-          options?: TransitionOptions
-        ): Promise<boolean>;
-        push(
-          url: StaticRoute,
-          as?: string,
-          options?: TransitionOptions
-        ): Promise<boolean>;
-        push(
-          url: { query?: { [key: string]: string | string[] | undefined } },
-          as?: string,
-          options?: TransitionOptions
-        ): Promise<boolean>;
-        replace(
-          url: Route,
-          as?: string,
-          options?: TransitionOptions
-        ): Promise<boolean>;
-        replace(
-          url: StaticRoute,
+          url: Route | StaticRoute | Query,
           as?: string,
           options?: TransitionOptions
         ): Promise<boolean>;
         replace(
-          url: { query?: { [key: string]: string | string[] | undefined } },
+          url: Route | StaticRoute | Query,
           as?: string,
           options?: TransitionOptions
         ): Promise<boolean>;
@@ -1379,12 +1147,10 @@ declare module "next/link" {
   type Query = { query?: { [key: string]: string | string[] | undefined } };
   type StaticRoute = Exclude<Route, { query: any }>["pathname"];
 
-  export interface LinkProps<
-    Href extends Route | StaticRoute | Query = Route | StaticRoute | Query
-  >
+  export interface LinkProps
     extends Omit<NextLinkProps, "href" | "locale">,
       AnchorHTMLAttributes<HTMLAnchorElement> {
-    href: Href;
+    href: Route | StaticRoute | Query;
     locale?: false;
   }
 
@@ -1398,15 +1164,7 @@ declare module "next/link" {
     HTMLElement
   >;
 
-  declare function Link(
-    props: PropsWithChildren<LinkProps<Route>>
-  ): LinkReactElement;
-  declare function Link(
-    props: PropsWithChildren<LinkProps<StaticRoute>>
-  ): LinkReactElement;
-  declare function Link(
-    props: PropsWithChildren<LinkProps<Query>>
-  ): LinkReactElement;
+  declare function Link(props: PropsWithChildren<LinkProps>): LinkReactElement;
 
   export default Link;
 }
@@ -1420,6 +1178,7 @@ declare module "next/router" {
 
   type NextTransitionOptions = NonNullable<Parameters<Router["push"]>[2]>;
   type StaticRoute = Exclude<Route, { query: any }>["pathname"];
+  type Query = { query?: { [key: string]: string | string[] | undefined } };
 
   interface TransitionOptions extends Omit<NextTransitionOptions, "locale"> {
     locale?: false;
@@ -1441,32 +1200,12 @@ declare module "next/router" {
         locale?: Locale;
         locales?: undefined;
         push(
-          url: Route,
-          as?: string,
-          options?: TransitionOptions
-        ): Promise<boolean>;
-        push(
-          url: StaticRoute,
-          as?: string,
-          options?: TransitionOptions
-        ): Promise<boolean>;
-        push(
-          url: { query?: { [key: string]: string | string[] | undefined } },
-          as?: string,
-          options?: TransitionOptions
-        ): Promise<boolean>;
-        replace(
-          url: Route,
-          as?: string,
-          options?: TransitionOptions
-        ): Promise<boolean>;
-        replace(
-          url: StaticRoute,
+          url: Route | StaticRoute | Query,
           as?: string,
           options?: TransitionOptions
         ): Promise<boolean>;
         replace(
-          url: { query?: { [key: string]: string | string[] | undefined } },
+          url: Route | StaticRoute | Query,
           as?: string,
           options?: TransitionOptions
         ): Promise<boolean>;