Skip to content

Commit 443ddbe

Browse files
committed
Add cases with upcase idents for jsx namespaces
1 parent 83c6814 commit 443ddbe

10 files changed

+97
-18
lines changed

tests/baselines/reference/jsxNamespacePrefixInName.errors.txt

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@ tests/cases/compiler/jsxNamespacePrefixInName.tsx(24,38): error TS1005: ':' expe
2727
tests/cases/compiler/jsxNamespacePrefixInName.tsx(24,41): error TS1109: Expression expected.
2828
tests/cases/compiler/jsxNamespacePrefixInName.tsx(24,42): error TS1109: Expression expected.
2929
tests/cases/compiler/jsxNamespacePrefixInName.tsx(25,24): error TS1003: Identifier expected.
30+
tests/cases/compiler/jsxNamespacePrefixInName.tsx(29,25): error TS2304: Cannot find name 'Upcase:element'.
31+
tests/cases/compiler/jsxNamespacePrefixInName.tsx(31,34): error TS2304: Cannot find name 'NS:something'.
3032

3133

32-
==== tests/cases/compiler/jsxNamespacePrefixInName.tsx (29 errors) ====
34+
==== tests/cases/compiler/jsxNamespacePrefixInName.tsx (31 errors) ====
3335
var justElement1 = <a:element />;
3436
var justElement2 = <a:element></a:element>;
3537
var justElement3 = <a:element attr={"value"}></a:element>;
@@ -113,4 +115,13 @@ tests/cases/compiler/jsxNamespacePrefixInName.tsx(25,24): error TS1003: Identifi
113115
var beginOfIdent1 = <a :attr={"value"} />;
114116
~
115117
!!! error TS1003: Identifier expected.
116-
118+
119+
var Upcase = "mycomponent"
120+
var upcaseComponent1 = <ns:Upcase /> // Parsed as intrinsic: ok
121+
var upcaseComponent2 = <Upcase:element /> // Parsed as component: not ok
122+
~~~~~~~~~~~~~~
123+
!!! error TS2304: Cannot find name 'Upcase:element'.
124+
125+
var upcaseComponentUndeclared = <NS:something />
126+
~~~~~~~~~~~~
127+
!!! error TS2304: Cannot find name 'NS:something'.

tests/baselines/reference/jsxNamespacePrefixInName.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,12 @@ var endOfIdent2 = <a attr:={"value"} />;
2424

2525
var beginOfIdent1 = <:a attr={"value"} />;
2626
var beginOfIdent1 = <a :attr={"value"} />;
27-
27+
28+
var Upcase = "mycomponent"
29+
var upcaseComponent1 = <ns:Upcase /> // Parsed as intrinsic: ok
30+
var upcaseComponent2 = <Upcase:element /> // Parsed as component: not ok
31+
32+
var upcaseComponentUndeclared = <NS:something />
2833

2934
//// [jsxNamespacePrefixInName.jsx]
3035
var justElement1 = <a:element />;
@@ -51,3 +56,7 @@ var endOfIdent1 = <a attr={"value"}/>;
5156
var endOfIdent2 = <a attr {..."value"}/>;
5257
var beginOfIdent1 = < , a, attr = { "value": } / > ;
5358
var beginOfIdent1 = <a attr={"value"}/>;
59+
var Upcase = "mycomponent";
60+
var upcaseComponent1 = <ns:Upcase />; // Parsed as intrinsic: ok
61+
var upcaseComponent2 = <Upcase:element />; // Parsed as component: not ok
62+
var upcaseComponentUndeclared = <NS:something />;

tests/baselines/reference/jsxNamespacePrefixInName.symbols

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,15 @@ var beginOfIdent1 = <a :attr={"value"} />;
8484
>beginOfIdent1 : Symbol(beginOfIdent1, Decl(jsxNamespacePrefixInName.tsx, 23, 3), Decl(jsxNamespacePrefixInName.tsx, 24, 3))
8585
>attr : Symbol(attr, Decl(jsxNamespacePrefixInName.tsx, 24, 24))
8686

87+
var Upcase = "mycomponent"
88+
>Upcase : Symbol(Upcase, Decl(jsxNamespacePrefixInName.tsx, 26, 3))
89+
90+
var upcaseComponent1 = <ns:Upcase /> // Parsed as intrinsic: ok
91+
>upcaseComponent1 : Symbol(upcaseComponent1, Decl(jsxNamespacePrefixInName.tsx, 27, 3))
92+
93+
var upcaseComponent2 = <Upcase:element /> // Parsed as component: not ok
94+
>upcaseComponent2 : Symbol(upcaseComponent2, Decl(jsxNamespacePrefixInName.tsx, 28, 3))
95+
96+
var upcaseComponentUndeclared = <NS:something />
97+
>upcaseComponentUndeclared : Symbol(upcaseComponentUndeclared, Decl(jsxNamespacePrefixInName.tsx, 30, 3))
98+

tests/baselines/reference/jsxNamespacePrefixInName.types

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,3 +174,22 @@ var beginOfIdent1 = <a :attr={"value"} />;
174174
>attr : string
175175
>"value" : "value"
176176

177+
var Upcase = "mycomponent"
178+
>Upcase : string
179+
>"mycomponent" : "mycomponent"
180+
181+
var upcaseComponent1 = <ns:Upcase /> // Parsed as intrinsic: ok
182+
>upcaseComponent1 : any
183+
><ns:Upcase /> : any
184+
>ns:Upcase : any
185+
186+
var upcaseComponent2 = <Upcase:element /> // Parsed as component: not ok
187+
>upcaseComponent2 : any
188+
><Upcase:element /> : any
189+
>Upcase:element : any
190+
191+
var upcaseComponentUndeclared = <NS:something />
192+
>upcaseComponentUndeclared : any
193+
><NS:something /> : any
194+
>NS:something : any
195+

tests/baselines/reference/jsxNamespacePrefixIntrinsics.errors.txt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
tests/cases/compiler/jsxNamespacePrefixIntrinsics.tsx(11,18): error TS2339: Property 'element' does not exist on type 'JSX.IntrinsicElements'.
2-
tests/cases/compiler/jsxNamespacePrefixIntrinsics.tsx(12,30): error TS2322: Type '{ attribute: string; }' is not assignable to type '{ "ns:attribute": string; }'.
1+
tests/cases/compiler/jsxNamespacePrefixIntrinsics.tsx(13,18): error TS2339: Property 'element' does not exist on type 'JSX.IntrinsicElements'.
2+
tests/cases/compiler/jsxNamespacePrefixIntrinsics.tsx(14,30): error TS2322: Type '{ attribute: string; }' is not assignable to type '{ "ns:attribute": string; }'.
33
Property 'attribute' does not exist on type '{ "ns:attribute": string; }'.
4-
tests/cases/compiler/jsxNamespacePrefixIntrinsics.tsx(13,30): error TS2322: Type '{ "ns:invalid": string; }' is not assignable to type '{ "ns:attribute": string; }'.
4+
tests/cases/compiler/jsxNamespacePrefixIntrinsics.tsx(15,30): error TS2322: Type '{ "ns:invalid": string; }' is not assignable to type '{ "ns:attribute": string; }'.
55
Property 'ns:invalid' does not exist on type '{ "ns:attribute": string; }'.
66

77

@@ -10,11 +10,13 @@ tests/cases/compiler/jsxNamespacePrefixIntrinsics.tsx(13,30): error TS2322: Type
1010
interface IntrinsicElements {
1111
"ns:element": {
1212
"ns:attribute": string;
13-
}
13+
},
14+
"ns:NamespacedUpcaseAlsoIntrinsic": any
1415
}
1516
}
1617

1718
const valid = <ns:element ns:attribute="yep" />;
19+
const validUpcase = <ns:NamespacedUpcaseAlsoIntrinsic />;
1820

1921
const invalid1 = <element />;
2022
~~~~~~~~~~~

tests/baselines/reference/jsxNamespacePrefixIntrinsics.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ declare namespace JSX {
33
interface IntrinsicElements {
44
"ns:element": {
55
"ns:attribute": string;
6-
}
6+
},
7+
"ns:NamespacedUpcaseAlsoIntrinsic": any
78
}
89
}
910

1011
const valid = <ns:element ns:attribute="yep" />;
12+
const validUpcase = <ns:NamespacedUpcaseAlsoIntrinsic />;
1113

1214
const invalid1 = <element />;
1315
const invalid2 = <ns:element attribute="nope" />;
@@ -16,6 +18,7 @@ const invalid3 = <ns:element ns:invalid="nope" />;
1618

1719
//// [jsxNamespacePrefixIntrinsics.jsx]
1820
var valid = <ns:element ns:attribute="yep"/>;
21+
var validUpcase = <ns:NamespacedUpcaseAlsoIntrinsic />;
1922
var invalid1 = <element />;
2023
var invalid2 = <ns:element attribute="nope"/>;
2124
var invalid3 = <ns:element ns:invalid="nope"/>;

tests/baselines/reference/jsxNamespacePrefixIntrinsics.symbols

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,32 @@ declare namespace JSX {
1010

1111
"ns:attribute": string;
1212
>"ns:attribute" : Symbol("ns:attribute", Decl(jsxNamespacePrefixIntrinsics.tsx, 2, 19))
13-
}
13+
14+
},
15+
"ns:NamespacedUpcaseAlsoIntrinsic": any
16+
>"ns:NamespacedUpcaseAlsoIntrinsic" : Symbol(IntrinsicElements["ns:NamespacedUpcaseAlsoIntrinsic"], Decl(jsxNamespacePrefixIntrinsics.tsx, 4, 6))
1417
}
1518
}
1619

