Skip to content

Plumb tsconfig importHelpers through to the emitter - #216

Open
gg582 wants to merge 1 commit into
mainfrom
importhelpers-tsconfig-plumbing
Open

gg582 wants to merge 1 commit into
mainfrom
importhelpers-tsconfig-plumbing

Conversation

@gg582

@gg582 gg582 commented Sep 10, 2026

Copy link
Copy Markdown
Member

Summary

The emitter already implements importHelpers end to end (EmitOptions.import_helpers, HelperStyle selection in transform_view, tslib import/require emission in emitter/helpers.rs), but the tsconfig key never reached it: CompilerOptions had no field, so importHelpers: true was silently dropped on both the CLI and worker paths and helpers were always inlined.

This replicates the landed useDefineForClassFields plumbing shape for importHelpers:

  • project.rs: tri-state Option<bool> field, parse arm, accessor, tri-state parse test
  • program.rs: ResolvedProgram carry + accessor
  • emitter.rs: apply_emit_fields accepts import_helpers, set-when-Some
  • pipeline.rs / project/effective.rs: forward on both emit paths
  • check_cells.rs: worker build_tsconfig bool list + camelCase remap, so @importHelpers: true serializes as a typed boolean "importHelpers": true

Verification

  • cargo fmt --all --check
  • cargo check -p bamts-compiler -p bamts-verification
  • cargo test -p bamts-compiler --lib — 2007 passed, 0 failed
  • cargo test -p bamts-verification --lib — 696 passed, 0 failed
  • cargo clippy -p bamts-compiler -p bamts-verification --all-targets -- -D warnings
  • cargo run -p bamts-verification -- diagnostics regenerate --check — PASS
  • CLI end-to-end: es2015/commonjs async fn emits require("tslib").__awaiter with importHelpers: true, and the inline __awaiter body with importHelpers: false

Per repository discipline, conformance-row conversions (the 877 pinned helper-policy rows noted in .outline/GATES.md PLUMBING-RESULTS) are not claimed here; they are measured at the next sweep.

The emitter already implements importHelpers end to end
(EmitOptions.import_helpers, HelperStyle selection in transform_view,
tslib import/require emission in emitter/helpers.rs), but tsconfig had
no CompilerOptions field for it, so the key was silently dropped on
both the CLI and worker paths and helpers were always inlined.

Replicate the landed useDefineForClassFields plumbing shape:

- project.rs: tri-state Option<bool> field, parse arm, accessor,
  tri-state parse test
- program.rs: ResolvedProgram carry and accessor
- emitter.rs: apply_emit_fields takes import_helpers set-when-Some
- pipeline.rs, project/effective.rs: forward on both emit paths
- check_cells.rs: worker build_tsconfig bool list + camelCase remap so
  @importHelpers serializes as a typed boolean "importHelpers" key

Verified: fmt --check, check, bamts-compiler lib 2007/0,
bamts-verification lib 696/0, clippy --all-targets -D warnings,
diagnostics regenerate --check PASS. CLI smoke: es2015 commonjs async
fn emits require("tslib").__awaiter with importHelpers:true and the
inline helper body with importHelpers:false.
@coderabbitai

coderabbitai Bot commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: b6ea44ea-dba3-4fd3-9277-54461c2b9737

📥 Commits

Reviewing files that changed from the base of the PR and between cea70e7 and 1e3c98c.

📒 Files selected for processing (6)
  • crates/bamts-compiler/src/emitter.rs
  • crates/bamts-compiler/src/pipeline.rs
  • crates/bamts-compiler/src/program.rs
  • crates/bamts-compiler/src/project.rs
  • crates/bamts-compiler/src/project/effective.rs
  • crates/bamts-verification/src/check_cells.rs

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.

📜 Recent review details
⏰ Context from checks skipped due to timeout. (9)
  • GitHub Check: Conformance receipt shard 4/4
  • GitHub Check: Conformance receipt shard 2/4
  • GitHub Check: Conformance receipt shard 3/4
  • GitHub Check: Conformance receipt shard 1/4
  • GitHub Check: Corpus
  • GitHub Check: Quality
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Analyze (actions)
  • GitHub Check: Analyze (rust)
🧰 Additional context used
🔍 Remote MCP Context7

Relevant review context

  • importHelpers: true makes TypeScript import helpers from tslib instead of inlining them; tslib must be available at runtime. Global script files do not generate module imports.
  • Without importHelpers, helpers are inlined by default. noEmitHelpers is a separate option that suppresses helper emission and requires user-provided implementations.
  • Missing or outdated tslib produces compiler diagnostics when imported helpers are required, so end-to-end coverage should verify both emitted references and dependency/diagnostic behavior.
🔇 Additional comments (7)
crates/bamts-compiler/src/project.rs (1)

960-960: LGTM!

Also applies to: 1062-1065, 1258-1258, 2600-2623

crates/bamts-compiler/src/program.rs (1)

225-225: LGTM!

Also applies to: 246-249, 725-725

crates/bamts-compiler/src/emitter.rs (1)

213-213: LGTM!

Also applies to: 223-225

crates/bamts-compiler/src/project/effective.rs (1)

726-726: LGTM!

crates/bamts-compiler/src/pipeline.rs (1)

219-219: LGTM!

crates/bamts-verification/src/check_cells.rs (2)

1025-1025: LGTM!

Also applies to: 2497-2497


1001-1001: 🗄️ Data Integrity & Integration

Do not add a tslib fixture for this path.

compile_case_frontend loads the materialized files before emit_checked generates helper imports. ProgramLoader does not resolve those generated imports, so a missing tslib package cannot cause this verification cell to fail.


📝 Summary

Summary by CodeRabbit

  • New Features

    • Added support for the importHelpers compiler option in project configuration.
    • The setting now accepts true or false and is applied during program compilation and output generation.
    • Verification scenarios can now configure and validate importHelpers behavior.
  • Bug Fixes

    • Ensured configured helper-import behavior is consistently forwarded through the compilation pipeline.

Walkthrough

Changes

The compiler now parses the tri-state importHelpers option, stores it on ResolvedProgram, and applies it to emit options. Verification pragmas and source-map baseline emission also forward this setting.

Import helpers option

Layer / File(s) Summary
Parse importHelpers configuration
crates/bamts-compiler/src/project.rs
CompilerOptions parses and exposes importHelpers as Option<bool>. Tests cover true, false, and absent values.
Propagate the setting to emission
crates/bamts-compiler/src/program.rs, crates/bamts-compiler/src/pipeline.rs, crates/bamts-compiler/src/project/effective.rs, crates/bamts-compiler/src/emitter.rs
ResolvedProgram stores the setting. Program and project emission pass it to EmitOptions::apply_emit_fields, which updates self.import_helpers.
Wire verification and baseline emission
crates/bamts-verification/src/check_cells.rs
The importhelpers pragma maps to importHelpers, and source-map baseline emission forwards the resolved setting.

Sequence Diagram(s)

sequenceDiagram
  participant ProjectConfig
  participant CompilerOptions
  participant ResolvedProgram
  participant EmitOptions
  ProjectConfig->>CompilerOptions: Parse importHelpers
  CompilerOptions->>ResolvedProgram: Store import_helpers
  ResolvedProgram->>EmitOptions: Pass import_helpers
  EmitOptions->>EmitOptions: Apply import_helpers
Loading

Merge Risk: ⚪ Minimal · up to 1e3c9

The importHelpers option is propagated through the compiler and verification paths without an identified merge-blocking regression.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title directly describes plumbing the tsconfig importHelpers option through to the emitter. It is clear and specific; although it lacks a Conventional Commits type prefix, the requirement is not s…
Description check ✅ Passed The description clearly explains the importHelpers plumbing, affected compiler and worker paths, behavior changes, verification results, and excluded scope.
Docstring Coverage ✅ Passed Docstring coverage is 81.25% which is sufficient. The required threshold is 70.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 16 functions across 6 files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch importhelpers-tsconfig-plumbing

Warning

source "Github Grep" unavailable: no selected tools are declared read-only by the MCP server


source "Sequential Thinking" unavailable: no selected tools are declared read-only by the MCP server


source "Github Grep" unavailable: no selected tools are declared read-only by the MCP server


source "Sequential Thinking" unavailable: no selected tools are declared read-only by the MCP server


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant