-
Notifications
You must be signed in to change notification settings - Fork 716
Fix broken unicode escape sequence in JSX text #1754
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
Merged
jakebailey
merged 3 commits into
main
from
copilot/fix-401ef11a-03e3-494a-ab79-3dd7dd5acd07
Sep 30, 2025
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
56 changes: 56 additions & 0 deletions
56
testdata/baselines/reference/compiler/jsxUnicodeEscapeSequence.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,56 @@ | ||
jsxUnicodeEscapeSequence.tsx(3,12): error TS7026: JSX element implicitly has type 'any' because no interface 'JSX.IntrinsicElements' exists. | ||
jsxUnicodeEscapeSequence.tsx(3,12): 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. | ||
jsxUnicodeEscapeSequence.tsx(3,17): error TS7026: JSX element implicitly has type 'any' because no interface 'JSX.IntrinsicElements' exists. | ||
jsxUnicodeEscapeSequence.tsx(3,39): error TS7026: JSX element implicitly has type 'any' because no interface 'JSX.IntrinsicElements' exists. | ||
jsxUnicodeEscapeSequence.tsx(3,46): error TS7026: JSX element implicitly has type 'any' because no interface 'JSX.IntrinsicElements' exists. | ||
jsxUnicodeEscapeSequence.tsx(8,13): error TS7026: JSX element implicitly has type 'any' because no interface 'JSX.IntrinsicElements' exists. | ||
jsxUnicodeEscapeSequence.tsx(8,18): error TS7026: JSX element implicitly has type 'any' because no interface 'JSX.IntrinsicElements' exists. | ||
jsxUnicodeEscapeSequence.tsx(8,25): error TS7026: JSX element implicitly has type 'any' because no interface 'JSX.IntrinsicElements' exists. | ||
jsxUnicodeEscapeSequence.tsx(10,5): error TS7026: JSX element implicitly has type 'any' because no interface 'JSX.IntrinsicElements' exists. | ||
jsxUnicodeEscapeSequence.tsx(15,13): error TS7026: JSX element implicitly has type 'any' because no interface 'JSX.IntrinsicElements' exists. | ||
jsxUnicodeEscapeSequence.tsx(19,5): error TS7026: JSX element implicitly has type 'any' because no interface 'JSX.IntrinsicElements' exists. | ||
|
||
|
||
==== jsxUnicodeEscapeSequence.tsx (11 errors) ==== | ||
export const InlineUnicodeChar = () => { | ||
// This should work correctly - inline character with other content | ||
return <div><span>Warning: ⚠ Error</span></div>; | ||
~~~~~ | ||
!!! error TS7026: JSX element implicitly has type 'any' because no interface 'JSX.IntrinsicElements' exists. | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
!!! 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 TS7026: JSX element implicitly has type 'any' because no interface 'JSX.IntrinsicElements' exists. | ||
~~~~~~ | ||
!!! error TS7026: JSX element implicitly has type 'any' because no interface 'JSX.IntrinsicElements' exists. | ||
}; | ||
|
||
export const StandaloneUnicodeChar = () => { | ||
// This should reproduce the issue - unicode character on its own line | ||
return (<div><span>⚠</span> | ||
~~~~~ | ||
!!! error TS7026: JSX element implicitly has type 'any' because no interface 'JSX.IntrinsicElements' exists. | ||
~~~~~~ | ||
!!! error TS7026: JSX element implicitly has type 'any' because no interface 'JSX.IntrinsicElements' exists. | ||
~~~~~~~ | ||
!!! error TS7026: JSX element implicitly has type 'any' because no interface 'JSX.IntrinsicElements' exists. | ||
⚠ | ||
</div>); | ||
~~~~~~ | ||
!!! error TS7026: JSX element implicitly has type 'any' because no interface 'JSX.IntrinsicElements' exists. | ||
}; | ||
|
||
export const MultipleUnicodeChars = () => { | ||
// Test multiple unicode characters | ||
return (<div> | ||
~~~~~ | ||
!!! error TS7026: JSX element implicitly has type 'any' because no interface 'JSX.IntrinsicElements' exists. | ||
⚠ | ||
⛔ | ||
🚨 | ||
</div>); | ||
~~~~~~ | ||
!!! error TS7026: JSX element implicitly has type 'any' because no interface 'JSX.IntrinsicElements' exists. | ||
}; |
38 changes: 38 additions & 0 deletions
38
testdata/baselines/reference/compiler/jsxUnicodeEscapeSequence.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,38 @@ | ||
//// [tests/cases/compiler/jsxUnicodeEscapeSequence.tsx] //// | ||
|
||
//// [jsxUnicodeEscapeSequence.tsx] | ||
export const InlineUnicodeChar = () => { | ||
// This should work correctly - inline character with other content | ||
return <div><span>Warning: ⚠ Error</span></div>; | ||
}; | ||
|
||
export const StandaloneUnicodeChar = () => { | ||
// This should reproduce the issue - unicode character on its own line | ||
return (<div><span>⚠</span> | ||
⚠ | ||
</div>); | ||
}; | ||
|
||
export const MultipleUnicodeChars = () => { | ||
// Test multiple unicode characters | ||
return (<div> | ||
⚠ | ||
⛔ | ||
🚨 | ||
</div>); | ||
}; | ||
|
||
//// [jsxUnicodeEscapeSequence.js] | ||
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; | ||
export const InlineUnicodeChar = () => { | ||
// This should work correctly - inline character with other content | ||
return _jsx("div", { children: _jsx("span", { children: "Warning: \u26A0 Error" }) }); | ||
}; | ||
export const StandaloneUnicodeChar = () => { | ||
// This should reproduce the issue - unicode character on its own line | ||
return (_jsxs("div", { children: [_jsx("span", { children: "\u26A0" }), "\u26A0"] })); | ||
}; | ||
export const MultipleUnicodeChars = () => { | ||
// Test multiple unicode characters | ||
return (_jsx("div", { children: "\u26A0 \u26D4 \uD83D\uDEA8" })); | ||
}; |
29 changes: 29 additions & 0 deletions
29
testdata/baselines/reference/compiler/jsxUnicodeEscapeSequence.symbols
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,29 @@ | ||
//// [tests/cases/compiler/jsxUnicodeEscapeSequence.tsx] //// | ||
|
||
=== jsxUnicodeEscapeSequence.tsx === | ||
export const InlineUnicodeChar = () => { | ||
>InlineUnicodeChar : Symbol(InlineUnicodeChar, Decl(jsxUnicodeEscapeSequence.tsx, 0, 12)) | ||
|
||
// This should work correctly - inline character with other content | ||
return <div><span>Warning: ⚠ Error</span></div>; | ||
}; | ||
|
||
export const StandaloneUnicodeChar = () => { | ||
>StandaloneUnicodeChar : Symbol(StandaloneUnicodeChar, Decl(jsxUnicodeEscapeSequence.tsx, 5, 12)) | ||
|
||
// This should reproduce the issue - unicode character on its own line | ||
return (<div><span>⚠</span> | ||
⚠ | ||
</div>); | ||
}; | ||
|
||
export const MultipleUnicodeChars = () => { | ||
>MultipleUnicodeChars : Symbol(MultipleUnicodeChars, Decl(jsxUnicodeEscapeSequence.tsx, 12, 12)) | ||
|
||
// Test multiple unicode characters | ||
return (<div> | ||
⚠ | ||
⛔ | ||
🚨 | ||
</div>); | ||
}; |
54 changes: 54 additions & 0 deletions
54
testdata/baselines/reference/compiler/jsxUnicodeEscapeSequence.types
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,54 @@ | ||
//// [tests/cases/compiler/jsxUnicodeEscapeSequence.tsx] //// | ||
|
||
=== jsxUnicodeEscapeSequence.tsx === | ||
export const InlineUnicodeChar = () => { | ||
>InlineUnicodeChar : () => any | ||
>() => { // This should work correctly - inline character with other content return <div><span>Warning: ⚠ Error</span></div>;} : () => any | ||
|
||
// This should work correctly - inline character with other content | ||
return <div><span>Warning: ⚠ Error</span></div>; | ||
><div><span>Warning: ⚠ Error</span></div> : any | ||
>div : any | ||
><span>Warning: ⚠ Error</span> : any | ||
>span : any | ||
>span : any | ||
>div : any | ||
|
||
}; | ||
|
||
export const StandaloneUnicodeChar = () => { | ||
>StandaloneUnicodeChar : () => any | ||
>() => { // This should reproduce the issue - unicode character on its own line return (<div><span>⚠</span> ⚠ </div>);} : () => any | ||
|
||
// This should reproduce the issue - unicode character on its own line | ||
return (<div><span>⚠</span> | ||
>(<div><span>⚠</span> ⚠ </div>) : any | ||
><div><span>⚠</span> ⚠ </div> : any | ||
>div : any | ||
><span>⚠</span> : any | ||
>span : any | ||
>span : any | ||
|
||
⚠ | ||
</div>); | ||
>div : any | ||
|
||
}; | ||
|
||
export const MultipleUnicodeChars = () => { | ||
>MultipleUnicodeChars : () => any | ||
>() => { // Test multiple unicode characters return (<div> ⚠ ⛔ 🚨 </div>);} : () => any | ||
|
||
// Test multiple unicode characters | ||
return (<div> | ||
>(<div> ⚠ ⛔ 🚨 </div>) : any | ||
><div> ⚠ ⛔ 🚨 </div> : any | ||
>div : any | ||
|
||
⚠ | ||
⛔ | ||
🚨 | ||
</div>); | ||
>div : any | ||
|
||
}; |
31 changes: 31 additions & 0 deletions
31
testdata/tests/cases/compiler/jsxUnicodeEscapeSequence.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,31 @@ | ||
// @target: esnext | ||
// @module: preserve | ||
// @moduleResolution: bundler | ||
// @jsx: react-jsx | ||
// @strict: true | ||
|
||
// Test for unicode escape sequence issue in JSX | ||
// The warning symbol (⚠, U+26A0) should be correctly encoded as \u26A0, not \uFFFD | ||
|
||
// @filename: jsxUnicodeEscapeSequence.tsx | ||
|
||
export const InlineUnicodeChar = () => { | ||
// This should work correctly - inline character with other content | ||
return <div><span>Warning: ⚠ Error</span></div>; | ||
}; | ||
|
||
export const StandaloneUnicodeChar = () => { | ||
// This should reproduce the issue - unicode character on its own line | ||
return (<div><span>⚠</span> | ||
⚠ | ||
</div>); | ||
}; | ||
|
||
export const MultipleUnicodeChars = () => { | ||
// Test multiple unicode characters | ||
return (<div> | ||
⚠ | ||
⛔ | ||
🚨 | ||
</div>); | ||
}; |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.