andywer / andywer/threads.js

Package is not compatible with NodeJS ESM

Đang mở
#496 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
TypeScript
Star
3.5k
Fork
173
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

The package exporting types for ESM incorrectly https://arethetypeswrong.github.io/?p=threads%401.7.0

Image

That causes problems on the ESM projects with Typescript:

>
> TS7016: Could not find a declaration file for module threads.
> /Users/timofei.Iatsenko/Projects/js-lingui/node_modules/threads/index.mjs
> implicitly has an any type.
> There are types at
> /Users/timofei.Iatsenko/Projects/js-lingui/node_modules/threads/dist/index.d.ts
> , but this result could not be resolved when respecting package.json exports. The threads library may need to update its package.json or typings.

Basically for every module type cjs / esm, there should be own version of typings

"./dist/index.cjs"
"./dist/index.d.cts"

"./dist/index.mjs"
"./dist/index.d.mts"

More explanation is provided here https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/FalseCJS.md#common-causes

Currently `exports` field does not provide typings for ESM at all:

```ts
{
".": {
"require": "./dist/index.js",
"types": "./dist/index.d.ts",
"default": "./index.mjs"
},
"./observable": {
"require": "./observable.js",
"types": "./observable.d.ts",
"default": "./observable.mjs"
},
"./register": {
"require": "./register.js",
"types": "./register.d.ts",
"default": "./register.mjs"
},
"./worker": {
"require": "./worker.js",
"types": "./worker.d.ts",
"default": "./worker.mjs"
}
}
```

Note that just using the same `d.ts` file for the `mjs` target will not fix issue correctly, because it will masquerade ESM behind the CJS (read the article i provided above)

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.