ReviewOS

home-lang/home

TS CLI: checker ignores target and JSX overrides honored by emitter

#756
Closed chris opened this 11 days ago ·
11 days ago

Problem

home-tsc parses --target and --jsx well enough for the emitter, but the checker does not see the same resolved command-line options. It reports diagnostics that contradict the generated JavaScript and exits 1.

Reproduced on current main (332fa5e81) with a freshly built home-tsc.

--target

class Box { #value = 1; read() { return this.#value; } }
$ home-tsc --ignoreConfig input.ts --target es2022 --outDir out
input.ts:1:13 - error TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher.

The emitted file correctly retains the ES2022 private field:

class Box {
  #value = 1;
  read() {
    return this.#value;
  }
}

--jsx

const element = <span />;
$ home-tsc --ignoreConfig input.tsx --jsx react --outDir out
input.tsx:1:17 - error TS17004: Cannot use JSX unless the '--jsx' flag is provided.

The emitted file correctly uses the requested React transform:

const element = React.createElement("span", null);

Both commands exit 1 despite honoring the options during emit. This makes valid CLI builds fail and shows that checker and emitter option state diverge.

Acceptance

  • Resolve CLI and tsconfig options once and pass the same effective target/JSX settings to parsing, checking, and emission.
  • --target es2015 and newer permit private identifiers without TS18028; older targets retain the intended diagnostic behavior.
  • a supported --jsx mode permits JSX without TS17004 and produces the selected transform.
  • CLI overrides retain the documented precedence over tsconfig values.
  • Add CLI-level regression coverage that checks diagnostics, exit status, and emitted output together.

No-workaround boundary

Do not suppress TS18028/TS17004 at the CLI or infer validity from emitted text. Fix propagation of the resolved compiler options so all compiler phases use one coherent configuration.

11 days ago

Implemented on main in a140090f1 (fix(ts-cli): propagate target and jsx overrides).

The CLI and tsconfig paths now share the same target/JSX mappers, so syntax checks and emit receive one effective configuration and explicit CLI values retain precedence.

Validation:

  • focused ts_cli and ts_driver suites pass
  • --target es2022: exit 0, native #value emitted, no TS18028
  • --target es5: exit 1 with TS18028 retained
  • valid TSX with --jsx react: exit 0, React.createElement emitted, no TS17004
  • project config target: es2015 / jsx: preserve overridden by CLI es2022 / react: exit 0 with native private field and React JSX transform

Sign in to comment on this issue.