Skip to content

JSX: h is the default factory (the default library's where the program has none); no "failed statement" after an error - #1124

Merged
ASDAlexander77 merged 1 commit into
mainfrom
jsx-default-factory
Dec 3, 2026
Merged

ASDAlexander77 merged 1 commit into
mainfrom
jsx-default-factory

Conversation

@ASDAlexander77

Copy link
Copy Markdown
Owner

Needs DefaultLib ASDAlexander77/TypeScriptCompilerDefaultLib#133 (__jsx_h, JsxElement, __jsx_Fragment).

User ruling: h comes with the default library and is the default factory, so tslang file.tsx runs with no flags. It makes a JsxElement that prints as HTML.

  • With no factory named, an element calls h and a fragment's tag is Fragment. tsc's React.createElement / React.Fragment are used only when named. Where the program declares no h / Fragment, the call goes to the library's __jsx_h / __jsx_Fragment. This is decided again on every pass, so a program's h declared after the element still wins. --jsx-factory=h with no h declared also uses the library's
  • -mm=own: the library's factory gives one clear error at the element. A typed factory of the program's own still works there
  • The "factory can't be found" error is shorter
  • MLIRGenModule: "failed statement" is now reported only when the statement failed without an error of its own. Before, it followed every error and said nothing more
  • Tests: jsx-options (default h/Fragment, and exactly one error with no "failed statement"), 00jsx_default_factory now uses the program's own h, crash-errors name h, and the new defaultlib/jsx_default_factory.tsx runs against the real default library (gc and rc, JIT and exe; skipped when no library is built)
  • docs/jsx.md and whats-new

Local: Release ctest, 10424/10424 passed (with the DefaultLib branch built).

🤖 Generated with Claude Code

…ram has none; no "failed statement" after an error

- With no factory named (@jsx, --jsx-factory, "jsxFactory"), an element calls `h` and a fragment's tag is
  `Fragment` (user ruling; tsc's React.createElement / React.Fragment only when named). Where the program
  declares no `h` / `Fragment`, they are the default library's __jsx_h / __jsx_Fragment, asked again on
  every pass so a program's `h` declared after the element still wins. So `tslang file.tsx` runs, and
  `--jsx-factory=h` with no `h` declared too
- -mm=own: the library's factory is one clear error at the element (an element keeps its children)
- The "factory can't be found" error is shorter, and still names `h` when there is no library
- MLIRGenModule: "failed statement" is reported only when the statement failed without an error of
  its own (it followed every error, saying nothing more)
- Tests: jsx-options (the default `h`/`Fragment`, one error with no "failed statement"),
  00jsx_default_factory uses the program's own `h`, crash-errors name `h`, and
  defaultlib/jsx_default_factory.tsx runs against the real default library (gc, rc; jit and exe)
- docs/jsx.md: the library's `h`, components, what an element prints

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ASDAlexander77
ASDAlexander77 merged commit 0646729 into main Dec 3, 2026
8 checks passed
@ASDAlexander77
ASDAlexander77 deleted the jsx-default-factory branch December 3, 2026 19:02
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