[bug]: typescript errors when building with pnpm

Đang mở
#41 11 bình luận 2 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 6 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
65/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
node.js, typescript
Lĩnh vực
build-system, cli, devtools

Hướng nghiên cứu

Reproduce the issue by creating a plugin with init and running pnpm run build. Inspect TypeScript definition generation around server/src/controllers/index.ts, server/src/index.ts, and server/src/services/index.ts, along with the @strapi/pack-up entry point. Done means a newly initialized plugin builds successfully without TS2742 errors.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

issue: bug severity: medium source: sdk-plugin
What version of @strapi/sdk-plugin are you using?

@strapi/sdk-plugin 5.1.0
pnpm 9.1.0

What's Wrong?

Building a plugin with pnpm doesn't work

➜  myplugin5 pnpm run build

> [email protected] build /Users/ben/dev/strapi/myplugin5
> strapi-plugin build

✔ Verified package.json
✔ Created build context
Building type files:
   entries:
    – myplugin5/admin/src/index.ts ./admin/src/index.ts -> ./dist/admin/src/index.d.ts
    – myplugin5/server/src/index.ts ./server/src/index.ts -> ./dist/server/src/index.d.ts
[ERROR]  server/src/controllers/index.ts:3:1 - TS2742: The inferred type of 'default' cannot be named without a reference to '.pnpm/@[email protected]_@[email protected][email protected]/node_modules/@strapi/types/dist/core'. This is likely not portable. A type annotation is necessary.
[ERROR]  server/src/index.ts:19:1 - TS2742: The inferred type of 'default' cannot be named without a reference to '.pnpm/@[email protected]_@[email protected][email protected]/node_modules/@strapi/types/dist/core'. This is likely not portable. A type annotation is necessary.
[ERROR]  server/src/services/index.ts:3:1 - TS2742: The inferred type of 'default' cannot be named without a reference to '.pnpm/@[email protected]_@[email protected][email protected]/node_modules/@strapi/types/dist/core'. This is likely not portable. A type annotation is necessary.
[ERROR]  server/src/controllers/index.ts:3:1 - TS2742: The inferred type of 'default' cannot be named without a reference to '.pnpm/@[email protected]_@[email protected][email protected]/node_modules/@strapi/types/dist/core'. This is likely not portable. A type annotation is necessary.
[ERROR]  server/src/services/index.ts:3:1 - TS2742: The inferred type of 'default' cannot be named without a reference to '.pnpm/@[email protected]_@[email protected][email protected]/node_modules/@strapi/types/dist/core'. This is likely not portable. A type annotation is necessary.
[ERROR]  server/src/index.ts:19:1 - TS2742: The inferred type of 'default' cannot be named without a reference to '.pnpm/@[email protected]_@[email protected][email protected]/node_modules/@strapi/types/dist/core'. This is likely not portable. A type annotation is necessary.
[ERROR]  server/src/index.ts:19:1 - TS2742: The inferred type of 'default' cannot be named without a reference to '.pnpm/@[email protected]_@[email protected][email protected]/node_modules/@strapi/types/dist/core'. This is likely not portable. A type annotation is necessary.
[ERROR]  server/src/index.ts:19:1 - TS2742: The inferred type of 'default' cannot be named without a reference to '.pnpm/@[email protected]_@[email protected][email protected]/node_modules/@strapi/types/dist/core'. This is likely not portable. A type annotation is necessary.
[ERROR]  server/src/index.ts:19:1 - TS2742: The inferred type of 'default' cannot be named without a reference to '.pnpm/@[email protected]_@[email protected][email protected]/node_modules/@strapi/types/dist/core'. This is likely not portable. A type annotation is necessary.
[ERROR]  server/src/index.ts:19:1 - TS2742: The inferred type of 'default' cannot be named without a reference to '.pnpm/@[email protected]_@[email protected][email protected]/node_modules/@strapi/types/dist/core'. This is likely not portable. A type annotation is necessary.
[ERROR]  Failed to compile TypeScript definitions
[ERROR] There seems to be an unexpected error, try again with --debug for more information 

 ┌────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│                                                                                                                                                                                                                            │
│   Error: Failed to compile TypeScript definitions                                                                                                                                                                          │
│       at /Users/ben/dev/strapi/myplugin5/node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected][email protected]/node_modules/@strapi/pack-up/dist/index.js:835:19                           │
│       at Array.map (<anonymous>)                                                                                                                                                                                           │
│       at Observable._subscribe (/Users/ben/dev/strapi/myplugin5/node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected][email protected]/node_modules/@strapi/pack-up/dist/index.js:813:22)   │
│       at Observable._trySubscribe (/Users/ben/dev/strapi/myplugin5/node_modules/.pnpm/[email protected]/node_modules/rxjs/dist/cjs/internal/Observable.js:41:25)                                                                  │
│       at /Users/ben/dev/strapi/myplugin5/node_modules/.pnpm/[email protected]/node_modules/rxjs/dist/cjs/internal/Observable.js:35:31                                                                                             │
│       at Object.errorContext (/Users/ben/dev/strapi/myplugin5/node_modules/.pnpm/[email protected]/node_modules/rxjs/dist/cjs/internal/util/errorContext.js:22:9)                                                                 │
│       at Observable.subscribe (/Users/ben/dev/strapi/myplugin5/node_modules/.pnpm/[email protected]/node_modules/rxjs/dist/cjs/internal/Observable.js:26:24)                                                                      │
│       at /Users/ben/dev/strapi/myplugin5/node_modules/.pnpm/[email protected]/node_modules/rxjs/dist/cjs/internal/Observable.js:86:19                                                                                             │
│       at new Promise (<anonymous>)                                                                                                                                                                                         │
│       at Observable.toPromise (/Users/ben/dev/strapi/myplugin5/node_modules/.pnpm/[email protected]/node_modules/rxjs/dist/cjs/internal/Observable.js:84:16)                                                                      │
│                                                                                                                                                                                                                            │
└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
To Reproduce

create a new plugin with init

then run pnpm run build

Expected Behaviour

plugin should build

Ngôn ngữ chính
TypeScript
Star
24
Fork
13
Merge trung bình
5 ngày 3 giờ
Pull request đã merge (30 ngày)
5

Chuẩn bị môi trường

  • Không có Dockerfile hay tệp Docker Compose
  • Có mẫu pull request
  • Không có hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của strapi/sdk-plugin

Tất cả issue của strapi/sdk-plugin

Issue tương tự

Thêm issue về TypeScript

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.