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

Types issue with ESM setup #132

Open
iamchathu opened this issue Jan 28, 2025 · 3 comments
Open

Types issue with ESM setup #132

iamchathu opened this issue Jan 28, 2025 · 3 comments

Comments

@iamchathu
Copy link

Seems types doesn't work with latest versions of Fastify and Mercurius

https://stackblitz.com/edit/stackblitz-starters-1avfikyy?file=src%2Findex.ts

@jonnydgreen
Copy link
Collaborator

Ah interesting! Thanks for reporting this, would you be interested in contributing a fix for this? :) I'll also take a quick look tomorrow to replicate and understand the issue :)

@iamchathu
Copy link
Author

I would like to contribute. But I couldn't yet able to pin point the issue

@iamchathu
Copy link
Author

So I did some digging with following tool and the command

pnpx @arethetypeswrong/cli --from-npm mercurius-auth@6.0.0

It does give following errors

mercurius-auth v6.0.0

Build tools:
- typescript@^5.0.2

❗️ The resolved types use export default where the JavaScript file appears to use module.exports =. 
This will cause TypeScript under the node16 module mode to think an extra .default property access is required, but that will likely fail at runtime. 
These types should use export = instead of export default. https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/FalseExportDefault.md


┌───────────────────┬──────────────────────────────┐
│                   │ "mercurius-auth"             │
├───────────────────┼──────────────────────────────┤
│ node10            │ ❗️ Incorrect default export │
├───────────────────┼──────────────────────────────┤
│ node16 (from CJS) │ ❗️ Incorrect default export │
├───────────────────┼──────────────────────────────┤
│ node16 (from ESM) │ ❗️ Incorrect default export │
├───────────────────┼──────────────────────────────┤
│ bundler           │ ❗️ Incorrect default export │
└───────────────────┴──────────────────────────────┘

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

2 participants