Repository: tatethurston/nextjs-routes
Pull request #119 (2023-01-20 02:16:30)

export withRoutes types
fixes #118 


Patch:
diff --git a/.gitignore b/.gitignore
index 249704e..340c505 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,3 +3,4 @@ coverage
 node_modules
 tsconfig.tsbuildinfo
 .next
+.vscode
diff --git a/examples/app/nextjs-routes.d.ts b/examples/app/nextjs-routes.d.ts
index 4fd6109..15d1331 100644
--- a/examples/app/nextjs-routes.d.ts
+++ b/examples/app/nextjs-routes.d.ts
@@ -1,6 +1,6 @@
 // THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
 // This file will be automatically regenerated when your Next.js server is running.
-// nextjs-routes version: 1.0.7
+// nextjs-routes version: 1.0.8
 /* eslint-disable */
 
 // prettier-ignore
diff --git a/examples/intl/nextjs-routes.d.ts b/examples/intl/nextjs-routes.d.ts
index d6b017f..284bc95 100644
--- a/examples/intl/nextjs-routes.d.ts
+++ b/examples/intl/nextjs-routes.d.ts
@@ -1,6 +1,6 @@
 // THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
 // This file will be automatically regenerated when your Next.js server is running.
-// nextjs-routes version: 1.0.7
+// nextjs-routes version: 1.0.8
 /* eslint-disable */
 
 // prettier-ignore
diff --git a/examples/typescript/pages/_app.tsx b/examples/typescript/pages/_app.tsx
index ef51d68..e2618ab 100644
--- a/examples/typescript/pages/_app.tsx
+++ b/examples/typescript/pages/_app.tsx
@@ -1,4 +1,6 @@
 import type { AppProps } from "next/app";
