Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src/index.ts(1,15): error TS2459: Module '"a/server"' declares 'FileRouter' locally, but it is not exported. #382

Closed
juliusmarminge opened this issue Jan 11, 2024 · 1 comment
Labels
question Further information is requested

Comments

@juliusmarminge
Copy link
Contributor

Repo: https://github.com/juliusmarminge/buncheeee

Reproduce

pnpm i && pnpm build

CleanShot 2024-01-11 at 22 44 03@2x

Probably some weird config option that causes this, but the types aren't getting resolved:

CleanShot 2024-01-11 at 22 45 49@2x

@huozhi
Copy link
Owner

huozhi commented Jan 12, 2024

@juliusmarminge I tested against the repo and found that you can use the following patch to get rid of the errors

diff --git a/packages/a/package.json b/packages/a/package.json
index 7adeca4..5a7b607 100644
--- a/packages/a/package.json
+++ b/packages/a/package.json
@@ -74,8 +74,7 @@
     },
     "./internal/types": {
       "types": "./dist/internal/types.d.ts",
-      "import": "./dist/internal/types.mjs",
-      "require": "./dist/internal/types.js"
+      "default": "./dist/internal/types.js"
     }
   },
   "typesVersions": {
diff --git a/packages/a/src/server.ts b/packages/a/src/server.ts
index a178b44..632eb74 100644
--- a/packages/a/src/server.ts
+++ b/packages/a/src/server.ts
@@ -76,3 +76,5 @@ export const createServerHandler = <TRouter extends FileRouter>(
 
 export const extractRouterConfig = (router: FileRouter) =>
   buildPermissionsInfoHandler({ router })();
+
+export { type FileRouter }
\ No newline at end of file
  • 1st, Export the type that missing in packages/a
  • 2nd, The reason I change the "./internal/types" to only having default export and types, so it will only generate one type file and TS only be confused about the types of mjs and cjs.

This will make it work, but very good feedback. I think in the future it could have more validations about types to help configure correctly

@huozhi huozhi added the question Further information is requested label Jan 12, 2024
@huozhi huozhi closed this as completed Jan 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants