fix(build): clean dist directory before tsc build to prevent TS5055

When building multiple times consecutively, `tsc` would sometimes treat the previously generated `.d.ts` files in `dist/` as inputs, leading to the TS5055 overwrite error. Clearing the `dist` directory at the start of the build script ensures a clean slate and fixes this CI failure.
This commit is contained in:
Sandy Tao
2026-01-15 14:03:27 +08:00
parent 0663076afb
commit 549c732d78
+4 -1
View File
@@ -18,7 +18,7 @@
// limitations under the License.
import { execSync } from 'node:child_process';
import { writeFileSync, existsSync, cpSync } from 'node:fs';
import { writeFileSync, existsSync, cpSync, rmSync } from 'node:fs';
import { join, basename } from 'node:path';
if (!process.cwd().includes('packages')) {
@@ -28,6 +28,9 @@ if (!process.cwd().includes('packages')) {
const packageName = basename(process.cwd());
// Clean the dist directory to prevent TS5055 overwrite errors during consecutive builds
rmSync(join(process.cwd(), 'dist'), { recursive: true, force: true });
// build typescript files
execSync('tsc --build', { stdio: 'inherit' });