-
Notifications
You must be signed in to change notification settings - Fork 114
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
Can't use TS typedefs on an ESM setup #2365
Comments
My current workaround is just to do the following when importing: import graphqlModules = require("graphql-modules");
const { gql, createModule } = graphqlModules; |
Good news, I edited the {
"main": "index.js",
"module": "index.mjs",
"typings": "index.d.ts",
"typescript": {
"definition": "index.d.ts"
},
"exports": {
".": {
"require": {
"types": "./index.d.ts",
"default": "./index.js"
},
"import": {
"types": "./index.d.ts",
"default":"./index.mjs"
}
},
"./*": {
"require": {
"types": "./*.d.ts",
"default": "./*.js"
},
"import": {
"types": "./*.d.ts",
"default": "./*.mjs"
}
},
"./package.json": "./package.json"
}
} |
So I just revisted this again. Was going to do a PR to fix this, but I noticed that the However the Here's the diff --git a/node_modules/graphql-modules/package.json b/node_modules/graphql-modules/package.json
index 00c64ab..c5b45b2 100644
--- a/node_modules/graphql-modules/package.json
+++ b/node_modules/graphql-modules/package.json
@@ -30,11 +30,13 @@
"exports": {
".": {
"require": "./index.js",
- "import": "./index.mjs"
+ "import": "./index.mjs",
+ "types": "./index.d.ts"
},
"./*": {
"require": "./*.js",
- "import": "./*.mjs"
+ "import": "./*.mjs",
+ "types": "./*.d.ts"
},
"./package.json": "./package.json"
} |
@patrickjm could you please take a look at this. It seems you fixed types in source code in this PR #2324 but the final |
Any updates on this @patrickjm ? These are the exports from the published npmjs package, they seem to miss the |
No updates here, would recommend making another PR for this one. edit: I am not a maintainer of this repo |
The source code looks fine, this seems to be connected to the publishing pipeline. |
@patrickjm Any update? |
Does it transitively depend on your action? graphql-modules/.github/workflows/release.yml Lines 7 to 9 in 0c72ee4
Do you know why the |
Describe the bug
I am not able to use the TypeScript type definition files when my Node 18 project is setup with ESM support enabled. TypeScript compilation will produce the following error:
To Reproduce
Steps to reproduce the behavior:
package.json
(abbreviated):tsconfig.json
(abbreviated):In any
ts
file the following will produce the TypeScript error:Expected behavior
An import should use the expected type definition files.
Environment:
@graphql-modules/...
:2.1.2
18.16.0
Additional context
Was able to find some documentation on how to reference typedefs in the new
exports
feature: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-7.html#packagejson-exports-imports-and-self-referencingFor what it's worth looking at the current
graphql-modules
package.json
file, it currently has the following:The
graphql
package at version16.6.0
seems to be working correctly. It currently has the following:The text was updated successfully, but these errors were encountered: