Skip to content

Commit 83c6814

Browse files
committed
Add case for jsx namepsace intrinsics
1 parent d5b883a commit 83c6814

5 files changed

+136
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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; }'.
3+
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; }'.
5+
Property 'ns:invalid' does not exist on type '{ "ns:attribute": string; }'.
6+
7+
8+
==== tests/cases/compiler/jsxNamespacePrefixIntrinsics.tsx (3 errors) ====
9+
declare namespace JSX {
10+
interface IntrinsicElements {
11+
"ns:element": {
12+
"ns:attribute": string;
13+
}
14+
}
15+
}
16+
17+
const valid = <ns:element ns:attribute="yep" />;
18+
19+
const invalid1 = <element />;
20+
~~~~~~~~~~~
21+
!!! error TS2339: Property 'element' does not exist on type 'JSX.IntrinsicElements'.
22+
const invalid2 = <ns:element attribute="nope" />;
23+
~~~~~~~~~
24+
!!! error TS2322: Type '{ attribute: string; }' is not assignable to type '{ "ns:attribute": string; }'.
25+
!!! error TS2322: Property 'attribute' does not exist on type '{ "ns:attribute": string; }'.
26+
const invalid3 = <ns:element ns:invalid="nope" />;
27+
~~~~~~~~~~
28+
!!! error TS2322: Type '{ "ns:invalid": string; }' is not assignable to type '{ "ns:attribute": string; }'.
29+
!!! error TS2322: Property 'ns:invalid' does not exist on type '{ "ns:attribute": string; }'.
30+
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//// [jsxNamespacePrefixIntrinsics.tsx]
2+
declare namespace JSX {
3+
interface IntrinsicElements {
4+
"ns:element": {
5+
"ns:attribute": string;
6+
}
7+
}
8+
}
9+
10+
const valid = <ns:element ns:attribute="yep" />;
11+
12+
const invalid1 = <element />;
13+
const invalid2 = <ns:element attribute="nope" />;
14+
const invalid3 = <ns:element ns:invalid="nope" />;
15+
16+
17+
//// [jsxNamespacePrefixIntrinsics.jsx]
18+
var valid = <ns:element ns:attribute="yep"/>;
19+
var invalid1 = <element />;
20+
var invalid2 = <ns:element attribute="nope"/>;
21+
var invalid3 = <ns:element ns:invalid="nope"/>;
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
=== tests/cases/compiler/jsxNamespacePrefixIntrinsics.tsx ===
2+
declare namespace JSX {
3+
>JSX : Symbol(JSX, Decl(jsxNamespacePrefixIntrinsics.tsx, 0, 0))
4+
5+
interface IntrinsicElements {
6+
>IntrinsicElements : Symbol(IntrinsicElements, Decl(jsxNamespacePrefixIntrinsics.tsx, 0, 23))
7+
8+
"ns:element": {
9+
>"ns:element" : Symbol(IntrinsicElements["ns:element"], Decl(jsxNamespacePrefixIntrinsics.tsx, 1, 31))
10+
11+
"ns:attribute": string;
12+
>"ns:attribute" : Symbol("ns:attribute", Decl(jsxNamespacePrefixIntrinsics.tsx, 2, 19))
13+
}
14+
}
15+
}
16+
17+
const valid = <ns:element ns:attribute="yep" />;
18+
>valid : Symbol(valid, Decl(jsxNamespacePrefixIntrinsics.tsx, 8, 5))
19+
>ns:element : Symbol(JSX.IntrinsicElements["ns:element"], Decl(jsxNamespacePrefixIntrinsics.tsx, 1, 31))
20+
>ns:attribute : Symbol(ns:attribute, Decl(jsxNamespacePrefixIntrinsics.tsx, 8, 25))
21+
22+
const invalid1 = <element />;
23+
>invalid1 : Symbol(invalid1, Decl(jsxNamespacePrefixIntrinsics.tsx, 10, 5))
24+
25+
const invalid2 = <ns:element attribute="nope" />;
26+
>invalid2 : Symbol(invalid2, Decl(jsxNamespacePrefixIntrinsics.tsx, 11, 5))
27+
>ns:element : Symbol(JSX.IntrinsicElements["ns:element"], Decl(jsxNamespacePrefixIntrinsics.tsx, 1, 31))
28+
>attribute : Symbol(attribute, Decl(jsxNamespacePrefixIntrinsics.tsx, 11, 28))
29+
30+
const invalid3 = <ns:element ns:invalid="nope" />;
31+
>invalid3 : Symbol(invalid3, Decl(jsxNamespacePrefixIntrinsics.tsx, 12, 5))
32+
>ns:element : Symbol(JSX.IntrinsicElements["ns:element"], Decl(jsxNamespacePrefixIntrinsics.tsx, 1, 31))
33+
>ns:invalid : Symbol(ns:invalid, Decl(jsxNamespacePrefixIntrinsics.tsx, 12, 28))
34+
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
=== tests/cases/compiler/jsxNamespacePrefixIntrinsics.tsx ===
2+
declare namespace JSX {
3+
interface IntrinsicElements {
4+
"ns:element": {
5+
>"ns:element" : { "ns:attribute": string; }
6+
7+
"ns:attribute": string;
8+
>"ns:attribute" : string
9+
}
10+
}
11+
}
12+
13+
const valid = <ns:element ns:attribute="yep" />;
14+
>valid : any
15+
><ns:element ns:attribute="yep" /> : any
16+
>ns:element : any
17+
>ns:attribute : string
18+
19+
const invalid1 = <element />;
20+
>invalid1 : any
21+
><element /> : any
22+
>element : any
23+
24+
const invalid2 = <ns:element attribute="nope" />;
25+
>invalid2 : any
26+
><ns:element attribute="nope" /> : any
27+
>ns:element : any
28+
>attribute : string
29+
30+
const invalid3 = <ns:element ns:invalid="nope" />;
31+
>invalid3 : any
32+
><ns:element ns:invalid="nope" /> : any
33+
>ns:element : any
34+
>ns:invalid : string
35+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// @noImplicitAny: true
2+
// @jsx: preserve
3+
4+
declare namespace JSX {
5+
interface IntrinsicElements {
6+
"ns:element": {
7+
"ns:attribute": string;
8+
}
9+
}
10+
}
11+
12+
const valid = <ns:element ns:attribute="yep" />;
13+
14+
const invalid1 = <element />;
15+
const invalid2 = <ns:element attribute="nope" />;
16+
const invalid3 = <ns:element ns:invalid="nope" />;

0 commit comments

Comments
 (0)