+import withRoutes from "nextjs-routes/config";
+withRoutes({});
 
 function MyApp({ Component, pageProps }: AppProps) {
   return <Component {...pageProps} />;
diff --git a/examples/typescript/types/nextjs-routes.d.ts b/examples/typescript/types/nextjs-routes.d.ts
index 16e11fd..9ef897d 100644
--- a/examples/typescript/types/nextjs-routes.d.ts
+++ b/examples/typescript/types/nextjs-routes.d.ts
@@ -1,6 +1,6 @@
 // THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
 // This file will be automatically regenerated when your Next.js server is running.
-// nextjs-routes version: 1.0.7
+// nextjs-routes version: 1.0.8
 /* eslint-disable */
 
 // prettier-ignore
diff --git a/package.json b/package.json
index db19e9e..cc9eb89 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
 {
   "private": true,
   "name": "nextjs-routes-development",
-  "version": "1.0.7",
+  "version": "1.0.8",
   "license": "MIT",
   "author": "Tate <tatethurston@gmail.com>",
   "repository": {
diff --git a/public.package.json b/public.package.json
index 113c5fc..502e350 100644
--- a/public.package.json
+++ b/public.package.json
@@ -1,6 +1,6 @@
 {
   "name": "nextjs-routes",
-  "version": "1.0.7",
+  "version": "1.0.8",
   "description": "Type safe routing for Next.js",
   "license": "MIT",
   "author": "Tate <tatethurston@gmail.com>",
@@ -10,10 +10,10 @@
   },
   "type": "module",
   "exports": {
-    ".": "./src/index.js",
+    ".": "./index.js",
     "./package.json": "./package.json",
     "./config": {
-      "import": "./src/config.js",
+      "import": "./config.js",
       "require": "./config.cjs"
     }
   },
diff --git a/src/core.ts b/src/core.ts
index a7935ae..de58b63 100644
--- a/src/core.ts
+++ b/src/core.ts
@@ -7,7 +7,7 @@ import { findFiles, getAppDirectory, getPagesDirectory } from "./utils.js";
 // by node 17+
 // import pkg from "../package.json" assert { type: "json" };
 const pkg = {
-  version: "1.0.7",
+  version: "1.0.8",
 };
 
 type QueryType = "dynamic" | "catch-all" | "optional-catch-all";
diff --git a/tsconfig.json b/tsconfig.json
index d45b4d0..b47be95 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -10,11 +10,11 @@
     "noEmitOnError": false,
     "outDir": "dist",
     "resolveJsonModule": true,
-    "rootDir": ".",
+    "rootDir": "src",
     "skipLibCheck": true,
     "sourceMap": false,
     "strict": true,
     "target": "ES2020"
   },
-  "include": ["package.json", "src/**/*"]
+  "include": ["src/**/*"]
 }


Test patch:
diff --git a/e2e/nextjs-routes.d.ts b/e2e/nextjs-routes.d.ts
index 3d56d88..eaf396c 100644
--- a/e2e/nextjs-routes.d.ts
+++ b/e2e/nextjs-routes.d.ts
@@ -1,6 +1,6 @@
 // THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
 // This file will be automatically regenerated when your Next.js server is running.
-// nextjs-routes version: 1.0.7
+// nextjs-routes version: 1.0.8
 /* eslint-disable */
 
 // prettier-ignore
diff --git a/e2e/typetest.tsx b/e2e/typetest.tsx
index 32059ae..a093998 100644
--- a/e2e/typetest.tsx
+++ b/e2e/typetest.tsx
@@ -2,6 +2,13 @@ import Link from "next/link";
 import { LinkProps } from "next/link";
 import { useRouter, RouterEvent, NextRouter } from "next/router";
 import { route, type Route, type RoutedQuery } from "nextjs-routes";
+import withRoutes from "nextjs-routes/config";
+
+withRoutes();
+withRoutes({});
+withRoutes({ outDir: "types" });
+// @ts-expect-error invalid key 'foo'
+withRoutes({ foo: false });
 
 // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function
 function expectType<T>(_value: T) {}
diff --git a/src/__snapshots__/core.test.ts.snap b/src/__snapshots__/core.test.ts.snap
index 508e079..28357ce 100644
--- a/src/__snapshots__/core.test.ts.snap
+++ b/src/__snapshots__/core.test.ts.snap
@@ -6,7 +6,7 @@ exports[`route generation app directory (experimental) 1`] = `
     "nextjs-routes.d.ts",
     "// THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
 // This file will be automatically regenerated when your Next.js server is running.
-// nextjs-routes version: 1.0.7
+// nextjs-routes version: 1.0.8
 /* eslint-disable */
 
 // prettier-ignore
@@ -140,7 +140,7 @@ exports[`route generation configuration i18n 1`] = `
     "nextjs-routes.d.ts",
     "// THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
 // This file will be automatically regenerated when your Next.js server is running.
-// nextjs-routes version: 1.0.7
+// nextjs-routes version: 1.0.8
 /* eslint-disable */
 
 // prettier-ignore
@@ -292,7 +292,7 @@ exports[`route generation configuration outDir 1`] = `
     "src/nextjs-routes.d.ts",
     "// THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
 // This file will be automatically regenerated when your Next.js server is running.
-// nextjs-routes version: 1.0.7
+// nextjs-routes version: 1.0.8
 /* eslint-disable */
 
 // prettier-ignore
@@ -424,7 +424,7 @@ exports[`route generation configuration pageExtensions configured 1`] = `
     "nextjs-routes.d.ts",
     "// THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
 // This file will be automatically regenerated when your Next.js server is running.
-// nextjs-routes version: 1.0.7
+// nextjs-routes version: 1.0.8
 /* eslint-disable */
 
 // prettier-ignore
@@ -558,7 +558,7 @@ exports[`route generation configuration pageExtensions default 1`] = `
     "nextjs-routes.d.ts",
     "// THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
 // This file will be automatically regenerated when your Next.js server is running.
-// nextjs-routes version: 1.0.7
+// nextjs-routes version: 1.0.8
 /* eslint-disable */
 
 // prettier-ignore
@@ -690,7 +690,7 @@ exports[`route generation dedupes 1`] = `
     "nextjs-routes.d.ts",
     "// THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
 // This file will be automatically regenerated when your Next.js server is running.
-// nextjs-routes version: 1.0.7
+// nextjs-routes version: 1.0.8
 /* eslint-disable */
 
 // prettier-ignore
@@ -822,7 +822,7 @@ exports[`route generation no routes 1`] = `
     "nextjs-routes.d.ts",
     "// THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
 // This file will be automatically regenerated when your Next.js server is running.
-// nextjs-routes version: 1.0.7
+// nextjs-routes version: 1.0.8
 /* eslint-disable */
 
 // prettier-ignore
@@ -954,7 +954,7 @@ exports[`route generation transforms windows paths 1`] = `
     "nextjs-routes.d.ts",
     "// THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
 // This file will be automatically regenerated when your Next.js server is running.
-// nextjs-routes version: 1.0.7
+// nextjs-routes version: 1.0.8
 /* eslint-disable */
 
 // prettier-ignore
@@ -1086,7 +1086,7 @@ exports[`route generation typescript 1`] = `
     "nextjs-routes.d.ts",
     "// THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
 // This file will be automatically regenerated when your Next.js server is running.
-// nextjs-routes version: 1.0.7
+// nextjs-routes version: 1.0.8
 /* eslint-disable */
 
 // prettier-ignore