From 6200cf2686715602c3bf59b5adde69b244bb0e90 Mon Sep 17 00:00:00 2001 From: 10Derozan Date: Thu, 30 Nov 2023 14:16:24 +0800 Subject: [PATCH] fix(module-tools): add -b param to tsc when user add references (#5013) --- .changeset/proud-gifts-love.md | 6 ++++++ .../module-tools/src/builder/dts/tsc.ts | 16 +++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 .changeset/proud-gifts-love.md diff --git a/.changeset/proud-gifts-love.md b/.changeset/proud-gifts-love.md new file mode 100644 index 000000000000..18b2707ed656 --- /dev/null +++ b/.changeset/proud-gifts-love.md @@ -0,0 +1,6 @@ +--- +'@modern-js/module-tools': patch +--- + +fix(module-tools): add -b param to tsc when user add references to avoid error ts6305 +fix(module-tools): 用户使用 references 时给 tsc 添加 -b 参数来避免 TS6305 错误 diff --git a/packages/solutions/module-tools/src/builder/dts/tsc.ts b/packages/solutions/module-tools/src/builder/dts/tsc.ts index 0679bd597f8f..2d7941bb6744 100644 --- a/packages/solutions/module-tools/src/builder/dts/tsc.ts +++ b/packages/solutions/module-tools/src/builder/dts/tsc.ts @@ -65,11 +65,21 @@ const runTscBin = async ( ) => { const { appDirectory, watch = false, abortOnError = true } = config; - const { tempTsconfigPath } = info; + const { tempTsconfigPath, userTsconfig } = info; const tscBinFile = await getTscBinPath(appDirectory); - const watchParams = watch ? ['-w'] : []; + const params: string[] = []; + + if (watch) { + params.push('-w'); + } + + // avoid error TS6305 + if (userTsconfig.references) { + params.push('-b'); + } + const childProgress = execa( tscBinFile, [ @@ -79,7 +89,7 @@ const runTscBin = async ( '--pretty', // https://github.com/microsoft/TypeScript/issues/21824 '--preserveWatchOutput', - ...watchParams, + ...params, ], { stdio: 'pipe',