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

Fix CJS type import when moduleResolution is node16 #76

Merged
merged 1 commit into from
Jan 5, 2024

Conversation

andrew0
Copy link
Contributor

@andrew0 andrew0 commented Dec 27, 2023

The types right now currently don't work if the user is using node16 moduleResolution in a CJS project:
https://arethetypeswrong.github.io/?p=gqtx%400.9.3

After running yarn build && cd dist && npx @arethetypeswrong/cli --pack with this change:

image

The types right now currently don't work if the user is using node16
moduleResolution in a CJS project:
https://arethetypeswrong.github.io/?p=gqtx%400.9.3
},
"./package.json": "./package.json",
"./": "./"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VS Code gave a warning for this saying "Property ./ is not allowed."

@@ -1,7 +1,6 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "dist/cjs",
"declaration": false
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried using the same type definition files for both require and import, but then TypeScript thinks that the type definitions are for ESM even in CJS mode, so it won't let you import it in a CJS app.

@sikanhe
Copy link
Owner

sikanhe commented Jan 5, 2024

@andrew0 This is amazing - appreciate your help

@sikanhe sikanhe merged commit 91f52af into sikanhe:master Jan 5, 2024
1 check passed
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

Successfully merging this pull request may close these issues.

2 participants