Skip to content

bug: npm run build fails with TS5055 due to stale dist artifacts #4447

@wenshao

Description

@wenshao

bug: npm run build fails with TS5055 due to stale dist artifacts

Description

npm run build fails with numerous error TS5055: Cannot write file '...' because it would overwrite input file. errors in packages/core. This occurs when packages/core/dist/ contains stale .d.ts files from a previous build.

Root Cause

scripts/build_package.js runs tsc --build without first cleaning the output directory. When dist/ contains leftover .d.ts files, TypeScript's incremental/composite build treats them as input files (since they reside within the project tree), causing a conflict with the intended output path.

Steps to Reproduce

  1. Run npm run build successfully once.
  2. Make changes or switch branches.
  3. Run npm run build again → TS5055 errors.

Workaround

rm -rf packages/core/dist packages/core/tsconfig.tsbuildinfo
npm run build

Suggested Fix

Add a clean step to scripts/build_package.js before tsc --build:

import { rmSync } from 'node:fs';
rmSync('dist', { recursive: true, force: true });
rmSync('tsconfig.tsbuildinfo', { force: true });

Environment

  • Node.js v22
  • macOS (darwin)

Metadata

Metadata

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions