Skip to content

fix(tsrx): control flow expressions & text#2

Merged
LuLaValva merged 1 commit into
mainfrom
control-flow-fixes
Apr 30, 2026
Merged

fix(tsrx): control flow expressions & text#2
LuLaValva merged 1 commit into
mainfrom
control-flow-fixes

Conversation

@LuLaValva

@LuLaValva LuLaValva commented Apr 30, 2026

Copy link
Copy Markdown
Member

This example had two issues:

export default component Count() {
  let count = 0;

  <button onClick={() => {
    count++;
  }}>{count}</button>

  if (count > 5) {
    {"Large value"}
  }
}
  1. The transformer didn't treat the if expression as an attribute, so even though it has > it wasn't being wrapped in parentheses
  2. Text expressions do need to be prefixed with -- at the root level because of concise mode, but not in control flow tags

@LuLaValva LuLaValva merged commit 26b76ea into main Apr 30, 2026
3 checks passed
@coderabbitai

coderabbitai Bot commented Apr 30, 2026

Copy link
Copy Markdown

Caution

Review failed

Pull request was closed or merged during review

Walkthrough

The transform.ts file is refactored to standardize expression and statement rendering across control-flow helpers. The #emitIf, #emitForOf, and #emitSwitch functions now use #attrValue() instead of #slice() for condition/test expressions, while body emission switches to a new #blockStmts() helper. The #block helper is updated to emit block bodies via #blockStmts() and single statements via #child(). Additionally, a test fixture is added for a Count component that demonstrates state management, event handling, and conditional rendering.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix(tsrx): control flow expressions & text' directly refers to the main changes: fixes to control flow expression handling and text expression formatting in the tsrx transformer.
Description check ✅ Passed The description clearly explains the two specific issues being fixed with code examples and technical context about concise mode and parentheses wrapping.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch control-flow-fixes

Review rate limit: 4/5 reviews remaining, refill in 12 minutes.

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

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