-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Incorrect .js
suffix added to named module import in declaration files.
#60930
Comments
We're very likely to deprecate node10 in 6.0. I don't think this warrants a fix at this point. |
That seems reasonable to me (deprecating in 6.0, not fixing bug prior to that), thanks for sharing the plan! Am I correct in assuming that the |
This issue has been marked as "Won't Fix" and has seen no recent activity. It has been automatically closed for house-keeping purposes. |
Currently, the `_types` is built using `node` module resolution, which results in this project generating invalid types. Details about the TypeScript bug can be found at microsoft/TypeScript#60930 (comment) and there are no plans to fix it since `node` (which is equivalent to `node10`) is being deprecated in TypeScript soon. The rest of this project uses `nodenext`, so this changes the types `tsconfig` file to also use `nodenext`, and fix the bug that currently prevents the library from being used correctly in native ESM projects.
Currently, the `_types` is built using `node` module resolution, which results in this project generating invalid types. Details about the TypeScript bug can be found at microsoft/TypeScript#60930 (comment) and there are no plans to fix it since `node` (which is equivalent to `node10`) is being deprecated in TypeScript soon. The way this bug manifests is in files like `src/_types/core/P256.d.ts` where it would previously generate code like:�```ts create: (hash: import("@noble/curves/abstract/utils.js").CHash) => import("@noble/curves/abstract/weierstrass.js").CurveFn; ``` when it should have generated code like this (which is what is generated after this change):�```ts create: (hash: import("@noble/curves/abstract/utils").CHash) => import("@noble/curves/abstract/weierstrass").CurveFn; ``` For the cjs build command, I changed from `node` to `node10` to be more explicit/clear, since `node` was just an alias for `node10`. For the esm build command, I changed it to use the tsconfig so it is less likely to get out of sync with the generated types. Also updated .gitignore to ignore `.pnpm-store` which had 30,000 files it wanted to commit after I did `pnpm install` using the recommended version of `pnpm`.
Currently, the `_types` is built using `node` module resolution, which results in this project generating invalid types. Details about the TypeScript bug can be found at microsoft/TypeScript#60930 (comment) and there are no plans to fix it since `node` (which is equivalent to `node10`) is being deprecated in TypeScript soon. The way this bug manifests is in files like `src/_types/core/P256.d.ts` where it would previously generate code like:�```ts create: (hash: import("@noble/curves/abstract/utils.js").CHash) => import("@noble/curves/abstract/weierstrass.js").CurveFn; ``` when it should have generated code like this (which is what is generated after this change):�```ts create: (hash: import("@noble/curves/abstract/utils").CHash) => import("@noble/curves/abstract/weierstrass").CurveFn; ``` For the cjs build command, I changed from `node` to `node10` to be more explicit/clear, since `node` was just an alias for `node10`. For the esm build command, I changed it to use the tsconfig so it is less likely to get out of sync with the generated types. Also updated .gitignore to ignore `.pnpm-store` which had 30,000 files it wanted to commit after I did `pnpm install` using the recommended version of `pnpm`.
🔎 Search Terms
declaration js extension named module node10
🕗 Version & Regression Information
⏯ Playground Link
Not possible because repro requires multiple files.
💻 Code
🙁 Actual behavior
The generated
.d.ts
file hasbut this is invalid because there is no named export of
@noble/curves/_shortw_utils.js
. In particular, there.js
suffix should not be added.🙂 Expected behavior
The generated
.d.ts
file doesn't include an extraneous.js
on the dynamic import statement.Additional information about the issue
The reason I think this is a bug and not just some esoteric behavior of
node10
module resolution is that if you do not importother.js
, it correctly emits the following line instead (note the missing.js
extension):Either it is correct with the
.js
extension (a Node10 module resolution thing), or it is correct without the.js
extension, but it doesn't make sense that the presence of an extension would changed based on whether or not a local file was imported.Note: Bug does not reproduce if you import from another package. It only seems to occur if you import from a relative path (which is why there is no playground repro).
The text was updated successfully, but these errors were encountered: