Skip to content

fix(js/ts): Fix JSX props with long string values causing compile error (fixes #3839)#4545

Merged
MangelMaxime merged 2 commits intomainfrom
repo-assist/fix-issue-3839-jsx-long-string-prop-v2-65ee641ca3e6335d
Apr 21, 2026
Merged

fix(js/ts): Fix JSX props with long string values causing compile error (fixes #3839)#4545
MangelMaxime merged 2 commits intomainfrom
repo-assist/fix-issue-3839-jsx-long-string-prop-v2-65ee641ca3e6335d

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

🤖 This is a draft PR from Repo Assist, an automated AI assistant.

Closes #3839

Root Cause

When a JSX prop's string value exceeds ~100 characters, Fable optimises the Fable AST by hoisting the string into a Let binding. The resulting expression changes from:

Value(NewTuple([StringConst "className"; StringConst "aaaa...long..."], ...), ...)
```

to:

```
Let(x, StringConst "aaaa...long...", Value(NewTuple([StringConst "className"; IdentExpr x], ...), ...))

The transformJsxProps function in Fable2Babel.fs only matched the direct MaybeCasted(Value(NewTuple([key; value], ...), ...)) pattern. When the string was Let-wrapped, no arm matched and the fallthrough addError fired with "Cannot detect JSX prop key at compile time".

Fix

Added a new match arm in transformJsxProps that handles MaybeCasted(Let(_, letValue, Value(NewTuple([key; _], ...), ...))). In this pattern:

  • letValue is the actual long string value (what was bound)
  • key is the prop name, extracted from inside the Let body's tuple
  • the _ inside the tuple is the IdentExpr reference to the Let-bound variable (not needed)

The fix correctly uses letValue as the prop value, exactly as if the string had been written inline.

Test

Added divWithLongClassName to the JSX integration test in Components.fs with a string of 98 'a' characters (above the ~100-char threshold), and the corresponding expected output to Components.jsx.expected.

Trade-offs

  • Minimal change: only Fable2Babel.fs (the JS/TS code generator) is modified
  • No other targets are affected
  • The children prop with a long string value is also handled correctly in the new arm

Generated by 🌈 Repo Assist, see workflow run. Learn more.

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@8f2d44f5d624e31c4af7cdbd948c6f5eba875a85

@github-actions github-actions Bot added automation Automated changes repo-assist Created by Repo Assist labels Apr 19, 2026
)

When a JSX prop's string value exceeds ~100 characters, Fable wraps it in a
Let binding. The transformJsxProps function only matched the direct
Value(NewTuple([key; value])) pattern, causing a 'Cannot detect JSX prop key
at compile time' error for any string longer than the threshold.

Fix: add a match arm for MaybeCasted(Let(_, letValue, Value(NewTuple(...)))) to
extract the key from the tuple body and use the Let-bound value as the prop value.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

chore: revert CHANGELOG.md
@MangelMaxime MangelMaxime force-pushed the repo-assist/fix-issue-3839-jsx-long-string-prop-v2-65ee641ca3e6335d branch from 7b98fdb to 0e97261 Compare April 21, 2026 20:39
@MangelMaxime MangelMaxime marked this pull request as ready for review April 21, 2026 20:39
@MangelMaxime MangelMaxime changed the title [Repo Assist] [JS/TS] Fix JSX props with long string values causing compile error (fixes #3839) fix(js/ts): Fix JSX props with long string values causing compile error (fixes #3839) Apr 21, 2026
@MangelMaxime MangelMaxime merged commit d828a46 into main Apr 21, 2026
31 checks passed
@MangelMaxime MangelMaxime deleted the repo-assist/fix-issue-3839-jsx-long-string-prop-v2-65ee641ca3e6335d branch April 21, 2026 20:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automation Automated changes repo-assist Created by Repo Assist

Projects

None yet

Development

Successfully merging this pull request may close these issues.

transformJsxProps errors on large strings

1 participant