Repository navigation
Pass undefined for jsxDEV self inside super arguments - #65539
Closed
Josué Barros (joshbarros) wants to merge 2 commits into
Closed
Josué Barros (joshbarros) wants to merge 2 commits into
Josué Barros (joshbarros) wants to merge 2 commits into
Conversation
Member
|
If you're willing, this would be much easier to review if it were two commits, one that adds the test and baselines showing bad behavior, then one commit with the fix and baseline update showing it works. |
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The super-call flag mishandles nested classes and independent this scopes, causing a pre-super ReferenceError in one case and incorrect JSX __self values in others.
2 open issues
What changed in this PR
Addresses #65415 by changing the JSX development transform to avoid accessing this when JSX is evaluated inside super() arguments.
Changes:
- Tracks traversal inside
super()calls and emitsvoid 0for thejsxDEVself argument. - Adds a derived-constructor regression test with a local JSX runtime declaration and expected baselines.
| File | Description |
|---|---|
tsc/testdata/tests/cases/compiler/jsxDevSelfInSuperArguments.tsx |
Adds the JSX-in-super() regression case. |
tsc/testdata/baselines/reference/compiler/jsxDevSelfInSuperArguments.types |
Records expected type information. |
tsc/testdata/baselines/reference/compiler/jsxDevSelfInSuperArguments.symbols |
Records expected symbol bindings. |
tsc/testdata/baselines/reference/compiler/jsxDevSelfInSuperArguments.js |
Records emitted jsxDEV with void 0 as self. |
tsc/internal/transformers/jsxtransforms/jsx.go |
Tracks super-call context and adjusts development JSX emission. |
Review effort: Balanced
added 2 commits
November 16, 2026 16:23
The test covers JSX in a super call, in a method inside the super arguments, and in a nested class expression. The baselines show the current behavior, which passes this before super() returns.
A super call's arguments are evaluated before this is available. Track that context and pass void 0 for __self, while restoring the enclosing state around nested super calls and resetting it in functions, methods and class bodies that have their own this.
Josué Barros (joshbarros)
force-pushed
the
fix/65415-jsxdev-self-before-super
branch
from
November 16, 2026 19:24
eb2885b to
ca757d3
Compare
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Fixes #65415
The
react-jsxdevtransform always passedthisas the__selfargument. In a derived constructor, JSX in the arguments ofsuper()is evaluated beforethisis available, so the emitted code threwReferenceError: Must call super constructor ... before accessing 'this'at runtime.This tracks when the JSX visitor is inside a
super()call and passesvoid 0for__selfthere.The new compiler test uses a local
jsx-dev-runtimeand the report's derived constructor. On the unfixed compiler the emitted__selfisthis; with the change it isvoid 0.Validation:
go test ./tsc/internal/testrunner -run TestLocal/jsxDevSelfInSuperArguments -count=1: fails without the change, passes with it.go test ./tsc/internal/testrunner -run TestLocal -count=1: pass (full compiler suite).gofmt: clean.Drafted with assistance from an AI assistant. I reviewed the diff and ran the tests above.