Skip to content

TS5055 regression with checkJs: true #359

Description

@gtbuchanan

Description

The fix for #220 (adding emitDeclarationOnly: true) was applied in getDeclarationFiles but not in compileDts. This means the second ts.createProgram call in compileDts still hits TS5055 when checkJs: true is enabled.

Reproduction

https://github.com/gtbuchanan/dts-bundle-generator-repro-5055

pnpm install
node repro.js

Expected

entry.ts is bundled successfully.

Actual

error TS5055: Cannot write file 'lib.mjs' because it would overwrite input file.

Analysis

In compile-dts.js, compileDts removes outDir (line 28) and sets declaration: true (line 33), but does not set emitDeclarationOnly: true. It then calls getDeclarationFiles, which creates its own program with emitDeclarationOnly: true (line 136) — that program works fine. But afterwards, compileDts creates a second program (line 79) using the original compilerOptions (without emitDeclarationOnly), and checkProgramDiagnosticsErrors on line 80 reports TS5055.

The fix from #220 / #221 needs to also be applied to the compilerOptions in compileDts, not just in getDeclarationFiles.

Versions

  • dts-bundle-generator: 9.5.1
  • TypeScript: 5.9.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions