Skip to content

Codegen: typecheck failure prevents file emission; consider emit-then-validate #144

Description

@hardbyte

Problem

When TS codegen is invoked with `typecheck: true`, `tsc` runs inside `typescript::generate()` after the source is built but before it's returned. If tsc fails for any reason (including environmental failures like missing `node_modules` in a fresh worktree), the generated source is discarded and the CLI exits non-zero.

In a multi-language build script (`reflectapi codegen --language typescript && reflectapi codegen --language python`), this means a transient TS env issue blocks Python emission entirely. Reported by an internal consumer who hit this on a fresh worktree.

Suggested fix

Two options:

  1. Emit-then-validate: write the generated file first, then run `tsc --noEmit` against it. tsc failure becomes a non-zero exit but the file is still on disk for downstream tooling.
  2. Multi-language CLI mode: `reflectapi codegen --language typescript,python` accumulates per-language errors and exits at the end. Simpler for orchestration but doesn't help users invoking once-per-language.

(1) is the smaller change; (2) is a nicer DX add-on.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions