-
Notifications
You must be signed in to change notification settings - Fork 224
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 compatibility with Node16/NodeNext moduleResolution #1200
Comments
Same here, cannot integrate Superstruct in Superforms v2 due to this. |
Opened a PR for this issue in #1211 |
I am testing version 1.0.5-0 which, as I understand it, is a pre-release for the fix to this issue. However it seems to fail for me when I also use My
and I get this error:
Am I missing something or should this work too ? |
@nerochiaro The TS error actually explains it correctly — you are importing an ECMAScript module ( The underlying cause is a bit obscured by TypeScript in this case, but it's the equivalent of doing something like this: // File: index.cjs <- a CommonJS module because of .cjs
const { hello } = require("./hello.mjs")
hello() // File: hello.mjs <- a ECMAScript module because of .mjs
export function hello() {
console.log("hello world")
} Trying to run this with Node you get the following error:
In TypeScript codebases, I find it best to set the package.json {
"type": "module",
// ...plus all the other usual fields
} |
This has been resolved in 2.0! |
When setting ModuleResolution to
NodeNext
in a project'stsconfig.json
and using ESM within that project, superstruct's types fail to be discovered. I am fairly sure this is due to the fact thatindex.d.ts
imports other type declarations without file extensions.It would be a fairly simple fix to change imports to use
.js
file extensions, which do work, even for type declarations, and shouldn't break anything.The text was updated successfully, but these errors were encountered: