-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
"moduleResolution": "NodeNext" throws ESM related errors #50058
Comments
It sounds like you had a misconfiguration and fixed it. I don't see a demonstrated bug here. |
Isn't |
Yes, that's what the issue is here. When |
@fatcerberus points out that #50086 is likely related FWIW. |
@sheetalkamat was this also fixed by your PR? |
It probably is but i didnt verify it explicitly (assuming issue is with descipencies between errors reported for vscode and tsc) |
The main issue with ESM and The officially proposed workaround is to manually add It's particularly surprising because TypeScript encourages you to use Frontend framework users whose build toolchain compiles TypeScript on demand will be hit next as they add the It makes my team members develop an aversion to TypeScript, not to mention it probably got me looking pretty bad myself, because the only way to perform the otherwise trivial act of delivering an isomorphic library (i.e. one which which works out of the box in all contexts - Node, browser, ESM, CJS, pre-compiled, on-demand, framework, no framework) is walking the compiled code's AST to add the extensions. |
I am seeing an issue similar to this where the addition of Basically, when trying to import the
Despite the fact that I created a super simple repro repo (reprository?) here: https://github.com/smaye81/ts-repro. You can see this behavior by running the two scripts:
I'm not sure if I'm just using a bad configuration, but I would think at the very least this error message should be fixed, right? |
Not sure if same issue but with Basically this code won't work w
My current workaround is to add dozens of lines such as
Makes the editor code go away but now code doesn't transpile correctly (results in things like ajv['default']['default']) What is baffling is IF editor says error then its correct and if it says no error then its not. I kept thinking that my TS linter and my |
I encountered this similar problem when I want to import the default this doesn't workimport create from "zustand/vanilla";
export const store = create(() => ({ foo: "bar" })); this worksimport zustand from "zustand/vanilla";
import { defaultImport } from "default-import";
const create = defaultImport(zustand);
export const store = create(() => ({ foo: "bar" })); A minimal repo to reproduce this problem: https://stackblitz.com/edit/node-vj368k?file=src/index.ts |
|
@weswigham Thanks for the quick response, so what's the correct way to declare types for a mjs entrypoint? Forgive me if I sound stupid. Update: There're generally two things that worth noting:
|
I’m facing the same issue in these two PRs:
Here are some third-party packages that have problems with default exports when
As a temp solution, I’ve managed to do this: -import x from "x";
+import _x from "x";
+const x = _x as unknown as typeof _x.default; Although it‘s true that the problem is within the packages, I wonder if it is possible to create a new compile option which could be used during the transition period? Something like When switching a project to |
I would also add |
Fix the issue that `@kosko/env` cannot be resolved correctly when `moduleResolution=nodenext` is set in `tsconfig.json`. microsoft/TypeScript#50058
Fix the issue that `@kosko/env` cannot be resolved correctly when `moduleResolution=nodenext` is set in `tsconfig.json`. microsoft/TypeScript#50058
Leaving a note for the users of these two libraries as they seem to trigger this kind of error too with Sample code:
The errors:
|
This kind of error pretty much always indicates that the types use I guess big.js is on DefinitelyTyped but probably has the same problem. Will take a look at that next. Edit: big.js fix is up DefinitelyTyped/DefinitelyTyped#66163 |
I have same problem for module
EDIT : I found how to fix. You have to do this : import type { Functions } from 'serverless/aws.d.ts'; |
Does this issue occur when all extensions are disabled?: Yes
Steps to Reproduce:
npm
package. Install[email protected]
andpretty-ms
.tsconfig.json
as:"type": "module"
inpackage.json
.ts
extension undersrc/
:tsc
throws no errors.tsconfig.json
The text was updated successfully, but these errors were encountered: