-
-
Notifications
You must be signed in to change notification settings - Fork 20
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
tsconfig module: NodeNext has typescript error TS7016 Could not find a declaration file #435
Comments
I tried to reproduce the issue but for me it works as expected. But I probably did not replicate your case 100%. I used your tsconfig.json (at least the part that you showed above) and compiled a file with the content: import { GridEngineHeadless } from "grid-engine";
console.log(GridEngineHeadless); That worked for me. If I change the "exports" section in Grid Engines package.json as you suggest above it breaks. If this is still an issue for you, could you share a minimum breaking example on codesandbox or similar? |
Here you go. I made no changes other than adding a manual ![]() https://codesandbox.io/p/sandbox/dazzling-goldwasser-cftd8g |
Thanks for the example repo! I was finally able to reproduce it. However, I could not yet solve the problem with the suggested fix but I am on it. |
A small update: I think I got the types working thanks to the link to the TS docs you provided. TL/DR: I will have to change all imports in the TS code to use .js file endings, even though there are no such .js files... 😭 |
That is... pretty disgusting. I would rather you not do that, mostly on moral DevX grounds. I don't know how comfortable you are with your package bundler, but outputting the
As a last resort, the other alternative I thought of was to throw up a And again, if you don't find a clean solution, feel free to close this out. It's a bit of an odd edge case. |
That is exactly how I finally got it working.
It reads like I would eventually have to do it anyway, because the TypeScript team made it pretty clear they will not allow .ts endings and I think enforcing file endings is part of the ECMA specification... |
@perspectivezoom, can you confirm that it works now with version 2.38.0? |
Yep, I'm getting types now in the backend. It is now correctly complaining that I need to I appreciate the fix @Annoraaq. Closing the issue. |
Thanks for your help and pointing it out in the first place! |
I could reproduce it. I just released a patch: v2.38.1 It now works for CJS and ESM for me. |
Confirmed that upgrading to |
I'm using
GridEngineHeadless
to keep track of character movement serverside in a NodeJS Express Colyseus multiplayer server, and encountered the following type resolution error:This error does not appear on my NextJS clientside
GridEngineHeadless
usage (duplicating the server logic for nonlaggy local character movement).I eventually traced the problem down to the

moduleResolution: "NodeNext"
config in mytsconfig.json
:If I change the
tsconfig.json
to"module":"ESNext", "moduleResolution": "Node"
(which is what my frontend uses),npm run build
works fine.Much Googling later, I discovered the following Typescript issue: microsoft/TypeScript#49160
I've created a minimal repro at https://github.com/perspectivezoom/tsc-nodenext

As before, changing the
tsconfig.json
to"module":"ESNext", "moduleResolution": "Node"
causesnpm run build
to work.I think the easiest bugfix here is to have the
package.json
exports
declaration include atypes
path in thecjs
require
, but there are other ways to do it.https://www.typescriptlang.org/docs/handbook/esm-node.html#packagejson-exports-imports-and-self-referencing
Note that this is not a blocking bug; I'm using
declare module "grid-engine";
in my project to bypass the error, but this workaround typesGridEngineHeadless
asany
, which is not great.EDIT: I am no longer using
GridEngineHeadless
on the serverside, because I couldn't figure out how to not drop input ticks with bad latency. Switched back to the client telling the server its position instead of inputs, which isn't great from a security perspective but not the worst thing in the world. Man, multiplayer is hard.The text was updated successfully, but these errors were encountered: