-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix unicode escapes in jsx identifiers and extended unicode character…
…s in jsdoc (#32716) * Fix unicode escapes in jsx identifiers and extended unicode characters in jsdoc * Support unicode escapes in JSDoc * Add tests for extended escapes
- Loading branch information
Showing
20 changed files
with
455 additions
and
13 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
19 changes: 19 additions & 0 deletions
19
tests/baselines/reference/extendedUnicodePlaneIdentifiersJSDoc.js
This file contains 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,19 @@ | ||
//// [file.js] | ||
/** | ||
* Adds | ||
* @param {number} 𝑚 | ||
* @param {number} 𝑀 | ||
*/ | ||
function foo(𝑚, 𝑀) { | ||
console.log(𝑀 + 𝑚); | ||
} | ||
|
||
//// [file.js] | ||
/** | ||
* Adds | ||
* @param {number} 𝑚 | ||
* @param {number} 𝑀 | ||
*/ | ||
function foo(𝑚, 𝑀) { | ||
console.log(𝑀 + 𝑚); | ||
} |
18 changes: 18 additions & 0 deletions
18
tests/baselines/reference/extendedUnicodePlaneIdentifiersJSDoc.symbols
This file contains 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,18 @@ | ||
=== tests/cases/compiler/file.js === | ||
/** | ||
* Adds | ||
* @param {number} 𝑚 | ||
* @param {number} 𝑀 | ||
*/ | ||
function foo(𝑚, 𝑀) { | ||
>foo : Symbol(foo, Decl(file.js, 0, 0)) | ||
>𝑚 : Symbol(𝑚, Decl(file.js, 5, 13)) | ||
>𝑀 : Symbol(𝑀, Decl(file.js, 5, 16)) | ||
|
||
console.log(𝑀 + 𝑚); | ||
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) | ||
>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) | ||
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) | ||
>𝑀 : Symbol(𝑀, Decl(file.js, 5, 16)) | ||
>𝑚 : Symbol(𝑚, Decl(file.js, 5, 13)) | ||
} |
20 changes: 20 additions & 0 deletions
20
tests/baselines/reference/extendedUnicodePlaneIdentifiersJSDoc.types
This file contains 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 @@ | ||
=== tests/cases/compiler/file.js === | ||
/** | ||
* Adds | ||
* @param {number} 𝑚 | ||
* @param {number} 𝑀 | ||
*/ | ||
function foo(𝑚, 𝑀) { | ||
>foo : (𝑚: number, 𝑀: number) => void | ||
>𝑚 : number | ||
>𝑀 : number | ||
|
||
console.log(𝑀 + 𝑚); | ||
>console.log(𝑀 + 𝑚) : void | ||
>console.log : (message?: any, ...optionalParams: any[]) => void | ||
>console : Console | ||
>log : (message?: any, ...optionalParams: any[]) => void | ||
>𝑀 + 𝑚 : number | ||
>𝑀 : number | ||
>𝑚 : number | ||
} |
This file contains 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,33 @@ | ||
//// [file.js] | ||
/** | ||
* @param {number} \u0061 | ||
* @param {number} a\u0061 | ||
*/ | ||
function foo(a, aa) { | ||
console.log(a + aa); | ||
} | ||
|
||
/** | ||
* @param {number} \u{0061} | ||
* @param {number} a\u{0061} | ||
*/ | ||
function bar(a, aa) { | ||
console.log(a + aa); | ||
} | ||
|
||
|
||
//// [file.js] | ||
/** | ||
* @param {number} \u0061 | ||
* @param {number} a\u0061 | ||
*/ | ||
function foo(a, aa) { | ||
console.log(a + aa); | ||
} | ||
/** | ||
* @param {number} \u{0061} | ||
* @param {number} a\u{0061} | ||
*/ | ||
function bar(a, aa) { | ||
console.log(a + aa); | ||
} |
This file contains 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,35 @@ | ||
=== tests/cases/compiler/file.js === | ||
/** | ||
* @param {number} \u0061 | ||
* @param {number} a\u0061 | ||
*/ | ||
function foo(a, aa) { | ||
>foo : Symbol(foo, Decl(file.js, 0, 0)) | ||
>a : Symbol(a, Decl(file.js, 4, 13)) | ||
>aa : Symbol(aa, Decl(file.js, 4, 15)) | ||
|
||
console.log(a + aa); | ||
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) | ||
>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) | ||
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) | ||
>a : Symbol(a, Decl(file.js, 4, 13)) | ||
>aa : Symbol(aa, Decl(file.js, 4, 15)) | ||
} | ||
|
||
/** | ||
* @param {number} \u{0061} | ||
* @param {number} a\u{0061} | ||
*/ | ||
function bar(a, aa) { | ||
>bar : Symbol(bar, Decl(file.js, 6, 1)) | ||
>a : Symbol(a, Decl(file.js, 12, 13)) | ||
>aa : Symbol(aa, Decl(file.js, 12, 15)) | ||
|
||
console.log(a + aa); | ||
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) | ||
>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) | ||
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) | ||
>a : Symbol(a, Decl(file.js, 12, 13)) | ||
>aa : Symbol(aa, Decl(file.js, 12, 15)) | ||
} | ||
|
This file contains 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,39 @@ | ||
=== tests/cases/compiler/file.js === | ||
/** | ||
* @param {number} \u0061 | ||
* @param {number} a\u0061 | ||
*/ | ||
function foo(a, aa) { | ||
>foo : (a: number, aa: number) => void | ||
>a : number | ||
>aa : number | ||
|
||
console.log(a + aa); | ||
>console.log(a + aa) : void | ||
>console.log : (message?: any, ...optionalParams: any[]) => void | ||
>console : Console | ||
>log : (message?: any, ...optionalParams: any[]) => void | ||
>a + aa : number | ||
>a : number | ||
>aa : number | ||
} | ||
|
||
/** | ||
* @param {number} \u{0061} | ||
* @param {number} a\u{0061} | ||
*/ | ||
function bar(a, aa) { | ||
>bar : (a: number, aa: number) => void | ||
>a : number | ||
>aa : number | ||
|
||
console.log(a + aa); | ||
>console.log(a + aa) : void | ||
>console.log : (message?: any, ...optionalParams: any[]) => void | ||
>console : Console | ||
>log : (message?: any, ...optionalParams: any[]) => void | ||
>a + aa : number | ||
>a : number | ||
>aa : number | ||
} | ||
|
This file contains 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,34 @@ | ||
//// [file.tsx] | ||
import * as React from "react"; | ||
declare global { | ||
namespace JSX { | ||
interface IntrinsicElements { | ||
"a-b": any; | ||
"a-c": any; | ||
} | ||
} | ||
} | ||
const Compa = (x: {x: number}) => <div>{"" + x}</div>; | ||
|
||
let a = <\u0061></a>; // works | ||
let ab = <\u0061-b></a-b>; // works | ||
let ac = <a-\u0063></a-c>; // works | ||
let compa = <Comp\u0061 x={12} />; // works | ||
|
||
let a2 = <\u{0061}></a>; // works | ||
let ab2 = <\u{0061}-b></a-b>; // works | ||
let ac2 = <a-\u{0063}></a-c>; // works | ||
let compa2 = <Comp\u{0061} x={12} />; // works | ||
|
||
|
||
//// [file.js] | ||
import * as React from "react"; | ||
const Compa = (x) => React.createElement("div", null, "" + x); | ||
let a = React.createElement("a", null); // works | ||
let ab = React.createElement("a-b", null); // works | ||
let ac = React.createElement("a-c", null); // works | ||
let compa = React.createElement(Comp\u0061, { x: 12 }); // works | ||
let a2 = React.createElement("a", null); // works | ||
let ab2 = React.createElement("a-b", null); // works | ||
let ac2 = React.createElement("a-c", null); // works | ||
let compa2 = React.createElement(Comp\u{0061}, { x: 12 }); // works |
Oops, something went wrong.