error TS2742: The inferred type of 'default' cannot be named without a reference
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- rollup, typescript
- Lĩnh vực
- build-system, tooling
Hướng nghiên cứu
Bắt đầu với src/runtime/plugin.ts và bản tái hiện trong playground/app.config.ts, sau đó kiểm tra các khai báo được tạo trong playground/node_modules/myPackage/dist. Chạy pnpm prepack để tái hiện TS2742 và so sánh khai báo bị lỗi với biến thể sử dụng Params = string; hoàn tất khi module được build mà không có lỗi kiểu suy luận không portable.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Im trying to pnpm prepack a nuxt3 module with a package which exports a simple object and its types file.
1 - In the playground/node_modules/myPackage/dist
index.d.ts :
type Params = string[];
declare const endpoints: {
abc: (q: Params) => string;
};
export { Params, endpoints as default };
index.js :
// src/index.ts
var endpoints = {
abc: (q) => "test"
};
var src_default = endpoints;
export {
src_default as default
};
2 - In the playground/app.config.ts
import endpoints from "myPackage";
export default {
endpoints
};
3 - In the module, src/runtime/plugin.ts :
import { defineNuxtPlugin, useAppConfig } from "#imports";
export default defineNuxtPlugin(() => {
return {
provide: {
backend: useAppConfig().endpoints,
},
};
});
Then, i run pnpm prepack and i always have this error :
ℹ Building my-module 12:16:16 PM
src/runtime/plugin.ts(3,1): error TS2742: The inferred type of 'default' cannot be named without a reference to '../../playground/node_modules/@aurionsarl/auberdog-pension-api/dist'. This is likely not portable. A type annotation is necessary.
src/runtime/plugin.ts(3,1): error TS2742: The inferred type of 'default' cannot be named without a reference to '../../playground/node_modules/@aurionsarl/auberdog-pension-api/dist'. This is likely not portable. A type annotation is necessary.
Error [RollupError]: Failed to compile. Check the logs above.
at error (file:///home/tony/projects/testmodule/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:2245:30)
at Object.error (file:///home/tony/projects/testmodule/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:25139:20)
at Object.error (file:///home/tony/projects/testmodule/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:24262:42)
at generateDtsFromTs (file:///home/tony/projects/testmodule/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/rollup-plugin-dts/dist/rollup-plugin-dts.mjs:1697:30)
at Object.transform (file:///home/tony/projects/testmodule/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/rollup-plugin-dts/dist/rollup-plugin-dts.mjs:1706:38)
at file:///home/tony/projects/testmodule/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:25332:40
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
id: '/home/tony/projects/testmodule/src/module.ts',
hook: 'resolveId',
code: 'PLUGIN_ERROR',
plugin: 'commonjs--resolver',
watchFiles: [
'/home/tony/projects/testmodule/src/module.ts',
'/home/tony/projects/testmodule/src/runtime/plugin.ts'
]
}
ELIFECYCLE Command failed with exit code 1.
And the error disappears if i replace the code in the playground/node_modules/myPackage/dist by this one :
type Params = string; // replace string[] to string
declare const endpoints: {
abc: (q: Params) => string;
};
export { Params, endpoints as default };
- Ngôn ngữ chính
- TypeScript
- Star
- 277
- Fork
- 36
- Merge trung bình
- 4 ngày 19 giờ
- Pull request đã merge (30 ngày)
- 3
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của nuxt/module-builder
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
nuxt/module-builder#801 ·
-
enhancement
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 48/100
nuxt/module-builder#764 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
nuxt/module-builder#754 ·
-
Conflict between folder structure in readme (src/runtime) and TypeScript config (src/module/runtime)Có thể đã có người làm @dword-design đã nhận 136 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 45/100
nuxt/module-builder#749 ·
-
Tsdown/obuild migrationCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
nuxt/module-builder#726 · 1 bình luận · 1 reaction ·
Tất cả issue của nuxt/module-builder
Issue tương tự
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 65/100
521xueweihan/HelloGitHub#4025 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
voidzero-dev/void#478 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 69/100
Small-tailqwq/dsh-deep-whale#207 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
The inspector never shows the instances field, so scaling out is unreachableCó thể đã có người làm @Mrkewl đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
xevrion/breakscale#96 ·
Maintainer thường phản hồi trong vòng 4 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Flux159/mcp-server-kubernetes#384 ·