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

'@whatwg-node/server/index.mjs' implicitly has an 'any' type. #574

Closed
Tobbe opened this issue May 31, 2023 · 7 comments
Closed

'@whatwg-node/server/index.mjs' implicitly has an 'any' type. #574

Tobbe opened this issue May 31, 2023 · 7 comments

Comments

@Tobbe
Copy link

Tobbe commented May 31, 2023

Describe the bug

I tried switching to moduleResolution: bundler in Redwood, but doing so I'm getting this TS error

Could not find a declaration file for module '@whatwg-node/server'. '/Users/tobbe/dev/redwood/redwood/node_modules/@whatwg-node/server/index.mjs' implicitly has an 'any' type.
There are types at '/Users/tobbe/dev/redwood/redwood/node_modules/@whatwg-node/server/index.d.ts', but this result could not be resolved when respecting package.json "exports". The '@whatwg-node/server' library may need to update its package.json or typings.

To Reproduce Steps to reproduce the behavior:

No sandbox link right now, sorry. Let me know if you want one

Expected behavior

No TS errors when using this package in an ESM environment

Environment:

  • OS: MacOS
  • package-name: @whatwg-node/server
  • NodeJS: 18

Additional context

In node_modules/@whatwg-node/server there is already an index.d.ts file. If I just copy/paste this file and name the copy index.d.mts the error goes away.

You can read more about the error here: microsoft/TypeScript#52363
That issue also links out to this PR with an example solution to that error in another project: gxmari007/vite-plugin-eslint#60 The comments on that PR are also good to read

@ardatan
Copy link
Owner

ardatan commented Jun 1, 2023

I don't use that flag so I don't have much idea about the error.
Also I prefer skipLibCheck: true because I don't think we need to run type checking for the libraries.
Feel free to contribute to fix it. PRs are welcome!

@Tobbe
Copy link
Author

Tobbe commented Jun 3, 2023

Also I prefer skipLibCheck: true because I don't think we need to run type checking for the libraries.

We do use skipLibCheck: true. I had to copy some of your code into our project to see the actual error I posted above.
The problem is though that even with skipLibCheck: true I'm getting actual errors in our code, because TS just says the type is any for stuff we import from graphql-yoga

Importing from graphql-yoga:
image

Using Plugin (notice how it say = any at the end)
image

And finally, here's how that's a problem for us
image

Feel free to contribute to fix it. PRs are welcome!

I did look into fixing this, but didn't get very far 🙁 Can this be fixed here, in this repo, or do I need to make changes to bob? Do you think you could give me some pointers?

@LiamMartens
Copy link
Contributor

What version of @whatwg-node/server is this? Would be great to have a basic code example too

@ardatan
Copy link
Owner

ardatan commented Jul 10, 2023

Closing the issue due to the lack of response. Feel free to create a new one if you still have it.

@ardatan ardatan closed this as completed Jul 10, 2023
@virtuoushub
Copy link

virtuoushub commented Aug 23, 2023

Hi @Tobbe and I are working together.

What version of @whatwg-node/server is this? Would be great to have a basic code example too

0.8.12

$ yarn why @whatwg-node/server
...
├─ graphql-yoga@npm:4.0.2
│  └─ @whatwg-node/server@npm:0.8.12 (via npm:^0.8.1)
...

Sorry, I don't have a basic code example but here is an example of where it errors: https://github.com/redwoodjs/redwood/blob/main/packages/graphql-server/src/functions/graphql.ts#L111


Closing the issue due to the lack of response. Feel free to create a new one if you still have it.

Happy to open another one, however the issue is still the same as before. Please let me know what is best.

@ardatan
Copy link
Owner

ardatan commented Aug 23, 2023

If you share a reproduction on CodeSandbox or StackBlitz, I can help you better

@virtuoushub
Copy link

If you share a reproduction on CodeSandbox or StackBlitz, I can help you better

https://codesandbox.io/s/kind-shadow-qfq88y?file=/src/functions/graphql.ts:3324-3374#L112

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants
@Tobbe @virtuoushub @LiamMartens @ardatan and others