Skip to content

Commit

Permalink
Merge pull request #11 from ckastbjerg/less-strict-query
Browse files Browse the repository at this point in the history
Less strict type for Query
  • Loading branch information
ckastbjerg authored Apr 8, 2021
2 parents 1955634 + c93cc23 commit 1369000
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ And for dynamic routes, the type is always:
**Example**:

```ts
type Query = { [key: string]: string | number };
type Query = { [key: string]: any };
export type TypeSafePage =
| "/users"
| { route: "/users"; query?: Query }
Expand Down
2 changes: 1 addition & 1 deletion example/src/@types/next-type-safe-routes/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// package. You should _not_ update these types manually...

declare module "next-type-safe-routes" {
type Query = { [key: string]: string | number };
type Query = { [key: string]: any };
export type TypeSafePage = "/" | { route: "/", query?: Query } | { route: "/users/[userId]", params: { userId: string | string[] | number }, query?: Query } | "/users" | { route: "/users", query?: Query };
export type TypeSafeApiRoute = "/api/mocks" | { route: "/api/mocks", query?: Query } | { route: "/api/users/[userId]", params: { userId: string | string[] | number }, query?: Query } | "/api/users" | { route: "/api/users", query?: Query };
export const getPathname = (typeSafeUrl: TypeSafePage | TypeSafeApiRoute) => string;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "next-type-safe-routes",
"version": "0.2.0-alpha",
"version": "0.2.0-alpha.1",
"description": "Never should your users experience broken links again!",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ exports[`plugin/generateTypeScriptFile works as expected 1`] = `
// package. You should _not_ update these types manually...
declare module \\"next-type-safe-routes\\" {
type Query = { [key: string]: string | number };
type Query = { [key: string]: any };
export type TypeSafePage = \\"/404\\" | { route: \\"/404\\", query?: Query } | \\"/\\" | { route: \\"/\\", query?: Query } | { route: \\"/users/[userId]\\", params: { userId: string | string[] | number }, query?: Query } | \\"/users\\" | { route: \\"/users\\", query?: Query };
export type TypeSafeApiRoute = { route: \\"/api/[authId]\\", params: { authId: string | string[] | number }, query?: Query } | { route: \\"/api/users/[userId]\\", params: { userId: string | string[] | number }, query?: Query } | \\"/api/users\\" | { route: \\"/api/users\\", query?: Query };
export const getPathname = (typeSafeUrl: TypeSafePage | TypeSafeApiRoute) => string;
Expand Down
2 changes: 1 addition & 1 deletion src/plugin/generateTypeScriptFile/getFileContent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const getFileContent = ({
// package. You should _not_ update these types manually...
declare module "next-type-safe-routes" {
type Query = { [key: string]: string | number };
type Query = { [key: string]: any };
export type TypeSafePage = ${pages.map(getTypeSafeRoute).join(" | ")};
${
apiRoutes.length > 0
Expand Down
2 changes: 1 addition & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// NOTE, these will be replaced with the "real" TypeSafePage type
// when generating types for a project
type Query = { [key: string]: string | number };
type Query = { [key: string]: any };
type TypeSafePage =
| string
| { route: string; query?: Query }
Expand Down

0 comments on commit 1369000

Please sign in to comment.