1720
const valid = <ns:element ns:attribute="yep" />;
18-
>valid : Symbol(valid, Decl(jsxNamespacePrefixIntrinsics.tsx, 8, 5))
21+
>valid : Symbol(valid, Decl(jsxNamespacePrefixIntrinsics.tsx, 9, 5))
1922
>ns:element : Symbol(JSX.IntrinsicElements["ns:element"], Decl(jsxNamespacePrefixIntrinsics.tsx, 1, 31))
20-
>ns:attribute : Symbol(ns:attribute, Decl(jsxNamespacePrefixIntrinsics.tsx, 8, 25))
23+
>ns:attribute : Symbol(ns:attribute, Decl(jsxNamespacePrefixIntrinsics.tsx, 9, 25))
24+
25+
const validUpcase = <ns:NamespacedUpcaseAlsoIntrinsic />;
26+
>validUpcase : Symbol(validUpcase, Decl(jsxNamespacePrefixIntrinsics.tsx, 10, 5))
27+
>ns:NamespacedUpcaseAlsoIntrinsic : Symbol(JSX.IntrinsicElements["ns:NamespacedUpcaseAlsoIntrinsic"], Decl(jsxNamespacePrefixIntrinsics.tsx, 4, 6))
2128

2229
const invalid1 = <element />;
23-
>invalid1 : Symbol(invalid1, Decl(jsxNamespacePrefixIntrinsics.tsx, 10, 5))
30+
>invalid1 : Symbol(invalid1, Decl(jsxNamespacePrefixIntrinsics.tsx, 12, 5))
2431

2532
const invalid2 = <ns:element attribute="nope" />;
26-
>invalid2 : Symbol(invalid2, Decl(jsxNamespacePrefixIntrinsics.tsx, 11, 5))
33+
>invalid2 : Symbol(invalid2, Decl(jsxNamespacePrefixIntrinsics.tsx, 13, 5))
2734
>ns:element : Symbol(JSX.IntrinsicElements["ns:element"], Decl(jsxNamespacePrefixIntrinsics.tsx, 1, 31))
28-
>attribute : Symbol(attribute, Decl(jsxNamespacePrefixIntrinsics.tsx, 11, 28))
35+
>attribute : Symbol(attribute, Decl(jsxNamespacePrefixIntrinsics.tsx, 13, 28))
2936

3037
const invalid3 = <ns:element ns:invalid="nope" />;
31-
>invalid3 : Symbol(invalid3, Decl(jsxNamespacePrefixIntrinsics.tsx, 12, 5))
38+
>invalid3 : Symbol(invalid3, Decl(jsxNamespacePrefixIntrinsics.tsx, 14, 5))
3239
>ns:element : Symbol(JSX.IntrinsicElements["ns:element"], Decl(jsxNamespacePrefixIntrinsics.tsx, 1, 31))
33-
>ns:invalid : Symbol(ns:invalid, Decl(jsxNamespacePrefixIntrinsics.tsx, 12, 28))
40+
>ns:invalid : Symbol(ns:invalid, Decl(jsxNamespacePrefixIntrinsics.tsx, 14, 28))
3441

tests/baselines/reference/jsxNamespacePrefixIntrinsics.types

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ declare namespace JSX {
66

77
"ns:attribute": string;
88
>"ns:attribute" : string
9-
}
9+
10+
},
11+
"ns:NamespacedUpcaseAlsoIntrinsic": any
12+
>"ns:NamespacedUpcaseAlsoIntrinsic" : any
1013
}
1114
}
1215

@@ -16,6 +19,11 @@ const valid = <ns:element ns:attribute="yep" />;
1619
>ns:element : any
1720
>ns:attribute : string
1821

22+
const validUpcase = <ns:NamespacedUpcaseAlsoIntrinsic />;
23+
>validUpcase : any
24+
><ns:NamespacedUpcaseAlsoIntrinsic /> : any
25+
>ns:NamespacedUpcaseAlsoIntrinsic : any
26+
1927
const invalid1 = <element />;
2028
>invalid1 : any
2129
><element /> : any

tests/cases/compiler/jsxNamespacePrefixInName.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,9 @@ var endOfIdent2 = <a attr:={"value"} />;
2525

2626
var beginOfIdent1 = <:a attr={"value"} />;
2727
var beginOfIdent1 = <a :attr={"value"} />;
28+
29+
var Upcase = "mycomponent"
30+
var upcaseComponent1 = <ns:Upcase /> // Parsed as intrinsic: ok
31+
var upcaseComponent2 = <Upcase:element /> // Parsed as component: not ok
32+
33+
var upcaseComponentUndeclared = <NS:something />

tests/cases/compiler/jsxNamespacePrefixIntrinsics.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ declare namespace JSX {
55
interface IntrinsicElements {
66
"ns:element": {
77
"ns:attribute": string;
8-
}
8+
},
9+
"ns:NamespacedUpcaseAlsoIntrinsic": any
910
}
1011
}
1112

1213
const valid = <ns:element ns:attribute="yep" />;
14+
const validUpcase = <ns:NamespacedUpcaseAlsoIntrinsic />;
1315

1416
const invalid1 = <element />;
1517
const invalid2 = <ns:element attribute="nope" />;

0 commit comments

Comments
 (0)