-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Fixed a crash on JSX emit trying to emit unexpectedly recovered BinaryExpression in a JSX attribute
#64470
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Mateusz Burzyński (Andarist)
wants to merge
2
commits into
microsoft:main
Choose a base branch
from
Andarist:fix/jsx-attribute-value-no-sibling-recovery
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Fixed a crash on JSX emit trying to emit unexpectedly recovered BinaryExpression in a JSX attribute
#64470
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
20 changes: 20 additions & 0 deletions
20
...s/reference/compiler/jsxAttributeInitializerMultipleElementsNoCrash(jsx=react).errors.txt
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| jsxAttributeInitializerMultipleElementsNoCrash.tsx(4,11): error TS2657: JSX expressions must have one parent element. | ||
| jsxAttributeInitializerMultipleElementsNoCrash.tsx(4,29): error TS1003: Identifier expected. | ||
| jsxAttributeInitializerMultipleElementsNoCrash.tsx(4,39): error TS1109: Expression expected. | ||
| jsxAttributeInitializerMultipleElementsNoCrash.tsx(4,40): error TS1109: Expression expected. | ||
|
|
||
|
|
||
| ==== jsxAttributeInitializerMultipleElementsNoCrash.tsx (4 errors) ==== | ||
| declare namespace JSX { interface IntrinsicElements { [x: string]: any } } | ||
| declare const React: any; | ||
|
|
||
| const a = <div attr=<span /><span /> />; | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| !!! error TS2657: JSX expressions must have one parent element. | ||
| ~ | ||
| !!! error TS1003: Identifier expected. | ||
| ~ | ||
| !!! error TS1109: Expression expected. | ||
| ~ | ||
| !!! error TS1109: Expression expected. | ||
|
|
12 changes: 12 additions & 0 deletions
12
...baselines/reference/compiler/jsxAttributeInitializerMultipleElementsNoCrash(jsx=react).js
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| //// [tests/cases/compiler/jsxAttributeInitializerMultipleElementsNoCrash.tsx] //// | ||
|
|
||
| //// [jsxAttributeInitializerMultipleElementsNoCrash.tsx] | ||
| declare namespace JSX { interface IntrinsicElements { [x: string]: any } } | ||
| declare const React: any; | ||
|
|
||
| const a = <div attr=<span /><span /> />; | ||
|
|
||
|
|
||
| //// [jsxAttributeInitializerMultipleElementsNoCrash.js] | ||
| "use strict"; | ||
| const a = (React.createElement("div", { attr: React.createElement("span", null) }), React.createElement("span", null)) / > ; |
32 changes: 32 additions & 0 deletions
32
...ference/compiler/jsxAttributeInitializerMultipleElementsNoCrash(jsx=react-jsx).errors.txt
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| jsxAttributeInitializerMultipleElementsNoCrash.tsx(4,11): error TS2875: This JSX tag requires the module path 'react/jsx-runtime' to exist, but none could be found. Make sure you have types for the appropriate package installed. | ||
| jsxAttributeInitializerMultipleElementsNoCrash.tsx(4,11): error TS7026: JSX element implicitly has type 'any' because no interface 'JSX.IntrinsicElements' exists. | ||
| jsxAttributeInitializerMultipleElementsNoCrash.tsx(4,11): error TS2657: JSX expressions must have one parent element. | ||
| jsxAttributeInitializerMultipleElementsNoCrash.tsx(4,21): error TS7026: JSX element implicitly has type 'any' because no interface 'JSX.IntrinsicElements' exists. | ||
| jsxAttributeInitializerMultipleElementsNoCrash.tsx(4,29): error TS1003: Identifier expected. | ||
| jsxAttributeInitializerMultipleElementsNoCrash.tsx(4,29): error TS7026: JSX element implicitly has type 'any' because no interface 'JSX.IntrinsicElements' exists. | ||
| jsxAttributeInitializerMultipleElementsNoCrash.tsx(4,39): error TS1109: Expression expected. | ||
| jsxAttributeInitializerMultipleElementsNoCrash.tsx(4,40): error TS1109: Expression expected. | ||
|
|
||
|
|
||
| ==== jsxAttributeInitializerMultipleElementsNoCrash.tsx (8 errors) ==== | ||
| declare namespace JSX { interface IntrinsicElements { [x: string]: any } } | ||
| declare const React: any; | ||
|
|
||
| const a = <div attr=<span /><span /> />; | ||
| ~~~~~~~~~~~~~~~~~~ | ||
| !!! error TS2875: This JSX tag requires the module path 'react/jsx-runtime' to exist, but none could be found. Make sure you have types for the appropriate package installed. | ||
| ~~~~~~~~~~~~~~~~~~ | ||
| !!! error TS7026: JSX element implicitly has type 'any' because no interface 'JSX.IntrinsicElements' exists. | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| !!! error TS2657: JSX expressions must have one parent element. | ||
| ~~~~~~~~ | ||
| !!! error TS7026: JSX element implicitly has type 'any' because no interface 'JSX.IntrinsicElements' exists. | ||
| ~ | ||
| !!! error TS1003: Identifier expected. | ||
| ~~~~~~~~ | ||
| !!! error TS7026: JSX element implicitly has type 'any' because no interface 'JSX.IntrinsicElements' exists. | ||
| ~ | ||
| !!! error TS1109: Expression expected. | ||
| ~ | ||
| !!! error TS1109: Expression expected. | ||
|
|
12 changes: 12 additions & 0 deletions
12
...lines/reference/compiler/jsxAttributeInitializerMultipleElementsNoCrash(jsx=react-jsx).js
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| //// [tests/cases/compiler/jsxAttributeInitializerMultipleElementsNoCrash.tsx] //// | ||
|
|
||
| //// [jsxAttributeInitializerMultipleElementsNoCrash.tsx] | ||
| declare namespace JSX { interface IntrinsicElements { [x: string]: any } } | ||
| declare const React: any; | ||
|
|
||
| const a = <div attr=<span /><span /> />; | ||
|
|
||
|
|
||
| //// [jsxAttributeInitializerMultipleElementsNoCrash.js] | ||
| import { jsx as _jsx } from "react/jsx-runtime"; | ||
| const a = (_jsx("div", { attr: _jsx("span", {}) }), _jsx("span", {})) / > ; |
17 changes: 13 additions & 4 deletions
17
tsc/testdata/baselines/reference/compiler/jsxAttributeValueBinaryExpression.errors.txt
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,26 @@ | ||
| jsxAttributeValueBinaryExpression.tsx(1,1): error TS2657: JSX expressions must have one parent element. | ||
| jsxAttributeValueBinaryExpression.tsx(1,2): error TS2304: Cannot find name 'X'. | ||
| jsxAttributeValueBinaryExpression.tsx(1,6): error TS7026: JSX element implicitly has type 'any' because no interface 'JSX.IntrinsicElements' exists. | ||
| jsxAttributeValueBinaryExpression.tsx(1,6): error TS2657: JSX expressions must have one parent element. | ||
| jsxAttributeValueBinaryExpression.tsx(1,10): error TS1003: Identifier expected. | ||
| jsxAttributeValueBinaryExpression.tsx(1,10): error TS7026: JSX element implicitly has type 'any' because no interface 'JSX.IntrinsicElements' exists. | ||
| jsxAttributeValueBinaryExpression.tsx(1,16): error TS1109: Expression expected. | ||
| jsxAttributeValueBinaryExpression.tsx(1,17): error TS1109: Expression expected. | ||
|
|
||
|
|
||
| ==== jsxAttributeValueBinaryExpression.tsx (4 errors) ==== | ||
| ==== jsxAttributeValueBinaryExpression.tsx (7 errors) ==== | ||
| <X a=<b/><c/> /> | ||
| ~~~~~~~~~~~~~ | ||
| !!! error TS2657: JSX expressions must have one parent element. | ||
| ~ | ||
| !!! error TS2304: Cannot find name 'X'. | ||
| ~~~~ | ||
| !!! error TS7026: JSX element implicitly has type 'any' because no interface 'JSX.IntrinsicElements' exists. | ||
| ~~~~~~~~ | ||
| !!! error TS2657: JSX expressions must have one parent element. | ||
| ~ | ||
| !!! error TS1003: Identifier expected. | ||
| ~~~~ | ||
| !!! error TS7026: JSX element implicitly has type 'any' because no interface 'JSX.IntrinsicElements' exists. | ||
| ~ | ||
| !!! error TS1109: Expression expected. | ||
|
|
||
| !!! error TS1109: Expression expected. | ||
|
|
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,4 +6,5 @@ | |
|
|
||
| //// [jsxAttributeValueBinaryExpression.jsx] | ||
| "use strict"; | ||
| <X a=<b />, <c />/>; | ||
| (<X a=<b />/>, <c />) / > | ||
| ; | ||
7 changes: 7 additions & 0 deletions
7
tsc/testdata/tests/cases/compiler/jsxAttributeInitializerMultipleElementsNoCrash.tsx
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| // @jsx: react,react-jsx | ||
| // @noTypesAndSymbols: true | ||
|
|
||
| declare namespace JSX { interface IntrinsicElements { [x: string]: any } } | ||
| declare const React: any; | ||
|
|
||
| const a = <div attr=<span /><span /> />; |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's best to handle this here - where the bad data was created. All of the other code just doesn't expect
BinaryExpressionhere given: