error TS2742: The inferred type of 'default' cannot be named without a reference
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 35/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- rollup, typescript
- 領域
- build-system, tooling
調査の方向性
src/runtime/plugin.ts と playground/app.config.ts の再現から始め、その後 playground/node_modules/myPackage/dist にある生成された宣言を調べます。pnpm prepack を実行して TS2742 を再現し、失敗する宣言と Params = string; を使用するバリアントを比較します。モジュールが移植性のない推論型エラーなしでビルドできれば完了です。
索引モデルが issue の本文から書いたものです。
説明
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 };
- 主要言語
- TypeScript
- スター
- 276
- フォーク
- 35
- 平均マージ
- 2時間 46分
- マージ済み PR(30日)
- 2
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
nuxt/module-builder のほかの issue
-
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
nuxt/module-builder#801 ·
-
enhancement
難易度 3/5 1〜2日 初心者へのやさしさ 48/100
nuxt/module-builder#764 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
nuxt/module-builder#754 ·
-
Conflict between folder structure in readme (src/runtime) and TypeScript config (src/module/runtime)対応中かも @dword-design が 143 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 45/100
nuxt/module-builder#749 ·
-
Tsdown/obuild migration再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープン
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
nuxt/module-builder#726 · コメント 1 件 · リアクション 1 件 ·
nuxt/module-builder の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
awesome-dsh-plugin/awesome-dsh-plugin#9184 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
farion1231/cc-switch#8829 ·
メンテナーはふだん 1 日以内に返信
-
[core-client] Remove unused hand-maintained transport helpers after the definition-table cutoverオープンdoc-audit enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100