From 873a0782b9f879acc30a0360ec13c24103f637cd Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 10 Nov 2026 17:50:02 +0000 Subject: [PATCH 1/7] Initial plan From 4eac33b38746c0b231b0b0b1289bb3311a80c4f8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 10 Nov 2026 17:56:19 +0000 Subject: [PATCH 2/7] Add test for JSX tag and attribute names starting with '#' Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com> --- ...sStartingWithHash(jsx=preserve).errors.txt | 38 +++++++ .../jsxNamesStartingWithHash(jsx=preserve).js | 39 +++++++ ...amesStartingWithHash(jsx=preserve).symbols | 77 ++++++++++++++ ...xNamesStartingWithHash(jsx=preserve).types | 100 ++++++++++++++++++ ...amesStartingWithHash(jsx=react).errors.txt | 38 +++++++ .../jsxNamesStartingWithHash(jsx=react).js | 39 +++++++ ...sxNamesStartingWithHash(jsx=react).symbols | 77 ++++++++++++++ .../jsxNamesStartingWithHash(jsx=react).types | 100 ++++++++++++++++++ .../compiler/jsxNamesStartingWithHash.tsx | 23 ++++ 9 files changed, 531 insertions(+) create mode 100644 tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=preserve).errors.txt create mode 100644 tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=preserve).js create mode 100644 tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=preserve).symbols create mode 100644 tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=preserve).types create mode 100644 tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=react).errors.txt create mode 100644 tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=react).js create mode 100644 tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=react).symbols create mode 100644 tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=react).types create mode 100644 tsc/testdata/tests/cases/compiler/jsxNamesStartingWithHash.tsx diff --git a/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=preserve).errors.txt b/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=preserve).errors.txt new file mode 100644 index 0000000000000..c320d6062ab74 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=preserve).errors.txt @@ -0,0 +1,38 @@ +jsxNamesStartingWithHash.tsx(9,12): error TS2304: Cannot find name '#a'. +jsxNamesStartingWithHash.tsx(9,17): error TS2304: Cannot find name '#a'. +jsxNamesStartingWithHash.tsx(14,16): error TS1003: Identifier expected. +jsxNamesStartingWithHash.tsx(19,17): error TS2322: Type '{ "#x": number; x: number; }' is not assignable to type '{ x: number; }'. + Property '#x' does not exist on type '{ x: number; }'. + + +==== jsxNamesStartingWithHash.tsx (4 errors) ==== + declare const React: any; + declare namespace JSX { + interface IntrinsicElements { + [name: string]: any; + } + } + declare function Comp(props: { x: number }): any; + + const a = <#a>; + ~~ +!!! error TS2304: Cannot find name '#a'. + ~~ +!!! error TS2304: Cannot find name '#a'. + const b =
; + const c =
; + const d =
; + const e = ; + const f = ; + +!!! error TS1003: Identifier expected. + const g = <#h:i />; + const h =
; + const i = <#l-m>; + const j =
; + const k = ; + ~~ +!!! error TS2322: Type '{ "#x": number; x: number; }' is not assignable to type '{ x: number; }'. +!!! error TS2322: Property '#x' does not exist on type '{ x: number; }'. + const l =
; + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=preserve).js b/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=preserve).js new file mode 100644 index 0000000000000..e4e7761c155c2 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=preserve).js @@ -0,0 +1,39 @@ +//// [tests/cases/compiler/jsxNamesStartingWithHash.tsx] //// + +//// [jsxNamesStartingWithHash.tsx] +declare const React: any; +declare namespace JSX { + interface IntrinsicElements { + [name: string]: any; + } +} +declare function Comp(props: { x: number }): any; + +const a = <#a>; +const b =
; +const c =
; +const d =
; +const e = ; +const f = ; +const g = <#h:i />; +const h =
; +const i = <#l-m>; +const j =
; +const k = ; +const l =
; + + +//// [jsxNamesStartingWithHash.jsx] +"use strict"; +const a = <#a>; +const b =
; +const c =
; +const d =
; +const e = ; +const f = ; +const g = <#h:i />; +const h =
; +const i = <#l-m>; +const j =
; +const k = ; +const l =
; diff --git a/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=preserve).symbols b/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=preserve).symbols new file mode 100644 index 0000000000000..4e76ad35e6a89 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=preserve).symbols @@ -0,0 +1,77 @@ +//// [tests/cases/compiler/jsxNamesStartingWithHash.tsx] //// + +=== jsxNamesStartingWithHash.tsx === +declare const React: any; +>React : Symbol(React, Decl(jsxNamesStartingWithHash.tsx, 0, 13)) + +declare namespace JSX { +>JSX : Symbol(JSX, Decl(jsxNamesStartingWithHash.tsx, 0, 25)) + + interface IntrinsicElements { +>IntrinsicElements : Symbol(IntrinsicElements, Decl(jsxNamesStartingWithHash.tsx, 1, 23)) + + [name: string]: any; +>name : Symbol(name, Decl(jsxNamesStartingWithHash.tsx, 3, 9)) + } +} +declare function Comp(props: { x: number }): any; +>Comp : Symbol(Comp, Decl(jsxNamesStartingWithHash.tsx, 5, 1)) +>props : Symbol(props, Decl(jsxNamesStartingWithHash.tsx, 6, 22)) +>x : Symbol(x, Decl(jsxNamesStartingWithHash.tsx, 6, 30)) + +const a = <#a>; +>a : Symbol(a, Decl(jsxNamesStartingWithHash.tsx, 8, 5)) + +const b =
; +>b : Symbol(b, Decl(jsxNamesStartingWithHash.tsx, 9, 5)) +>div : Symbol(JSX.IntrinsicElements.__index, Decl(jsxNamesStartingWithHash.tsx, 2, 33)) +>#b : Symbol(#b, Decl(jsxNamesStartingWithHash.tsx, 9, 14)) + +const c =
; +>c : Symbol(c, Decl(jsxNamesStartingWithHash.tsx, 10, 5)) +>div : Symbol(JSX.IntrinsicElements.__index, Decl(jsxNamesStartingWithHash.tsx, 2, 33)) +>#c : Symbol(#c, Decl(jsxNamesStartingWithHash.tsx, 10, 14)) + +const d =
; +>d : Symbol(d, Decl(jsxNamesStartingWithHash.tsx, 11, 5)) +>div : Symbol(JSX.IntrinsicElements.__index, Decl(jsxNamesStartingWithHash.tsx, 2, 33)) +>#d:e : Symbol(#d:e, Decl(jsxNamesStartingWithHash.tsx, 11, 14)) + +const e = ; +>e : Symbol(e, Decl(jsxNamesStartingWithHash.tsx, 12, 5)) + +const f = ; +>f : Symbol(f, Decl(jsxNamesStartingWithHash.tsx, 13, 5)) +>a : Symbol(a, Decl(jsxNamesStartingWithHash.tsx, 8, 5)) + +const g = <#h:i />; +>g : Symbol(g, Decl(jsxNamesStartingWithHash.tsx, 14, 5)) + +const h =
; +>h : Symbol(h, Decl(jsxNamesStartingWithHash.tsx, 15, 5)) +>div : Symbol(JSX.IntrinsicElements.__index, Decl(jsxNamesStartingWithHash.tsx, 2, 33)) +>j:#k : Symbol(j:#k, Decl(jsxNamesStartingWithHash.tsx, 15, 14)) + +const i = <#l-m>; +>i : Symbol(i, Decl(jsxNamesStartingWithHash.tsx, 16, 5)) +>#l-m : Symbol(JSX.IntrinsicElements.__index, Decl(jsxNamesStartingWithHash.tsx, 2, 33)) +>#l-m : Symbol(JSX.IntrinsicElements.__index, Decl(jsxNamesStartingWithHash.tsx, 2, 33)) + +const j =
; +>j : Symbol(j, Decl(jsxNamesStartingWithHash.tsx, 17, 5)) +>div : Symbol(JSX.IntrinsicElements.__index, Decl(jsxNamesStartingWithHash.tsx, 2, 33)) +>#n-o : Symbol(#n-o, Decl(jsxNamesStartingWithHash.tsx, 17, 14)) + +const k = ; +>k : Symbol(k, Decl(jsxNamesStartingWithHash.tsx, 18, 5)) +>Comp : Symbol(Comp, Decl(jsxNamesStartingWithHash.tsx, 5, 1)) +>#x : Symbol(#x, Decl(jsxNamesStartingWithHash.tsx, 18, 15)) +>x : Symbol(x, Decl(jsxNamesStartingWithHash.tsx, 18, 22)) + +const l =
; +>l : Symbol(l, Decl(jsxNamesStartingWithHash.tsx, 19, 5)) +>div : Symbol(JSX.IntrinsicElements.__index, Decl(jsxNamesStartingWithHash.tsx, 2, 33)) +>#p : Symbol(#p, Decl(jsxNamesStartingWithHash.tsx, 19, 14)) +>#q : Symbol(#q, Decl(jsxNamesStartingWithHash.tsx, 19, 17)) +>r : Symbol(r, Decl(jsxNamesStartingWithHash.tsx, 19, 23)) + diff --git a/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=preserve).types b/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=preserve).types new file mode 100644 index 0000000000000..a48f2571f57ca --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=preserve).types @@ -0,0 +1,100 @@ +//// [tests/cases/compiler/jsxNamesStartingWithHash.tsx] //// + +=== jsxNamesStartingWithHash.tsx === +declare const React: any; +>React : any + +declare namespace JSX { + interface IntrinsicElements { + [name: string]: any; +>name : string + } +} +declare function Comp(props: { x: number }): any; +>Comp : (props: { x: number; }) => any +>props : { x: number; } +>x : number + +const a = <#a>; +>a : any +><#a> : any +>#a : any +>#a : any + +const b =
; +>b : any +>
: any +>div : any +>#b : true + +const c =
; +>c : any +>
: any +>div : any +>#c : string + +const d =
; +>d : any +>
: any +>div : any +>#d:e : true +>#d : any +>e : any + +const e = ; +>e : any +> : any +>a : any +>#f : any + +const f = ; +>f : any +> : any +>a.#g : any +>a : any +> : any + +const g = <#h:i />; +>g : any +><#h:i /> : any +>#h : any +>i : any + +const h =
; +>h : any +>
: any +>div : any +>j:#k : true +>j : any +>#k : any + +const i = <#l-m>; +>i : any +><#l-m> : any +>#l-m : any +>#l-m : any + +const j =
; +>j : any +>
: any +>div : any +>#n-o : number +>1 : 1 + +const k = ; +>k : any +> : any +>Comp : (props: { x: number; }) => any +>#x : number +>1 : 1 +>x : number +>1 : 1 + +const l =
; +>l : any +>
: any +>div : any +>#p : true +>#q : string +>r : string + diff --git a/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=react).errors.txt b/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=react).errors.txt new file mode 100644 index 0000000000000..c320d6062ab74 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=react).errors.txt @@ -0,0 +1,38 @@ +jsxNamesStartingWithHash.tsx(9,12): error TS2304: Cannot find name '#a'. +jsxNamesStartingWithHash.tsx(9,17): error TS2304: Cannot find name '#a'. +jsxNamesStartingWithHash.tsx(14,16): error TS1003: Identifier expected. +jsxNamesStartingWithHash.tsx(19,17): error TS2322: Type '{ "#x": number; x: number; }' is not assignable to type '{ x: number; }'. + Property '#x' does not exist on type '{ x: number; }'. + + +==== jsxNamesStartingWithHash.tsx (4 errors) ==== + declare const React: any; + declare namespace JSX { + interface IntrinsicElements { + [name: string]: any; + } + } + declare function Comp(props: { x: number }): any; + + const a = <#a>; + ~~ +!!! error TS2304: Cannot find name '#a'. + ~~ +!!! error TS2304: Cannot find name '#a'. + const b =
; + const c =
; + const d =
; + const e = ; + const f = ; + +!!! error TS1003: Identifier expected. + const g = <#h:i />; + const h =
; + const i = <#l-m>; + const j =
; + const k = ; + ~~ +!!! error TS2322: Type '{ "#x": number; x: number; }' is not assignable to type '{ x: number; }'. +!!! error TS2322: Property '#x' does not exist on type '{ x: number; }'. + const l =
; + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=react).js b/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=react).js new file mode 100644 index 0000000000000..15476799e0dd2 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=react).js @@ -0,0 +1,39 @@ +//// [tests/cases/compiler/jsxNamesStartingWithHash.tsx] //// + +//// [jsxNamesStartingWithHash.tsx] +declare const React: any; +declare namespace JSX { + interface IntrinsicElements { + [name: string]: any; + } +} +declare function Comp(props: { x: number }): any; + +const a = <#a>; +const b =
; +const c =
; +const d =
; +const e = ; +const f = ; +const g = <#h:i />; +const h =
; +const i = <#l-m>; +const j =
; +const k = ; +const l =
; + + +//// [jsxNamesStartingWithHash.js] +"use strict"; +const a = React.createElement(#a, null); +const b = React.createElement("div", { "#b": true }); +const c = React.createElement("div", { "#c": "" }); +const d = React.createElement("div", { "#d:e": true }); +const e = React.createElement("a:#f", null); +const f = React.createElement(a., null); +const g = React.createElement("#h:i", null); +const h = React.createElement("div", { "j:#k": true }); +const i = React.createElement("#l-m", null); +const j = React.createElement("div", { "#n-o": 1 }); +const k = React.createElement(Comp, { "#x": 1, x: 1 }); +const l = React.createElement("div", { "#p": true, "#q": "", r: "" }); diff --git a/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=react).symbols b/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=react).symbols new file mode 100644 index 0000000000000..4e76ad35e6a89 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=react).symbols @@ -0,0 +1,77 @@ +//// [tests/cases/compiler/jsxNamesStartingWithHash.tsx] //// + +=== jsxNamesStartingWithHash.tsx === +declare const React: any; +>React : Symbol(React, Decl(jsxNamesStartingWithHash.tsx, 0, 13)) + +declare namespace JSX { +>JSX : Symbol(JSX, Decl(jsxNamesStartingWithHash.tsx, 0, 25)) + + interface IntrinsicElements { +>IntrinsicElements : Symbol(IntrinsicElements, Decl(jsxNamesStartingWithHash.tsx, 1, 23)) + + [name: string]: any; +>name : Symbol(name, Decl(jsxNamesStartingWithHash.tsx, 3, 9)) + } +} +declare function Comp(props: { x: number }): any; +>Comp : Symbol(Comp, Decl(jsxNamesStartingWithHash.tsx, 5, 1)) +>props : Symbol(props, Decl(jsxNamesStartingWithHash.tsx, 6, 22)) +>x : Symbol(x, Decl(jsxNamesStartingWithHash.tsx, 6, 30)) + +const a = <#a>; +>a : Symbol(a, Decl(jsxNamesStartingWithHash.tsx, 8, 5)) + +const b =
; +>b : Symbol(b, Decl(jsxNamesStartingWithHash.tsx, 9, 5)) +>div : Symbol(JSX.IntrinsicElements.__index, Decl(jsxNamesStartingWithHash.tsx, 2, 33)) +>#b : Symbol(#b, Decl(jsxNamesStartingWithHash.tsx, 9, 14)) + +const c =
; +>c : Symbol(c, Decl(jsxNamesStartingWithHash.tsx, 10, 5)) +>div : Symbol(JSX.IntrinsicElements.__index, Decl(jsxNamesStartingWithHash.tsx, 2, 33)) +>#c : Symbol(#c, Decl(jsxNamesStartingWithHash.tsx, 10, 14)) + +const d =
; +>d : Symbol(d, Decl(jsxNamesStartingWithHash.tsx, 11, 5)) +>div : Symbol(JSX.IntrinsicElements.__index, Decl(jsxNamesStartingWithHash.tsx, 2, 33)) +>#d:e : Symbol(#d:e, Decl(jsxNamesStartingWithHash.tsx, 11, 14)) + +const e = ; +>e : Symbol(e, Decl(jsxNamesStartingWithHash.tsx, 12, 5)) + +const f = ; +>f : Symbol(f, Decl(jsxNamesStartingWithHash.tsx, 13, 5)) +>a : Symbol(a, Decl(jsxNamesStartingWithHash.tsx, 8, 5)) + +const g = <#h:i />; +>g : Symbol(g, Decl(jsxNamesStartingWithHash.tsx, 14, 5)) + +const h =
; +>h : Symbol(h, Decl(jsxNamesStartingWithHash.tsx, 15, 5)) +>div : Symbol(JSX.IntrinsicElements.__index, Decl(jsxNamesStartingWithHash.tsx, 2, 33)) +>j:#k : Symbol(j:#k, Decl(jsxNamesStartingWithHash.tsx, 15, 14)) + +const i = <#l-m>; +>i : Symbol(i, Decl(jsxNamesStartingWithHash.tsx, 16, 5)) +>#l-m : Symbol(JSX.IntrinsicElements.__index, Decl(jsxNamesStartingWithHash.tsx, 2, 33)) +>#l-m : Symbol(JSX.IntrinsicElements.__index, Decl(jsxNamesStartingWithHash.tsx, 2, 33)) + +const j =
; +>j : Symbol(j, Decl(jsxNamesStartingWithHash.tsx, 17, 5)) +>div : Symbol(JSX.IntrinsicElements.__index, Decl(jsxNamesStartingWithHash.tsx, 2, 33)) +>#n-o : Symbol(#n-o, Decl(jsxNamesStartingWithHash.tsx, 17, 14)) + +const k = ; +>k : Symbol(k, Decl(jsxNamesStartingWithHash.tsx, 18, 5)) +>Comp : Symbol(Comp, Decl(jsxNamesStartingWithHash.tsx, 5, 1)) +>#x : Symbol(#x, Decl(jsxNamesStartingWithHash.tsx, 18, 15)) +>x : Symbol(x, Decl(jsxNamesStartingWithHash.tsx, 18, 22)) + +const l =
; +>l : Symbol(l, Decl(jsxNamesStartingWithHash.tsx, 19, 5)) +>div : Symbol(JSX.IntrinsicElements.__index, Decl(jsxNamesStartingWithHash.tsx, 2, 33)) +>#p : Symbol(#p, Decl(jsxNamesStartingWithHash.tsx, 19, 14)) +>#q : Symbol(#q, Decl(jsxNamesStartingWithHash.tsx, 19, 17)) +>r : Symbol(r, Decl(jsxNamesStartingWithHash.tsx, 19, 23)) + diff --git a/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=react).types b/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=react).types new file mode 100644 index 0000000000000..a48f2571f57ca --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=react).types @@ -0,0 +1,100 @@ +//// [tests/cases/compiler/jsxNamesStartingWithHash.tsx] //// + +=== jsxNamesStartingWithHash.tsx === +declare const React: any; +>React : any + +declare namespace JSX { + interface IntrinsicElements { + [name: string]: any; +>name : string + } +} +declare function Comp(props: { x: number }): any; +>Comp : (props: { x: number; }) => any +>props : { x: number; } +>x : number + +const a = <#a>; +>a : any +><#a> : any +>#a : any +>#a : any + +const b =
; +>b : any +>
: any +>div : any +>#b : true + +const c =
; +>c : any +>
: any +>div : any +>#c : string + +const d =
; +>d : any +>
: any +>div : any +>#d:e : true +>#d : any +>e : any + +const e = ; +>e : any +> : any +>a : any +>#f : any + +const f = ; +>f : any +> : any +>a.#g : any +>a : any +> : any + +const g = <#h:i />; +>g : any +><#h:i /> : any +>#h : any +>i : any + +const h =
; +>h : any +>
: any +>div : any +>j:#k : true +>j : any +>#k : any + +const i = <#l-m>; +>i : any +><#l-m> : any +>#l-m : any +>#l-m : any + +const j =
; +>j : any +>
: any +>div : any +>#n-o : number +>1 : 1 + +const k = ; +>k : any +> : any +>Comp : (props: { x: number; }) => any +>#x : number +>1 : 1 +>x : number +>1 : 1 + +const l =
; +>l : any +>
: any +>div : any +>#p : true +>#q : string +>r : string + diff --git a/tsc/testdata/tests/cases/compiler/jsxNamesStartingWithHash.tsx b/tsc/testdata/tests/cases/compiler/jsxNamesStartingWithHash.tsx new file mode 100644 index 0000000000000..2da54ea89e42e --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/jsxNamesStartingWithHash.tsx @@ -0,0 +1,23 @@ +// @target: esnext +// @jsx: preserve,react + +declare const React: any; +declare namespace JSX { + interface IntrinsicElements { + [name: string]: any; + } +} +declare function Comp(props: { x: number }): any; + +const a = <#a>; +const b =
; +const c =
; +const d =
; +const e = ; +const f = ; +const g = <#h:i />; +const h =
; +const i = <#l-m>; +const j =
; +const k = ; +const l =
; From 266fdff5c99025a61e0ff97d22ee194cacdcd804 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 10 Nov 2026 18:04:39 +0000 Subject: [PATCH 3/7] Refine '#' JSX name test cases (baselines still show pre-fix behavior) Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com> --- ...sStartingWithHash(jsx=preserve).errors.txt | 24 ++++---- .../jsxNamesStartingWithHash(jsx=preserve).js | 9 ++- ...amesStartingWithHash(jsx=preserve).symbols | 55 ++++++++----------- ...xNamesStartingWithHash(jsx=preserve).types | 20 ++----- ...amesStartingWithHash(jsx=react).errors.txt | 24 ++++---- .../jsxNamesStartingWithHash(jsx=react).js | 9 ++- ...sxNamesStartingWithHash(jsx=react).symbols | 55 ++++++++----------- .../jsxNamesStartingWithHash(jsx=react).types | 20 ++----- .../compiler/jsxNamesStartingWithHash.tsx | 5 +- 9 files changed, 94 insertions(+), 127 deletions(-) diff --git a/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=preserve).errors.txt b/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=preserve).errors.txt index c320d6062ab74..dd1215402aebd 100644 --- a/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=preserve).errors.txt +++ b/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=preserve).errors.txt @@ -1,18 +1,17 @@ -jsxNamesStartingWithHash.tsx(9,12): error TS2304: Cannot find name '#a'. -jsxNamesStartingWithHash.tsx(9,17): error TS2304: Cannot find name '#a'. -jsxNamesStartingWithHash.tsx(14,16): error TS1003: Identifier expected. -jsxNamesStartingWithHash.tsx(19,17): error TS2322: Type '{ "#x": number; x: number; }' is not assignable to type '{ x: number; }'. - Property '#x' does not exist on type '{ x: number; }'. +jsxNamesStartingWithHash.tsx(8,12): error TS2304: Cannot find name '#a'. +jsxNamesStartingWithHash.tsx(8,17): error TS2304: Cannot find name '#a'. +jsxNamesStartingWithHash.tsx(13,16): error TS1003: Identifier expected. +jsxNamesStartingWithHash.tsx(19,12): error TS1127: Invalid character. +jsxNamesStartingWithHash.tsx(19,12): error TS2304: Cannot find name '#'. -==== jsxNamesStartingWithHash.tsx (4 errors) ==== +==== jsxNamesStartingWithHash.tsx (5 errors) ==== declare const React: any; declare namespace JSX { interface IntrinsicElements { [name: string]: any; } } - declare function Comp(props: { x: number }): any; const a = <#a>; ~~ @@ -30,9 +29,10 @@ jsxNamesStartingWithHash.tsx(19,17): error TS2322: Type '{ "#x": number; x: numb const h =
; const i = <#l-m>; const j =
; - const k = ; - ~~ -!!! error TS2322: Type '{ "#x": number; x: number; }' is not assignable to type '{ x: number; }'. -!!! error TS2322: Property '#x' does not exist on type '{ x: number; }'. - const l =
; + const k =
; + const l = <# />; + ~ +!!! error TS1127: Invalid character. + ~ +!!! error TS2304: Cannot find name '#'. \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=preserve).js b/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=preserve).js index e4e7761c155c2..21bc473f95426 100644 --- a/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=preserve).js +++ b/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=preserve).js @@ -7,7 +7,6 @@ declare namespace JSX { [name: string]: any; } } -declare function Comp(props: { x: number }): any; const a = <#a>; const b =
; @@ -19,8 +18,8 @@ const g = <#h:i />; const h =
; const i = <#l-m>; const j =
; -const k = ; -const l =
; +const k =
; +const l = <# />; //// [jsxNamesStartingWithHash.jsx] @@ -35,5 +34,5 @@ const g = <#h:i />; const h =
; const i = <#l-m>; const j =
; -const k = ; -const l =
; +const k =
; +const l = <# />; diff --git a/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=preserve).symbols b/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=preserve).symbols index 4e76ad35e6a89..1913b67f88242 100644 --- a/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=preserve).symbols +++ b/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=preserve).symbols @@ -14,64 +14,57 @@ declare namespace JSX { >name : Symbol(name, Decl(jsxNamesStartingWithHash.tsx, 3, 9)) } } -declare function Comp(props: { x: number }): any; ->Comp : Symbol(Comp, Decl(jsxNamesStartingWithHash.tsx, 5, 1)) ->props : Symbol(props, Decl(jsxNamesStartingWithHash.tsx, 6, 22)) ->x : Symbol(x, Decl(jsxNamesStartingWithHash.tsx, 6, 30)) const a = <#a>; ->a : Symbol(a, Decl(jsxNamesStartingWithHash.tsx, 8, 5)) +>a : Symbol(a, Decl(jsxNamesStartingWithHash.tsx, 7, 5)) const b =
; ->b : Symbol(b, Decl(jsxNamesStartingWithHash.tsx, 9, 5)) +>b : Symbol(b, Decl(jsxNamesStartingWithHash.tsx, 8, 5)) >div : Symbol(JSX.IntrinsicElements.__index, Decl(jsxNamesStartingWithHash.tsx, 2, 33)) ->#b : Symbol(#b, Decl(jsxNamesStartingWithHash.tsx, 9, 14)) +>#b : Symbol(#b, Decl(jsxNamesStartingWithHash.tsx, 8, 14)) const c =
; ->c : Symbol(c, Decl(jsxNamesStartingWithHash.tsx, 10, 5)) +>c : Symbol(c, Decl(jsxNamesStartingWithHash.tsx, 9, 5)) >div : Symbol(JSX.IntrinsicElements.__index, Decl(jsxNamesStartingWithHash.tsx, 2, 33)) ->#c : Symbol(#c, Decl(jsxNamesStartingWithHash.tsx, 10, 14)) +>#c : Symbol(#c, Decl(jsxNamesStartingWithHash.tsx, 9, 14)) const d =
; ->d : Symbol(d, Decl(jsxNamesStartingWithHash.tsx, 11, 5)) +>d : Symbol(d, Decl(jsxNamesStartingWithHash.tsx, 10, 5)) >div : Symbol(JSX.IntrinsicElements.__index, Decl(jsxNamesStartingWithHash.tsx, 2, 33)) ->#d:e : Symbol(#d:e, Decl(jsxNamesStartingWithHash.tsx, 11, 14)) +>#d:e : Symbol(#d:e, Decl(jsxNamesStartingWithHash.tsx, 10, 14)) const e = ; ->e : Symbol(e, Decl(jsxNamesStartingWithHash.tsx, 12, 5)) +>e : Symbol(e, Decl(jsxNamesStartingWithHash.tsx, 11, 5)) const f = ; ->f : Symbol(f, Decl(jsxNamesStartingWithHash.tsx, 13, 5)) ->a : Symbol(a, Decl(jsxNamesStartingWithHash.tsx, 8, 5)) +>f : Symbol(f, Decl(jsxNamesStartingWithHash.tsx, 12, 5)) +>a : Symbol(a, Decl(jsxNamesStartingWithHash.tsx, 7, 5)) const g = <#h:i />; ->g : Symbol(g, Decl(jsxNamesStartingWithHash.tsx, 14, 5)) +>g : Symbol(g, Decl(jsxNamesStartingWithHash.tsx, 13, 5)) const h =
; ->h : Symbol(h, Decl(jsxNamesStartingWithHash.tsx, 15, 5)) +>h : Symbol(h, Decl(jsxNamesStartingWithHash.tsx, 14, 5)) >div : Symbol(JSX.IntrinsicElements.__index, Decl(jsxNamesStartingWithHash.tsx, 2, 33)) ->j:#k : Symbol(j:#k, Decl(jsxNamesStartingWithHash.tsx, 15, 14)) +>j:#k : Symbol(j:#k, Decl(jsxNamesStartingWithHash.tsx, 14, 14)) const i = <#l-m>; ->i : Symbol(i, Decl(jsxNamesStartingWithHash.tsx, 16, 5)) +>i : Symbol(i, Decl(jsxNamesStartingWithHash.tsx, 15, 5)) >#l-m : Symbol(JSX.IntrinsicElements.__index, Decl(jsxNamesStartingWithHash.tsx, 2, 33)) >#l-m : Symbol(JSX.IntrinsicElements.__index, Decl(jsxNamesStartingWithHash.tsx, 2, 33)) const j =
; ->j : Symbol(j, Decl(jsxNamesStartingWithHash.tsx, 17, 5)) +>j : Symbol(j, Decl(jsxNamesStartingWithHash.tsx, 16, 5)) >div : Symbol(JSX.IntrinsicElements.__index, Decl(jsxNamesStartingWithHash.tsx, 2, 33)) ->#n-o : Symbol(#n-o, Decl(jsxNamesStartingWithHash.tsx, 17, 14)) +>#n-o : Symbol(#n-o, Decl(jsxNamesStartingWithHash.tsx, 16, 14)) -const k = ; ->k : Symbol(k, Decl(jsxNamesStartingWithHash.tsx, 18, 5)) ->Comp : Symbol(Comp, Decl(jsxNamesStartingWithHash.tsx, 5, 1)) ->#x : Symbol(#x, Decl(jsxNamesStartingWithHash.tsx, 18, 15)) ->x : Symbol(x, Decl(jsxNamesStartingWithHash.tsx, 18, 22)) - -const l =
; ->l : Symbol(l, Decl(jsxNamesStartingWithHash.tsx, 19, 5)) +const k =
; +>k : Symbol(k, Decl(jsxNamesStartingWithHash.tsx, 17, 5)) >div : Symbol(JSX.IntrinsicElements.__index, Decl(jsxNamesStartingWithHash.tsx, 2, 33)) ->#p : Symbol(#p, Decl(jsxNamesStartingWithHash.tsx, 19, 14)) ->#q : Symbol(#q, Decl(jsxNamesStartingWithHash.tsx, 19, 17)) ->r : Symbol(r, Decl(jsxNamesStartingWithHash.tsx, 19, 23)) +>#p : Symbol(#p, Decl(jsxNamesStartingWithHash.tsx, 17, 14)) +>#q : Symbol(#q, Decl(jsxNamesStartingWithHash.tsx, 17, 17)) +>r : Symbol(r, Decl(jsxNamesStartingWithHash.tsx, 17, 23)) + +const l = <# />; +>l : Symbol(l, Decl(jsxNamesStartingWithHash.tsx, 18, 5)) diff --git a/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=preserve).types b/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=preserve).types index a48f2571f57ca..0f0dda4c462da 100644 --- a/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=preserve).types +++ b/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=preserve).types @@ -10,10 +10,6 @@ declare namespace JSX { >name : string } } -declare function Comp(props: { x: number }): any; ->Comp : (props: { x: number; }) => any ->props : { x: number; } ->x : number const a = <#a>; >a : any @@ -81,20 +77,16 @@ const j =
; >#n-o : number >1 : 1 -const k = ; +const k =
; >k : any -> : any ->Comp : (props: { x: number; }) => any ->#x : number ->1 : 1 ->x : number ->1 : 1 - -const l =
; ->l : any >
: any >div : any >#p : true >#q : string >r : string +const l = <# />; +>l : any +><# /> : any +># : any + diff --git a/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=react).errors.txt b/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=react).errors.txt index c320d6062ab74..dd1215402aebd 100644 --- a/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=react).errors.txt +++ b/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=react).errors.txt @@ -1,18 +1,17 @@ -jsxNamesStartingWithHash.tsx(9,12): error TS2304: Cannot find name '#a'. -jsxNamesStartingWithHash.tsx(9,17): error TS2304: Cannot find name '#a'. -jsxNamesStartingWithHash.tsx(14,16): error TS1003: Identifier expected. -jsxNamesStartingWithHash.tsx(19,17): error TS2322: Type '{ "#x": number; x: number; }' is not assignable to type '{ x: number; }'. - Property '#x' does not exist on type '{ x: number; }'. +jsxNamesStartingWithHash.tsx(8,12): error TS2304: Cannot find name '#a'. +jsxNamesStartingWithHash.tsx(8,17): error TS2304: Cannot find name '#a'. +jsxNamesStartingWithHash.tsx(13,16): error TS1003: Identifier expected. +jsxNamesStartingWithHash.tsx(19,12): error TS1127: Invalid character. +jsxNamesStartingWithHash.tsx(19,12): error TS2304: Cannot find name '#'. -==== jsxNamesStartingWithHash.tsx (4 errors) ==== +==== jsxNamesStartingWithHash.tsx (5 errors) ==== declare const React: any; declare namespace JSX { interface IntrinsicElements { [name: string]: any; } } - declare function Comp(props: { x: number }): any; const a = <#a>; ~~ @@ -30,9 +29,10 @@ jsxNamesStartingWithHash.tsx(19,17): error TS2322: Type '{ "#x": number; x: numb const h =
; const i = <#l-m>; const j =
; - const k = ; - ~~ -!!! error TS2322: Type '{ "#x": number; x: number; }' is not assignable to type '{ x: number; }'. -!!! error TS2322: Property '#x' does not exist on type '{ x: number; }'. - const l =
; + const k =
; + const l = <# />; + ~ +!!! error TS1127: Invalid character. + ~ +!!! error TS2304: Cannot find name '#'. \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=react).js b/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=react).js index 15476799e0dd2..8aa17c63ec284 100644 --- a/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=react).js +++ b/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=react).js @@ -7,7 +7,6 @@ declare namespace JSX { [name: string]: any; } } -declare function Comp(props: { x: number }): any; const a = <#a>; const b =
; @@ -19,8 +18,8 @@ const g = <#h:i />; const h =
; const i = <#l-m>; const j =
; -const k = ; -const l =
; +const k =
; +const l = <# />; //// [jsxNamesStartingWithHash.js] @@ -35,5 +34,5 @@ const g = React.createElement("#h:i", null); const h = React.createElement("div", { "j:#k": true }); const i = React.createElement("#l-m", null); const j = React.createElement("div", { "#n-o": 1 }); -const k = React.createElement(Comp, { "#x": 1, x: 1 }); -const l = React.createElement("div", { "#p": true, "#q": "", r: "" }); +const k = React.createElement("div", { "#p": true, "#q": "", r: "" }); +const l = React.createElement(#, null); diff --git a/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=react).symbols b/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=react).symbols index 4e76ad35e6a89..1913b67f88242 100644 --- a/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=react).symbols +++ b/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=react).symbols @@ -14,64 +14,57 @@ declare namespace JSX { >name : Symbol(name, Decl(jsxNamesStartingWithHash.tsx, 3, 9)) } } -declare function Comp(props: { x: number }): any; ->Comp : Symbol(Comp, Decl(jsxNamesStartingWithHash.tsx, 5, 1)) ->props : Symbol(props, Decl(jsxNamesStartingWithHash.tsx, 6, 22)) ->x : Symbol(x, Decl(jsxNamesStartingWithHash.tsx, 6, 30)) const a = <#a>; ->a : Symbol(a, Decl(jsxNamesStartingWithHash.tsx, 8, 5)) +>a : Symbol(a, Decl(jsxNamesStartingWithHash.tsx, 7, 5)) const b =
; ->b : Symbol(b, Decl(jsxNamesStartingWithHash.tsx, 9, 5)) +>b : Symbol(b, Decl(jsxNamesStartingWithHash.tsx, 8, 5)) >div : Symbol(JSX.IntrinsicElements.__index, Decl(jsxNamesStartingWithHash.tsx, 2, 33)) ->#b : Symbol(#b, Decl(jsxNamesStartingWithHash.tsx, 9, 14)) +>#b : Symbol(#b, Decl(jsxNamesStartingWithHash.tsx, 8, 14)) const c =
; ->c : Symbol(c, Decl(jsxNamesStartingWithHash.tsx, 10, 5)) +>c : Symbol(c, Decl(jsxNamesStartingWithHash.tsx, 9, 5)) >div : Symbol(JSX.IntrinsicElements.__index, Decl(jsxNamesStartingWithHash.tsx, 2, 33)) ->#c : Symbol(#c, Decl(jsxNamesStartingWithHash.tsx, 10, 14)) +>#c : Symbol(#c, Decl(jsxNamesStartingWithHash.tsx, 9, 14)) const d =
; ->d : Symbol(d, Decl(jsxNamesStartingWithHash.tsx, 11, 5)) +>d : Symbol(d, Decl(jsxNamesStartingWithHash.tsx, 10, 5)) >div : Symbol(JSX.IntrinsicElements.__index, Decl(jsxNamesStartingWithHash.tsx, 2, 33)) ->#d:e : Symbol(#d:e, Decl(jsxNamesStartingWithHash.tsx, 11, 14)) +>#d:e : Symbol(#d:e, Decl(jsxNamesStartingWithHash.tsx, 10, 14)) const e = ; ->e : Symbol(e, Decl(jsxNamesStartingWithHash.tsx, 12, 5)) +>e : Symbol(e, Decl(jsxNamesStartingWithHash.tsx, 11, 5)) const f = ; ->f : Symbol(f, Decl(jsxNamesStartingWithHash.tsx, 13, 5)) ->a : Symbol(a, Decl(jsxNamesStartingWithHash.tsx, 8, 5)) +>f : Symbol(f, Decl(jsxNamesStartingWithHash.tsx, 12, 5)) +>a : Symbol(a, Decl(jsxNamesStartingWithHash.tsx, 7, 5)) const g = <#h:i />; ->g : Symbol(g, Decl(jsxNamesStartingWithHash.tsx, 14, 5)) +>g : Symbol(g, Decl(jsxNamesStartingWithHash.tsx, 13, 5)) const h =
; ->h : Symbol(h, Decl(jsxNamesStartingWithHash.tsx, 15, 5)) +>h : Symbol(h, Decl(jsxNamesStartingWithHash.tsx, 14, 5)) >div : Symbol(JSX.IntrinsicElements.__index, Decl(jsxNamesStartingWithHash.tsx, 2, 33)) ->j:#k : Symbol(j:#k, Decl(jsxNamesStartingWithHash.tsx, 15, 14)) +>j:#k : Symbol(j:#k, Decl(jsxNamesStartingWithHash.tsx, 14, 14)) const i = <#l-m>; ->i : Symbol(i, Decl(jsxNamesStartingWithHash.tsx, 16, 5)) +>i : Symbol(i, Decl(jsxNamesStartingWithHash.tsx, 15, 5)) >#l-m : Symbol(JSX.IntrinsicElements.__index, Decl(jsxNamesStartingWithHash.tsx, 2, 33)) >#l-m : Symbol(JSX.IntrinsicElements.__index, Decl(jsxNamesStartingWithHash.tsx, 2, 33)) const j =
; ->j : Symbol(j, Decl(jsxNamesStartingWithHash.tsx, 17, 5)) +>j : Symbol(j, Decl(jsxNamesStartingWithHash.tsx, 16, 5)) >div : Symbol(JSX.IntrinsicElements.__index, Decl(jsxNamesStartingWithHash.tsx, 2, 33)) ->#n-o : Symbol(#n-o, Decl(jsxNamesStartingWithHash.tsx, 17, 14)) +>#n-o : Symbol(#n-o, Decl(jsxNamesStartingWithHash.tsx, 16, 14)) -const k = ; ->k : Symbol(k, Decl(jsxNamesStartingWithHash.tsx, 18, 5)) ->Comp : Symbol(Comp, Decl(jsxNamesStartingWithHash.tsx, 5, 1)) ->#x : Symbol(#x, Decl(jsxNamesStartingWithHash.tsx, 18, 15)) ->x : Symbol(x, Decl(jsxNamesStartingWithHash.tsx, 18, 22)) - -const l =
; ->l : Symbol(l, Decl(jsxNamesStartingWithHash.tsx, 19, 5)) +const k =
; +>k : Symbol(k, Decl(jsxNamesStartingWithHash.tsx, 17, 5)) >div : Symbol(JSX.IntrinsicElements.__index, Decl(jsxNamesStartingWithHash.tsx, 2, 33)) ->#p : Symbol(#p, Decl(jsxNamesStartingWithHash.tsx, 19, 14)) ->#q : Symbol(#q, Decl(jsxNamesStartingWithHash.tsx, 19, 17)) ->r : Symbol(r, Decl(jsxNamesStartingWithHash.tsx, 19, 23)) +>#p : Symbol(#p, Decl(jsxNamesStartingWithHash.tsx, 17, 14)) +>#q : Symbol(#q, Decl(jsxNamesStartingWithHash.tsx, 17, 17)) +>r : Symbol(r, Decl(jsxNamesStartingWithHash.tsx, 17, 23)) + +const l = <# />; +>l : Symbol(l, Decl(jsxNamesStartingWithHash.tsx, 18, 5)) diff --git a/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=react).types b/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=react).types index a48f2571f57ca..0f0dda4c462da 100644 --- a/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=react).types +++ b/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=react).types @@ -10,10 +10,6 @@ declare namespace JSX { >name : string } } -declare function Comp(props: { x: number }): any; ->Comp : (props: { x: number; }) => any ->props : { x: number; } ->x : number const a = <#a>; >a : any @@ -81,20 +77,16 @@ const j =
; >#n-o : number >1 : 1 -const k = ; +const k =
; >k : any -> : any ->Comp : (props: { x: number; }) => any ->#x : number ->1 : 1 ->x : number ->1 : 1 - -const l =
; ->l : any >
: any >div : any >#p : true >#q : string >r : string +const l = <# />; +>l : any +><# /> : any +># : any + diff --git a/tsc/testdata/tests/cases/compiler/jsxNamesStartingWithHash.tsx b/tsc/testdata/tests/cases/compiler/jsxNamesStartingWithHash.tsx index 2da54ea89e42e..384d6653b121e 100644 --- a/tsc/testdata/tests/cases/compiler/jsxNamesStartingWithHash.tsx +++ b/tsc/testdata/tests/cases/compiler/jsxNamesStartingWithHash.tsx @@ -7,7 +7,6 @@ declare namespace JSX { [name: string]: any; } } -declare function Comp(props: { x: number }): any; const a = <#a>; const b =
; @@ -19,5 +18,5 @@ const g = <#h:i />; const h =
; const i = <#l-m>; const j =
; -const k = ; -const l =
; +const k =
; +const l = <# />; From 87d5176ed65b7ffda2809d31c5ffde860f5e0511 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 10 Nov 2026 18:11:38 +0000 Subject: [PATCH 4/7] Report an error for JSX tag and attribute names starting with '#' Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com> --- tsc/internal/parser/parser.go | 19 ++++++-- tsc/internal/scanner/scanner.go | 6 ++- ...sStartingWithHash(jsx=preserve).errors.txt | 46 +++++++++++++++---- .../jsxNamesStartingWithHash(jsx=preserve).js | 22 ++++----- ...amesStartingWithHash(jsx=preserve).symbols | 12 ++--- ...xNamesStartingWithHash(jsx=preserve).types | 28 +++++------ ...amesStartingWithHash(jsx=react).errors.txt | 46 +++++++++++++++---- .../jsxNamesStartingWithHash(jsx=react).js | 22 ++++----- ...sxNamesStartingWithHash(jsx=react).symbols | 12 ++--- .../jsxNamesStartingWithHash(jsx=react).types | 28 +++++------ 10 files changed, 156 insertions(+), 85 deletions(-) diff --git a/tsc/internal/parser/parser.go b/tsc/internal/parser/parser.go index a58db02e5c70f..fbf071271cfd8 100644 --- a/tsc/internal/parser/parser.go +++ b/tsc/internal/parser/parser.go @@ -5147,10 +5147,10 @@ func (p *Parser) parseJsxTagName() *ast.Expression { pos := p.nodePos() p.scanJsxIdentifier() isThis := p.token == ast.KindThisKeyword - tagName := p.parseIdentifierNameErrorOnUnicodeEscapeSequence() + tagName := p.parseJsxIdentifierName() if p.parseOptional(ast.KindColonToken) { p.scanJsxIdentifier() - return p.finishNode(p.factory.NewJsxNamespacedName(tagName, p.parseIdentifierNameErrorOnUnicodeEscapeSequence()), pos) + return p.finishNode(p.factory.NewJsxNamespacedName(tagName, p.parseJsxIdentifierName()), pos) } if isThis { result := p.factory.NewKeywordExpression(ast.KindThisKeyword) @@ -5159,6 +5159,17 @@ func (p *Parser) parseJsxTagName() *ast.Expression { return tagName } +func (p *Parser) parseJsxIdentifierName() *ast.Node { + if p.token == ast.KindPrivateIdentifier { + // '#' is not a valid JSX identifier character. Consume the private identifier and produce a missing + // identifier, as parseRightSideOfDot does for ``. + p.parseErrorAtCurrentToken(diagnostics.Identifier_expected) + p.nextToken() + return p.createMissingIdentifier() + } + return p.parseIdentifierNameErrorOnUnicodeEscapeSequence() +} + func (p *Parser) parseJsxAttributes() *ast.Node { pos := p.nodePos() return p.finishNode(p.factory.NewJsxAttributes(p.parseList(PCJsxAttributes, (*Parser).parseJsxAttribute)), pos) @@ -5184,10 +5195,10 @@ func (p *Parser) parseJsxSpreadAttribute() *ast.Node { func (p *Parser) parseJsxAttributeName() *ast.Node { pos := p.nodePos() p.scanJsxIdentifier() - attrName := p.parseIdentifierNameErrorOnUnicodeEscapeSequence() + attrName := p.parseJsxIdentifierName() if p.parseOptional(ast.KindColonToken) { p.scanJsxIdentifier() - return p.finishNode(p.factory.NewJsxNamespacedName(attrName, p.parseIdentifierNameErrorOnUnicodeEscapeSequence()), pos) + return p.finishNode(p.factory.NewJsxNamespacedName(attrName, p.parseJsxIdentifierName()), pos) } return attrName } diff --git a/tsc/internal/scanner/scanner.go b/tsc/internal/scanner/scanner.go index 7dc5199678d93..b55df6970caa8 100644 --- a/tsc/internal/scanner/scanner.go +++ b/tsc/internal/scanner/scanner.go @@ -1377,7 +1377,11 @@ func (s *Scanner) ScanJsxIdentifier() ast.Kind { // Any caller should be expecting this behavior and should only read the pos or token value after calling it. // Here scanIdentifierParts is reused to ensure Unicode escapes are handled. s.tokenValue += s.scanIdentifierParts(identifierVariantJSX) - s.token = GetIdentifierToken(s.tokenValue) + // '#' is not a valid JSX identifier character, so a private identifier (e.g. `#a-b`) keeps its kind + // and is left for the parser to report. + if s.token != ast.KindPrivateIdentifier { + s.token = GetIdentifierToken(s.tokenValue) + } } return s.token } diff --git a/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=preserve).errors.txt b/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=preserve).errors.txt index dd1215402aebd..3bbd8a87a51bf 100644 --- a/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=preserve).errors.txt +++ b/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=preserve).errors.txt @@ -1,11 +1,21 @@ -jsxNamesStartingWithHash.tsx(8,12): error TS2304: Cannot find name '#a'. -jsxNamesStartingWithHash.tsx(8,17): error TS2304: Cannot find name '#a'. +jsxNamesStartingWithHash.tsx(8,12): error TS1003: Identifier expected. +jsxNamesStartingWithHash.tsx(8,17): error TS1003: Identifier expected. +jsxNamesStartingWithHash.tsx(9,16): error TS1003: Identifier expected. +jsxNamesStartingWithHash.tsx(10,16): error TS1003: Identifier expected. +jsxNamesStartingWithHash.tsx(11,16): error TS1003: Identifier expected. +jsxNamesStartingWithHash.tsx(12,14): error TS1003: Identifier expected. jsxNamesStartingWithHash.tsx(13,16): error TS1003: Identifier expected. +jsxNamesStartingWithHash.tsx(14,12): error TS1003: Identifier expected. +jsxNamesStartingWithHash.tsx(15,18): error TS1003: Identifier expected. +jsxNamesStartingWithHash.tsx(16,12): error TS1003: Identifier expected. +jsxNamesStartingWithHash.tsx(16,19): error TS1003: Identifier expected. +jsxNamesStartingWithHash.tsx(17,16): error TS1003: Identifier expected. +jsxNamesStartingWithHash.tsx(18,16): error TS1003: Identifier expected. +jsxNamesStartingWithHash.tsx(18,19): error TS1003: Identifier expected. jsxNamesStartingWithHash.tsx(19,12): error TS1127: Invalid character. -jsxNamesStartingWithHash.tsx(19,12): error TS2304: Cannot find name '#'. -==== jsxNamesStartingWithHash.tsx (5 errors) ==== +==== jsxNamesStartingWithHash.tsx (15 errors) ==== declare const React: any; declare namespace JSX { interface IntrinsicElements { @@ -15,24 +25,44 @@ jsxNamesStartingWithHash.tsx(19,12): error TS2304: Cannot find name '#'. const a = <#a>; ~~ -!!! error TS2304: Cannot find name '#a'. +!!! error TS1003: Identifier expected. ~~ -!!! error TS2304: Cannot find name '#a'. +!!! error TS1003: Identifier expected. const b =
; + ~~ +!!! error TS1003: Identifier expected. const c =
; + ~~ +!!! error TS1003: Identifier expected. const d =
; + ~~ +!!! error TS1003: Identifier expected. const e = ; + ~~ +!!! error TS1003: Identifier expected. const f = ; !!! error TS1003: Identifier expected. const g = <#h:i />; + ~~ +!!! error TS1003: Identifier expected. const h =
; + ~~ +!!! error TS1003: Identifier expected. const i = <#l-m>; + ~~~~ +!!! error TS1003: Identifier expected. + ~~~~ +!!! error TS1003: Identifier expected. const j =
; + ~~~~ +!!! error TS1003: Identifier expected. const k =
; + ~~ +!!! error TS1003: Identifier expected. + ~~ +!!! error TS1003: Identifier expected. const l = <# />; ~ !!! error TS1127: Invalid character. - ~ -!!! error TS2304: Cannot find name '#'. \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=preserve).js b/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=preserve).js index 21bc473f95426..922cf4fbfd717 100644 --- a/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=preserve).js +++ b/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=preserve).js @@ -24,15 +24,15 @@ const l = <# />; //// [jsxNamesStartingWithHash.jsx] "use strict"; -const a = <#a>; -const b =
; -const c =
; -const d =
; -const e = ; +const a = <>; +const b =
; +const c =
; +const d =
; +const e = ; const f = ; -const g = <#h:i />; -const h =
; -const i = <#l-m>; -const j =
; -const k =
; -const l = <# />; +const g = <:i />; +const h =
; +const i = <>; +const j =
; +const k =
; +const l = < />; diff --git a/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=preserve).symbols b/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=preserve).symbols index 1913b67f88242..2c672e09e8c9b 100644 --- a/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=preserve).symbols +++ b/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=preserve).symbols @@ -21,12 +21,12 @@ const a = <#a>; const b =
; >b : Symbol(b, Decl(jsxNamesStartingWithHash.tsx, 8, 5)) >div : Symbol(JSX.IntrinsicElements.__index, Decl(jsxNamesStartingWithHash.tsx, 2, 33)) ->#b : Symbol(#b, Decl(jsxNamesStartingWithHash.tsx, 8, 14)) +> : Symbol((Missing), Decl(jsxNamesStartingWithHash.tsx, 8, 14)) const c =
; >c : Symbol(c, Decl(jsxNamesStartingWithHash.tsx, 9, 5)) >div : Symbol(JSX.IntrinsicElements.__index, Decl(jsxNamesStartingWithHash.tsx, 2, 33)) ->#c : Symbol(#c, Decl(jsxNamesStartingWithHash.tsx, 9, 14)) +> : Symbol((Missing), Decl(jsxNamesStartingWithHash.tsx, 9, 14)) const d =
; >d : Symbol(d, Decl(jsxNamesStartingWithHash.tsx, 10, 5)) @@ -50,19 +50,17 @@ const h =
; const i = <#l-m>; >i : Symbol(i, Decl(jsxNamesStartingWithHash.tsx, 15, 5)) ->#l-m : Symbol(JSX.IntrinsicElements.__index, Decl(jsxNamesStartingWithHash.tsx, 2, 33)) ->#l-m : Symbol(JSX.IntrinsicElements.__index, Decl(jsxNamesStartingWithHash.tsx, 2, 33)) const j =
; >j : Symbol(j, Decl(jsxNamesStartingWithHash.tsx, 16, 5)) >div : Symbol(JSX.IntrinsicElements.__index, Decl(jsxNamesStartingWithHash.tsx, 2, 33)) ->#n-o : Symbol(#n-o, Decl(jsxNamesStartingWithHash.tsx, 16, 14)) +> : Symbol((Missing), Decl(jsxNamesStartingWithHash.tsx, 16, 14)) const k =
; >k : Symbol(k, Decl(jsxNamesStartingWithHash.tsx, 17, 5)) >div : Symbol(JSX.IntrinsicElements.__index, Decl(jsxNamesStartingWithHash.tsx, 2, 33)) ->#p : Symbol(#p, Decl(jsxNamesStartingWithHash.tsx, 17, 14)) ->#q : Symbol(#q, Decl(jsxNamesStartingWithHash.tsx, 17, 17)) +> : Symbol((Missing), Decl(jsxNamesStartingWithHash.tsx, 17, 14), Decl(jsxNamesStartingWithHash.tsx, 17, 17)) +> : Symbol((Missing), Decl(jsxNamesStartingWithHash.tsx, 17, 14), Decl(jsxNamesStartingWithHash.tsx, 17, 17)) >r : Symbol(r, Decl(jsxNamesStartingWithHash.tsx, 17, 23)) const l = <# />; diff --git a/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=preserve).types b/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=preserve).types index 0f0dda4c462da..553b66e4cf17b 100644 --- a/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=preserve).types +++ b/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=preserve).types @@ -14,34 +14,34 @@ declare namespace JSX { const a = <#a>; >a : any ><#a> : any ->#a : any ->#a : any +> : any +> : any const b =
; >b : any >
: any >div : any ->#b : true +> : true const c =
; >c : any >
: any >div : any ->#c : string +> : string const d =
; >d : any >
: any >div : any >#d:e : true ->#d : any +> : any >e : any const e = ; >e : any > : any >a : any ->#f : any +> : any const f = ; >f : any @@ -53,7 +53,7 @@ const f = ; const g = <#h:i />; >g : any ><#h:i /> : any ->#h : any +> : any >i : any const h =
; @@ -62,31 +62,31 @@ const h =
; >div : any >j:#k : true >j : any ->#k : any +> : any const i = <#l-m>; >i : any ><#l-m> : any ->#l-m : any ->#l-m : any +> : any +> : any const j =
; >j : any >
: any >div : any ->#n-o : number +> : number >1 : 1 const k =
; >k : any >
: any >div : any ->#p : true ->#q : string +> : true +> : true >r : string const l = <# />; >l : any ><# /> : any -># : any +> : any diff --git a/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=react).errors.txt b/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=react).errors.txt index dd1215402aebd..3bbd8a87a51bf 100644 --- a/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=react).errors.txt +++ b/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=react).errors.txt @@ -1,11 +1,21 @@ -jsxNamesStartingWithHash.tsx(8,12): error TS2304: Cannot find name '#a'. -jsxNamesStartingWithHash.tsx(8,17): error TS2304: Cannot find name '#a'. +jsxNamesStartingWithHash.tsx(8,12): error TS1003: Identifier expected. +jsxNamesStartingWithHash.tsx(8,17): error TS1003: Identifier expected. +jsxNamesStartingWithHash.tsx(9,16): error TS1003: Identifier expected. +jsxNamesStartingWithHash.tsx(10,16): error TS1003: Identifier expected. +jsxNamesStartingWithHash.tsx(11,16): error TS1003: Identifier expected. +jsxNamesStartingWithHash.tsx(12,14): error TS1003: Identifier expected. jsxNamesStartingWithHash.tsx(13,16): error TS1003: Identifier expected. +jsxNamesStartingWithHash.tsx(14,12): error TS1003: Identifier expected. +jsxNamesStartingWithHash.tsx(15,18): error TS1003: Identifier expected. +jsxNamesStartingWithHash.tsx(16,12): error TS1003: Identifier expected. +jsxNamesStartingWithHash.tsx(16,19): error TS1003: Identifier expected. +jsxNamesStartingWithHash.tsx(17,16): error TS1003: Identifier expected. +jsxNamesStartingWithHash.tsx(18,16): error TS1003: Identifier expected. +jsxNamesStartingWithHash.tsx(18,19): error TS1003: Identifier expected. jsxNamesStartingWithHash.tsx(19,12): error TS1127: Invalid character. -jsxNamesStartingWithHash.tsx(19,12): error TS2304: Cannot find name '#'. -==== jsxNamesStartingWithHash.tsx (5 errors) ==== +==== jsxNamesStartingWithHash.tsx (15 errors) ==== declare const React: any; declare namespace JSX { interface IntrinsicElements { @@ -15,24 +25,44 @@ jsxNamesStartingWithHash.tsx(19,12): error TS2304: Cannot find name '#'. const a = <#a>; ~~ -!!! error TS2304: Cannot find name '#a'. +!!! error TS1003: Identifier expected. ~~ -!!! error TS2304: Cannot find name '#a'. +!!! error TS1003: Identifier expected. const b =
; + ~~ +!!! error TS1003: Identifier expected. const c =
; + ~~ +!!! error TS1003: Identifier expected. const d =
; + ~~ +!!! error TS1003: Identifier expected. const e = ; + ~~ +!!! error TS1003: Identifier expected. const f = ; !!! error TS1003: Identifier expected. const g = <#h:i />; + ~~ +!!! error TS1003: Identifier expected. const h =
; + ~~ +!!! error TS1003: Identifier expected. const i = <#l-m>; + ~~~~ +!!! error TS1003: Identifier expected. + ~~~~ +!!! error TS1003: Identifier expected. const j =
; + ~~~~ +!!! error TS1003: Identifier expected. const k =
; + ~~ +!!! error TS1003: Identifier expected. + ~~ +!!! error TS1003: Identifier expected. const l = <# />; ~ !!! error TS1127: Invalid character. - ~ -!!! error TS2304: Cannot find name '#'. \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=react).js b/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=react).js index 8aa17c63ec284..a2a462ba95a81 100644 --- a/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=react).js +++ b/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=react).js @@ -24,15 +24,15 @@ const l = <# />; //// [jsxNamesStartingWithHash.js] "use strict"; -const a = React.createElement(#a, null); -const b = React.createElement("div", { "#b": true }); -const c = React.createElement("div", { "#c": "" }); -const d = React.createElement("div", { "#d:e": true }); -const e = React.createElement("a:#f", null); +const a = React.createElement(, null); +const b = React.createElement("div", { "": true }); +const c = React.createElement("div", { "": "" }); +const d = React.createElement("div", { ":e": true }); +const e = React.createElement("a:", null); const f = React.createElement(a., null); -const g = React.createElement("#h:i", null); -const h = React.createElement("div", { "j:#k": true }); -const i = React.createElement("#l-m", null); -const j = React.createElement("div", { "#n-o": 1 }); -const k = React.createElement("div", { "#p": true, "#q": "", r: "" }); -const l = React.createElement(#, null); +const g = React.createElement(":i", null); +const h = React.createElement("div", { "j:": true }); +const i = React.createElement(, null); +const j = React.createElement("div", { "": 1 }); +const k = React.createElement("div", { "": true, "": "", r: "" }); +const l = React.createElement(, null); diff --git a/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=react).symbols b/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=react).symbols index 1913b67f88242..2c672e09e8c9b 100644 --- a/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=react).symbols +++ b/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=react).symbols @@ -21,12 +21,12 @@ const a = <#a>; const b =
; >b : Symbol(b, Decl(jsxNamesStartingWithHash.tsx, 8, 5)) >div : Symbol(JSX.IntrinsicElements.__index, Decl(jsxNamesStartingWithHash.tsx, 2, 33)) ->#b : Symbol(#b, Decl(jsxNamesStartingWithHash.tsx, 8, 14)) +> : Symbol((Missing), Decl(jsxNamesStartingWithHash.tsx, 8, 14)) const c =
; >c : Symbol(c, Decl(jsxNamesStartingWithHash.tsx, 9, 5)) >div : Symbol(JSX.IntrinsicElements.__index, Decl(jsxNamesStartingWithHash.tsx, 2, 33)) ->#c : Symbol(#c, Decl(jsxNamesStartingWithHash.tsx, 9, 14)) +> : Symbol((Missing), Decl(jsxNamesStartingWithHash.tsx, 9, 14)) const d =
; >d : Symbol(d, Decl(jsxNamesStartingWithHash.tsx, 10, 5)) @@ -50,19 +50,17 @@ const h =
; const i = <#l-m>; >i : Symbol(i, Decl(jsxNamesStartingWithHash.tsx, 15, 5)) ->#l-m : Symbol(JSX.IntrinsicElements.__index, Decl(jsxNamesStartingWithHash.tsx, 2, 33)) ->#l-m : Symbol(JSX.IntrinsicElements.__index, Decl(jsxNamesStartingWithHash.tsx, 2, 33)) const j =
; >j : Symbol(j, Decl(jsxNamesStartingWithHash.tsx, 16, 5)) >div : Symbol(JSX.IntrinsicElements.__index, Decl(jsxNamesStartingWithHash.tsx, 2, 33)) ->#n-o : Symbol(#n-o, Decl(jsxNamesStartingWithHash.tsx, 16, 14)) +> : Symbol((Missing), Decl(jsxNamesStartingWithHash.tsx, 16, 14)) const k =
; >k : Symbol(k, Decl(jsxNamesStartingWithHash.tsx, 17, 5)) >div : Symbol(JSX.IntrinsicElements.__index, Decl(jsxNamesStartingWithHash.tsx, 2, 33)) ->#p : Symbol(#p, Decl(jsxNamesStartingWithHash.tsx, 17, 14)) ->#q : Symbol(#q, Decl(jsxNamesStartingWithHash.tsx, 17, 17)) +> : Symbol((Missing), Decl(jsxNamesStartingWithHash.tsx, 17, 14), Decl(jsxNamesStartingWithHash.tsx, 17, 17)) +> : Symbol((Missing), Decl(jsxNamesStartingWithHash.tsx, 17, 14), Decl(jsxNamesStartingWithHash.tsx, 17, 17)) >r : Symbol(r, Decl(jsxNamesStartingWithHash.tsx, 17, 23)) const l = <# />; diff --git a/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=react).types b/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=react).types index 0f0dda4c462da..553b66e4cf17b 100644 --- a/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=react).types +++ b/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=react).types @@ -14,34 +14,34 @@ declare namespace JSX { const a = <#a>; >a : any ><#a> : any ->#a : any ->#a : any +> : any +> : any const b =
; >b : any >
: any >div : any ->#b : true +> : true const c =
; >c : any >
: any >div : any ->#c : string +> : string const d =
; >d : any >
: any >div : any >#d:e : true ->#d : any +> : any >e : any const e = ; >e : any > : any >a : any ->#f : any +> : any const f = ; >f : any @@ -53,7 +53,7 @@ const f = ; const g = <#h:i />; >g : any ><#h:i /> : any ->#h : any +> : any >i : any const h =
; @@ -62,31 +62,31 @@ const h =
; >div : any >j:#k : true >j : any ->#k : any +> : any const i = <#l-m>; >i : any ><#l-m> : any ->#l-m : any ->#l-m : any +> : any +> : any const j =
; >j : any >
: any >div : any ->#n-o : number +> : number >1 : 1 const k =
; >k : any >
: any >div : any ->#p : true ->#q : string +> : true +> : true >r : string const l = <# />; >l : any ><# /> : any -># : any +> : any From 0e869f93c699f0c3492ff0bea64dfb3d0c6d4d16 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 10 Nov 2026 18:29:45 +0000 Subject: [PATCH 5/7] Rescan JSX names starting with '#' as single tokens in astnav Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com> --- tsc/internal/astnav/tokens.go | 16 ++++++++++++ tsc/internal/astnav/tokens_test.go | 39 ++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/tsc/internal/astnav/tokens.go b/tsc/internal/astnav/tokens.go index 99b58eb11fc6d..3dfaea969fa74 100644 --- a/tsc/internal/astnav/tokens.go +++ b/tsc/internal/astnav/tokens.go @@ -13,11 +13,27 @@ func shouldRescanLessThanLessThanToken(s *scanner.Scanner, containingNode *ast.N return token == ast.KindLessThanLessThanToken && ast.IsJsxChild(containingNode) } +// The parser skips private identifiers in JSX tag and attribute names, which are scanned +// as JSX identifiers and so may contain dashes (e.g. `<#a-b />`). +func shouldRescanJsxPrivateIdentifier(containingNode *ast.Node, token ast.Kind) bool { + if token != ast.KindPrivateIdentifier { + return false + } + switch containingNode.Kind { + case ast.KindJsxOpeningElement, ast.KindJsxSelfClosingElement, ast.KindJsxClosingElement, ast.KindJsxAttribute, ast.KindJsxNamespacedName: + return true + } + return false +} + func scanNavigationToken(s *scanner.Scanner, containingNode *ast.Node) ast.Kind { token := s.Token() if shouldRescanLessThanLessThanToken(s, containingNode, token) { return s.ReScanJsxToken(true /*allowMultilineJsxText*/) } + if shouldRescanJsxPrivateIdentifier(containingNode, token) { + return s.ScanJsxIdentifier() + } return token } diff --git a/tsc/internal/astnav/tokens_test.go b/tsc/internal/astnav/tokens_test.go index 91596cb2e8e00..09ef438aa5da3 100644 --- a/tsc/internal/astnav/tokens_test.go +++ b/tsc/internal/astnav/tokens_test.go @@ -14,6 +14,7 @@ import ( "github.com/microsoft/TypeScript/tsc/internal/core" "github.com/microsoft/TypeScript/tsc/internal/parser" "github.com/microsoft/TypeScript/tsc/internal/repo" + "github.com/microsoft/TypeScript/tsc/internal/scanner" "github.com/microsoft/TypeScript/tsc/internal/testutil/baseline" "github.com/microsoft/TypeScript/tsc/internal/testutil/jstest" "gotest.tools/v3/assert" @@ -110,6 +111,44 @@ func TestGetTokenAtPosition(t *testing.T) { }) } +func TestGetTokenAtPositionJsxNameStartingWithHash(t *testing.T) { + t.Parallel() + // The parser skips JSX tag and attribute names starting with '#', which are scanned as a + // single private identifier that may contain dashes. + fileText := `const a = <#a-b>; +const b =
; +const c =
; +const d = <#h-i:j />; +` + file := parser.ParseSourceFile(ast.SourceFileParseOptions{ + FileName: "/file.tsx", + PathKey: "/file.tsx", + }, fileText, core.ScriptKindTSX) + + for pos := range len(fileText) { + astnav.GetTokenAtPosition(file, pos) + astnav.GetTouchingPropertyName(file, pos) + astnav.FindPrecedingToken(file, pos) + } + + for _, name := range []string{"#a-b", "#c-d", "#f-g", "#h-i"} { + for offset := 0; ; { + index := strings.Index(fileText[offset:], name) + if index < 0 { + break + } + start := offset + index + for pos := start; pos < start+len(name); pos++ { + token := astnav.GetTouchingPropertyName(file, pos) + assert.Equal(t, token.Kind, ast.KindPrivateIdentifier, "at position %d", pos) + assert.Equal(t, scanner.GetTokenPosOfNode(token, file, false /*includeJSDoc*/), start, "at position %d", pos) + assert.Equal(t, token.End(), start+len(name), "at position %d", pos) + } + offset = start + len(name) + } + } +} + func TestGetTouchingPropertyName(t *testing.T) { t.Parallel() jstest.SkipIfNoNodeJS(t) From cc6b05c366a735ec5792a3e34d69e787223b304f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 10 Nov 2026 18:40:20 +0000 Subject: [PATCH 6/7] Also rescan '#' names at the start of dotted JSX tag names in astnav Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com> --- tsc/internal/astnav/tokens.go | 14 ++++++++++++-- tsc/internal/astnav/tokens_test.go | 3 ++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/tsc/internal/astnav/tokens.go b/tsc/internal/astnav/tokens.go index 3dfaea969fa74..7736bf81a767d 100644 --- a/tsc/internal/astnav/tokens.go +++ b/tsc/internal/astnav/tokens.go @@ -15,23 +15,33 @@ func shouldRescanLessThanLessThanToken(s *scanner.Scanner, containingNode *ast.N // The parser skips private identifiers in JSX tag and attribute names, which are scanned // as JSX identifiers and so may contain dashes (e.g. `<#a-b />`). -func shouldRescanJsxPrivateIdentifier(containingNode *ast.Node, token ast.Kind) bool { +func shouldRescanJsxPrivateIdentifier(s *scanner.Scanner, containingNode *ast.Node, token ast.Kind) bool { if token != ast.KindPrivateIdentifier { return false } switch containingNode.Kind { case ast.KindJsxOpeningElement, ast.KindJsxSelfClosingElement, ast.KindJsxClosingElement, ast.KindJsxAttribute, ast.KindJsxNamespacedName: return true + case ast.KindPropertyAccessExpression: + // The leftmost name of a dotted JSX tag name (e.g. `<#a-b.c />`) precedes the property access's expression. + return s.TokenStart() < containingNode.Expression().Pos() && isInJsxTagName(containingNode) } return false } +func isInJsxTagName(node *ast.Node) bool { + for ast.IsPropertyAccessExpression(node.Parent) && node.Parent.Expression() == node { + node = node.Parent + } + return ast.IsJsxTagName(node) +} + func scanNavigationToken(s *scanner.Scanner, containingNode *ast.Node) ast.Kind { token := s.Token() if shouldRescanLessThanLessThanToken(s, containingNode, token) { return s.ReScanJsxToken(true /*allowMultilineJsxText*/) } - if shouldRescanJsxPrivateIdentifier(containingNode, token) { + if shouldRescanJsxPrivateIdentifier(s, containingNode, token) { return s.ScanJsxIdentifier() } return token diff --git a/tsc/internal/astnav/tokens_test.go b/tsc/internal/astnav/tokens_test.go index 09ef438aa5da3..ced450d2e5560 100644 --- a/tsc/internal/astnav/tokens_test.go +++ b/tsc/internal/astnav/tokens_test.go @@ -119,6 +119,7 @@ func TestGetTokenAtPositionJsxNameStartingWithHash(t *testing.T) { const b =
; const c =
; const d = <#h-i:j />; +const e = <#k-l.m.n>; ` file := parser.ParseSourceFile(ast.SourceFileParseOptions{ FileName: "/file.tsx", @@ -131,7 +132,7 @@ const d = <#h-i:j />; astnav.FindPrecedingToken(file, pos) } - for _, name := range []string{"#a-b", "#c-d", "#f-g", "#h-i"} { + for _, name := range []string{"#a-b", "#c-d", "#f-g", "#h-i", "#k-l"} { for offset := 0; ; { index := strings.Index(fileText[offset:], name) if index < 0 { From 5f999e95a00294710e39659d5dba552512a00424 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 10 Nov 2026 19:36:34 +0000 Subject: [PATCH 7/7] Simplify: don't extend '#' JSX names with dashes; drop astnav rescan Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com> --- tsc/internal/astnav/tokens.go | 26 ------------ tsc/internal/astnav/tokens_test.go | 40 ------------------- tsc/internal/scanner/scanner.go | 9 ++--- ...sStartingWithHash(jsx=preserve).errors.txt | 21 +++------- .../jsxNamesStartingWithHash(jsx=preserve).js | 12 ++---- ...amesStartingWithHash(jsx=preserve).symbols | 20 +++------- ...xNamesStartingWithHash(jsx=preserve).types | 23 +++-------- ...amesStartingWithHash(jsx=react).errors.txt | 21 +++------- .../jsxNamesStartingWithHash(jsx=react).js | 12 ++---- ...sxNamesStartingWithHash(jsx=react).symbols | 20 +++------- .../jsxNamesStartingWithHash(jsx=react).types | 23 +++-------- .../compiler/jsxNamesStartingWithHash.tsx | 6 +-- 12 files changed, 45 insertions(+), 188 deletions(-) diff --git a/tsc/internal/astnav/tokens.go b/tsc/internal/astnav/tokens.go index 7736bf81a767d..99b58eb11fc6d 100644 --- a/tsc/internal/astnav/tokens.go +++ b/tsc/internal/astnav/tokens.go @@ -13,37 +13,11 @@ func shouldRescanLessThanLessThanToken(s *scanner.Scanner, containingNode *ast.N return token == ast.KindLessThanLessThanToken && ast.IsJsxChild(containingNode) } -// The parser skips private identifiers in JSX tag and attribute names, which are scanned -// as JSX identifiers and so may contain dashes (e.g. `<#a-b />`). -func shouldRescanJsxPrivateIdentifier(s *scanner.Scanner, containingNode *ast.Node, token ast.Kind) bool { - if token != ast.KindPrivateIdentifier { - return false - } - switch containingNode.Kind { - case ast.KindJsxOpeningElement, ast.KindJsxSelfClosingElement, ast.KindJsxClosingElement, ast.KindJsxAttribute, ast.KindJsxNamespacedName: - return true - case ast.KindPropertyAccessExpression: - // The leftmost name of a dotted JSX tag name (e.g. `<#a-b.c />`) precedes the property access's expression. - return s.TokenStart() < containingNode.Expression().Pos() && isInJsxTagName(containingNode) - } - return false -} - -func isInJsxTagName(node *ast.Node) bool { - for ast.IsPropertyAccessExpression(node.Parent) && node.Parent.Expression() == node { - node = node.Parent - } - return ast.IsJsxTagName(node) -} - func scanNavigationToken(s *scanner.Scanner, containingNode *ast.Node) ast.Kind { token := s.Token() if shouldRescanLessThanLessThanToken(s, containingNode, token) { return s.ReScanJsxToken(true /*allowMultilineJsxText*/) } - if shouldRescanJsxPrivateIdentifier(s, containingNode, token) { - return s.ScanJsxIdentifier() - } return token } diff --git a/tsc/internal/astnav/tokens_test.go b/tsc/internal/astnav/tokens_test.go index ced450d2e5560..91596cb2e8e00 100644 --- a/tsc/internal/astnav/tokens_test.go +++ b/tsc/internal/astnav/tokens_test.go @@ -14,7 +14,6 @@ import ( "github.com/microsoft/TypeScript/tsc/internal/core" "github.com/microsoft/TypeScript/tsc/internal/parser" "github.com/microsoft/TypeScript/tsc/internal/repo" - "github.com/microsoft/TypeScript/tsc/internal/scanner" "github.com/microsoft/TypeScript/tsc/internal/testutil/baseline" "github.com/microsoft/TypeScript/tsc/internal/testutil/jstest" "gotest.tools/v3/assert" @@ -111,45 +110,6 @@ func TestGetTokenAtPosition(t *testing.T) { }) } -func TestGetTokenAtPositionJsxNameStartingWithHash(t *testing.T) { - t.Parallel() - // The parser skips JSX tag and attribute names starting with '#', which are scanned as a - // single private identifier that may contain dashes. - fileText := `const a = <#a-b>; -const b =
; -const c =
; -const d = <#h-i:j />; -const e = <#k-l.m.n>; -` - file := parser.ParseSourceFile(ast.SourceFileParseOptions{ - FileName: "/file.tsx", - PathKey: "/file.tsx", - }, fileText, core.ScriptKindTSX) - - for pos := range len(fileText) { - astnav.GetTokenAtPosition(file, pos) - astnav.GetTouchingPropertyName(file, pos) - astnav.FindPrecedingToken(file, pos) - } - - for _, name := range []string{"#a-b", "#c-d", "#f-g", "#h-i", "#k-l"} { - for offset := 0; ; { - index := strings.Index(fileText[offset:], name) - if index < 0 { - break - } - start := offset + index - for pos := start; pos < start+len(name); pos++ { - token := astnav.GetTouchingPropertyName(file, pos) - assert.Equal(t, token.Kind, ast.KindPrivateIdentifier, "at position %d", pos) - assert.Equal(t, scanner.GetTokenPosOfNode(token, file, false /*includeJSDoc*/), start, "at position %d", pos) - assert.Equal(t, token.End(), start+len(name), "at position %d", pos) - } - offset = start + len(name) - } - } -} - func TestGetTouchingPropertyName(t *testing.T) { t.Parallel() jstest.SkipIfNoNodeJS(t) diff --git a/tsc/internal/scanner/scanner.go b/tsc/internal/scanner/scanner.go index b55df6970caa8..884c280de1bfd 100644 --- a/tsc/internal/scanner/scanner.go +++ b/tsc/internal/scanner/scanner.go @@ -1370,18 +1370,15 @@ func (s *Scanner) ScanJsxTokenEx(allowMultilineJsxText bool) ast.Kind { // Scans a JSX identifier; these differ from normal identifiers in that they allow dashes func (s *Scanner) ScanJsxIdentifier() ast.Kind { - if tokenIsIdentifierOrKeyword(s.token) { + // '#' is not a valid JSX identifier character, so a private identifier is left for the parser to report. + if s.token != ast.KindPrivateIdentifier && tokenIsIdentifierOrKeyword(s.token) { // An identifier or keyword has already been parsed - check for a `-` or a single instance of `:` and then append it and // everything after it to the token // Do note that this means that `scanJsxIdentifier` effectively _mutates_ the visible token without advancing to a new token // Any caller should be expecting this behavior and should only read the pos or token value after calling it. // Here scanIdentifierParts is reused to ensure Unicode escapes are handled. s.tokenValue += s.scanIdentifierParts(identifierVariantJSX) - // '#' is not a valid JSX identifier character, so a private identifier (e.g. `#a-b`) keeps its kind - // and is left for the parser to report. - if s.token != ast.KindPrivateIdentifier { - s.token = GetIdentifierToken(s.tokenValue) - } + s.token = GetIdentifierToken(s.tokenValue) } return s.token } diff --git a/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=preserve).errors.txt b/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=preserve).errors.txt index 3bbd8a87a51bf..efd5915050fc0 100644 --- a/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=preserve).errors.txt +++ b/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=preserve).errors.txt @@ -7,15 +7,12 @@ jsxNamesStartingWithHash.tsx(12,14): error TS1003: Identifier expected. jsxNamesStartingWithHash.tsx(13,16): error TS1003: Identifier expected. jsxNamesStartingWithHash.tsx(14,12): error TS1003: Identifier expected. jsxNamesStartingWithHash.tsx(15,18): error TS1003: Identifier expected. -jsxNamesStartingWithHash.tsx(16,12): error TS1003: Identifier expected. +jsxNamesStartingWithHash.tsx(16,16): error TS1003: Identifier expected. jsxNamesStartingWithHash.tsx(16,19): error TS1003: Identifier expected. -jsxNamesStartingWithHash.tsx(17,16): error TS1003: Identifier expected. -jsxNamesStartingWithHash.tsx(18,16): error TS1003: Identifier expected. -jsxNamesStartingWithHash.tsx(18,19): error TS1003: Identifier expected. -jsxNamesStartingWithHash.tsx(19,12): error TS1127: Invalid character. +jsxNamesStartingWithHash.tsx(17,12): error TS1127: Invalid character. -==== jsxNamesStartingWithHash.tsx (15 errors) ==== +==== jsxNamesStartingWithHash.tsx (12 errors) ==== declare const React: any; declare namespace JSX { interface IntrinsicElements { @@ -49,20 +46,12 @@ jsxNamesStartingWithHash.tsx(19,12): error TS1127: Invalid character. const h =
; ~~ !!! error TS1003: Identifier expected. - const i = <#l-m>; - ~~~~ -!!! error TS1003: Identifier expected. - ~~~~ -!!! error TS1003: Identifier expected. - const j =
; - ~~~~ -!!! error TS1003: Identifier expected. - const k =
; + const i =
; ~~ !!! error TS1003: Identifier expected. ~~ !!! error TS1003: Identifier expected. - const l = <# />; + const j = <# />; ~ !!! error TS1127: Invalid character. \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=preserve).js b/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=preserve).js index 922cf4fbfd717..d5c909ff59100 100644 --- a/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=preserve).js +++ b/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=preserve).js @@ -16,10 +16,8 @@ const e = ; const f = ; const g = <#h:i />; const h =
; -const i = <#l-m>; -const j =
; -const k =
; -const l = <# />; +const i =
; +const j = <# />; //// [jsxNamesStartingWithHash.jsx] @@ -32,7 +30,5 @@ const e = ; const f = ; const g = <:i />; const h =
; -const i = <>; -const j =
; -const k =
; -const l = < />; +const i =
; +const j = < />; diff --git a/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=preserve).symbols b/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=preserve).symbols index 2c672e09e8c9b..f3e62d63b8403 100644 --- a/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=preserve).symbols +++ b/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=preserve).symbols @@ -48,21 +48,13 @@ const h =
; >div : Symbol(JSX.IntrinsicElements.__index, Decl(jsxNamesStartingWithHash.tsx, 2, 33)) >j:#k : Symbol(j:#k, Decl(jsxNamesStartingWithHash.tsx, 14, 14)) -const i = <#l-m>; +const i =
; >i : Symbol(i, Decl(jsxNamesStartingWithHash.tsx, 15, 5)) - -const j =
; ->j : Symbol(j, Decl(jsxNamesStartingWithHash.tsx, 16, 5)) >div : Symbol(JSX.IntrinsicElements.__index, Decl(jsxNamesStartingWithHash.tsx, 2, 33)) -> : Symbol((Missing), Decl(jsxNamesStartingWithHash.tsx, 16, 14)) +> : Symbol((Missing), Decl(jsxNamesStartingWithHash.tsx, 15, 14), Decl(jsxNamesStartingWithHash.tsx, 15, 17)) +> : Symbol((Missing), Decl(jsxNamesStartingWithHash.tsx, 15, 14), Decl(jsxNamesStartingWithHash.tsx, 15, 17)) +>n : Symbol(n, Decl(jsxNamesStartingWithHash.tsx, 15, 23)) -const k =
; ->k : Symbol(k, Decl(jsxNamesStartingWithHash.tsx, 17, 5)) ->div : Symbol(JSX.IntrinsicElements.__index, Decl(jsxNamesStartingWithHash.tsx, 2, 33)) -> : Symbol((Missing), Decl(jsxNamesStartingWithHash.tsx, 17, 14), Decl(jsxNamesStartingWithHash.tsx, 17, 17)) -> : Symbol((Missing), Decl(jsxNamesStartingWithHash.tsx, 17, 14), Decl(jsxNamesStartingWithHash.tsx, 17, 17)) ->r : Symbol(r, Decl(jsxNamesStartingWithHash.tsx, 17, 23)) - -const l = <# />; ->l : Symbol(l, Decl(jsxNamesStartingWithHash.tsx, 18, 5)) +const j = <# />; +>j : Symbol(j, Decl(jsxNamesStartingWithHash.tsx, 16, 5)) diff --git a/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=preserve).types b/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=preserve).types index 553b66e4cf17b..a70abd9dd7406 100644 --- a/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=preserve).types +++ b/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=preserve).types @@ -64,29 +64,16 @@ const h =
; >j : any > : any -const i = <#l-m>; +const i =
; >i : any -><#l-m> : any -> : any -> : any - -const j =
; ->j : any ->
: any ->div : any -> : number ->1 : 1 - -const k =
; ->k : any ->
: any +>
: any >div : any > : true > : true ->r : string +>n : string -const l = <# />; ->l : any +const j = <# />; +>j : any ><# /> : any > : any diff --git a/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=react).errors.txt b/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=react).errors.txt index 3bbd8a87a51bf..efd5915050fc0 100644 --- a/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=react).errors.txt +++ b/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=react).errors.txt @@ -7,15 +7,12 @@ jsxNamesStartingWithHash.tsx(12,14): error TS1003: Identifier expected. jsxNamesStartingWithHash.tsx(13,16): error TS1003: Identifier expected. jsxNamesStartingWithHash.tsx(14,12): error TS1003: Identifier expected. jsxNamesStartingWithHash.tsx(15,18): error TS1003: Identifier expected. -jsxNamesStartingWithHash.tsx(16,12): error TS1003: Identifier expected. +jsxNamesStartingWithHash.tsx(16,16): error TS1003: Identifier expected. jsxNamesStartingWithHash.tsx(16,19): error TS1003: Identifier expected. -jsxNamesStartingWithHash.tsx(17,16): error TS1003: Identifier expected. -jsxNamesStartingWithHash.tsx(18,16): error TS1003: Identifier expected. -jsxNamesStartingWithHash.tsx(18,19): error TS1003: Identifier expected. -jsxNamesStartingWithHash.tsx(19,12): error TS1127: Invalid character. +jsxNamesStartingWithHash.tsx(17,12): error TS1127: Invalid character. -==== jsxNamesStartingWithHash.tsx (15 errors) ==== +==== jsxNamesStartingWithHash.tsx (12 errors) ==== declare const React: any; declare namespace JSX { interface IntrinsicElements { @@ -49,20 +46,12 @@ jsxNamesStartingWithHash.tsx(19,12): error TS1127: Invalid character. const h =
; ~~ !!! error TS1003: Identifier expected. - const i = <#l-m>; - ~~~~ -!!! error TS1003: Identifier expected. - ~~~~ -!!! error TS1003: Identifier expected. - const j =
; - ~~~~ -!!! error TS1003: Identifier expected. - const k =
; + const i =
; ~~ !!! error TS1003: Identifier expected. ~~ !!! error TS1003: Identifier expected. - const l = <# />; + const j = <# />; ~ !!! error TS1127: Invalid character. \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=react).js b/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=react).js index a2a462ba95a81..7792b25f6e04b 100644 --- a/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=react).js +++ b/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=react).js @@ -16,10 +16,8 @@ const e = ; const f = ; const g = <#h:i />; const h =
; -const i = <#l-m>; -const j =
; -const k =
; -const l = <# />; +const i =
; +const j = <# />; //// [jsxNamesStartingWithHash.js] @@ -32,7 +30,5 @@ const e = React.createElement("a:", null); const f = React.createElement(a., null); const g = React.createElement(":i", null); const h = React.createElement("div", { "j:": true }); -const i = React.createElement(, null); -const j = React.createElement("div", { "": 1 }); -const k = React.createElement("div", { "": true, "": "", r: "" }); -const l = React.createElement(, null); +const i = React.createElement("div", { "": true, "": "", n: "" }); +const j = React.createElement(, null); diff --git a/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=react).symbols b/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=react).symbols index 2c672e09e8c9b..f3e62d63b8403 100644 --- a/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=react).symbols +++ b/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=react).symbols @@ -48,21 +48,13 @@ const h =
; >div : Symbol(JSX.IntrinsicElements.__index, Decl(jsxNamesStartingWithHash.tsx, 2, 33)) >j:#k : Symbol(j:#k, Decl(jsxNamesStartingWithHash.tsx, 14, 14)) -const i = <#l-m>; +const i =
; >i : Symbol(i, Decl(jsxNamesStartingWithHash.tsx, 15, 5)) - -const j =
; ->j : Symbol(j, Decl(jsxNamesStartingWithHash.tsx, 16, 5)) >div : Symbol(JSX.IntrinsicElements.__index, Decl(jsxNamesStartingWithHash.tsx, 2, 33)) -> : Symbol((Missing), Decl(jsxNamesStartingWithHash.tsx, 16, 14)) +> : Symbol((Missing), Decl(jsxNamesStartingWithHash.tsx, 15, 14), Decl(jsxNamesStartingWithHash.tsx, 15, 17)) +> : Symbol((Missing), Decl(jsxNamesStartingWithHash.tsx, 15, 14), Decl(jsxNamesStartingWithHash.tsx, 15, 17)) +>n : Symbol(n, Decl(jsxNamesStartingWithHash.tsx, 15, 23)) -const k =
; ->k : Symbol(k, Decl(jsxNamesStartingWithHash.tsx, 17, 5)) ->div : Symbol(JSX.IntrinsicElements.__index, Decl(jsxNamesStartingWithHash.tsx, 2, 33)) -> : Symbol((Missing), Decl(jsxNamesStartingWithHash.tsx, 17, 14), Decl(jsxNamesStartingWithHash.tsx, 17, 17)) -> : Symbol((Missing), Decl(jsxNamesStartingWithHash.tsx, 17, 14), Decl(jsxNamesStartingWithHash.tsx, 17, 17)) ->r : Symbol(r, Decl(jsxNamesStartingWithHash.tsx, 17, 23)) - -const l = <# />; ->l : Symbol(l, Decl(jsxNamesStartingWithHash.tsx, 18, 5)) +const j = <# />; +>j : Symbol(j, Decl(jsxNamesStartingWithHash.tsx, 16, 5)) diff --git a/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=react).types b/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=react).types index 553b66e4cf17b..a70abd9dd7406 100644 --- a/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=react).types +++ b/tsc/testdata/baselines/reference/compiler/jsxNamesStartingWithHash(jsx=react).types @@ -64,29 +64,16 @@ const h =
; >j : any > : any -const i = <#l-m>; +const i =
; >i : any -><#l-m> : any -> : any -> : any - -const j =
; ->j : any ->
: any ->div : any -> : number ->1 : 1 - -const k =
; ->k : any ->
: any +>
: any >div : any > : true > : true ->r : string +>n : string -const l = <# />; ->l : any +const j = <# />; +>j : any ><# /> : any > : any diff --git a/tsc/testdata/tests/cases/compiler/jsxNamesStartingWithHash.tsx b/tsc/testdata/tests/cases/compiler/jsxNamesStartingWithHash.tsx index 384d6653b121e..c93639dfe642f 100644 --- a/tsc/testdata/tests/cases/compiler/jsxNamesStartingWithHash.tsx +++ b/tsc/testdata/tests/cases/compiler/jsxNamesStartingWithHash.tsx @@ -16,7 +16,5 @@ const e = ; const f = ; const g = <#h:i />; const h =
; -const i = <#l-m>; -const j =
; -const k =
; -const l = <# />; +const i =
; +const j = <# />;