Skip to content

Commit d61ffe1

Browse files
committed
[test] Intrinsics with colon no longer type-checked
1 parent bdcf8ab commit d61ffe1

File tree

5 files changed

+80
-5
lines changed

5 files changed

+80
-5
lines changed

tests/baselines/reference/jsxElementType.errors.txt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,4 +197,14 @@ tests/cases/compiler/jsxElementType.tsx(99,2): error TS2304: Cannot find name 'U
197197
<Unresolved foo="abc" />;
198198
~~~~~~~~~~
199199
!!! error TS2304: Cannot find name 'Unresolved'.
200-
200+
201+
// regression test for intrinsic containing `:`
202+
declare global {
203+
namespace JSX {
204+
interface IntrinsicElements {
205+
['fbt:enum']: { knownProp: string };
206+
}
207+
}
208+
}
209+
210+
<fbt:enum knownProp="accepted" unknownProp="rejected" />;

tests/baselines/reference/jsxElementType.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,17 @@ function f1<T extends (props: {}) => React.ReactElement<any>>(Component: T) {
9898

9999
<Unresolved />;
100100
<Unresolved foo="abc" />;
101-
101+
102+
// regression test for intrinsic containing `:`
103+
declare global {
104+
namespace JSX {
105+
interface IntrinsicElements {
106+
['fbt:enum']: { knownProp: string };
107+
}
108+
}
109+
}
110+
111+
<fbt:enum knownProp="accepted" unknownProp="rejected" />;
102112

103113
//// [jsxElementType.js]
104114
"use strict";
@@ -231,3 +241,4 @@ function f1(Component) {
231241
}
232242
React.createElement(Unresolved, null);
233243
React.createElement(Unresolved, { foo: "abc" });
244+
React.createElement("fbt:enum", { knownProp: "accepted", unknownProp: "rejected" });

tests/baselines/reference/jsxElementType.symbols

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,17 @@ type NewReactJSXElementConstructor<P> =
4949
>P : Symbol(P, Decl(jsxElementType.tsx, 16, 35))
5050

5151
declare global {
52-
>global : Symbol(global, Decl(jsxElementType.tsx, 18, 48))
52+
>global : Symbol(global, Decl(jsxElementType.tsx, 18, 48), Decl(jsxElementType.tsx, 98, 25))
5353

5454
namespace JSX {
55-
>JSX : Symbol(JSX, Decl(react16.d.ts, 2493, 12), Decl(jsxElementType.tsx, 20, 16))
55+
>JSX : Symbol(JSX, Decl(react16.d.ts, 2493, 12), Decl(jsxElementType.tsx, 20, 16), Decl(jsxElementType.tsx, 101, 16))
5656

5757
type ElementType = string | NewReactJSXElementConstructor<any>;
5858
>ElementType : Symbol(ElementType, Decl(jsxElementType.tsx, 21, 17))
5959
>NewReactJSXElementConstructor : Symbol(NewReactJSXElementConstructor, Decl(jsxElementType.tsx, 13, 30))
6060

6161
interface IntrinsicElements {
62-
>IntrinsicElements : Symbol(IntrinsicElements, Decl(react16.d.ts, 2514, 86), Decl(jsxElementType.tsx, 22, 67))
62+
>IntrinsicElements : Symbol(IntrinsicElements, Decl(react16.d.ts, 2514, 86), Decl(jsxElementType.tsx, 22, 67), Decl(jsxElementType.tsx, 102, 17))
6363

6464
['my-custom-element']: React.DOMAttributes<unknown>;
6565
>['my-custom-element'] : Symbol(IntrinsicElements['my-custom-element'], Decl(jsxElementType.tsx, 23, 33))
@@ -272,3 +272,25 @@ function f1<T extends (props: {}) => React.ReactElement<any>>(Component: T) {
272272
<Unresolved foo="abc" />;
273273
>foo : Symbol(foo, Decl(jsxElementType.tsx, 98, 11))
274274

275+
// regression test for intrinsic containing `:`
276+
declare global {
277+
>global : Symbol(global, Decl(jsxElementType.tsx, 18, 48), Decl(jsxElementType.tsx, 98, 25))
278+
279+
namespace JSX {
280+
>JSX : Symbol(JSX, Decl(react16.d.ts, 2493, 12), Decl(jsxElementType.tsx, 20, 16), Decl(jsxElementType.tsx, 101, 16))
281+
282+
interface IntrinsicElements {
283+
>IntrinsicElements : Symbol(IntrinsicElements, Decl(react16.d.ts, 2514, 86), Decl(jsxElementType.tsx, 22, 67), Decl(jsxElementType.tsx, 102, 17))
284+
285+
['fbt:enum']: { knownProp: string };
286+
>['fbt:enum'] : Symbol(IntrinsicElements['fbt:enum'], Decl(jsxElementType.tsx, 103, 33))
287+
>'fbt:enum' : Symbol(IntrinsicElements['fbt:enum'], Decl(jsxElementType.tsx, 103, 33))
288+
>knownProp : Symbol(knownProp, Decl(jsxElementType.tsx, 104, 21))
289+
}
290+
}
291+
}
292+
293+
<fbt:enum knownProp="accepted" unknownProp="rejected" />;
294+
>knownProp : Symbol(knownProp, Decl(jsxElementType.tsx, 109, 9))
295+
>unknownProp : Symbol(unknownProp, Decl(jsxElementType.tsx, 109, 30))
296+

tests/baselines/reference/jsxElementType.types

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,3 +290,24 @@ function f1<T extends (props: {}) => React.ReactElement<any>>(Component: T) {
290290
>Unresolved : any
291291
>foo : string
292292

293+
// regression test for intrinsic containing `:`
294+
declare global {
295+
>global : any
296+
297+
namespace JSX {
298+
interface IntrinsicElements {
299+
['fbt:enum']: { knownProp: string };
300+
>['fbt:enum'] : { knownProp: string; }
301+
>'fbt:enum' : "fbt:enum"
302+
>knownProp : string
303+
}
304+
}
305+
}
306+
307+
<fbt:enum knownProp="accepted" unknownProp="rejected" />;
308+
><fbt:enum knownProp="accepted" unknownProp="rejected" /> : JSX.Element
309+
>fbt : any
310+
>enum : any
311+
>knownProp : string
312+
>unknownProp : string
313+

tests/cases/compiler/jsxElementType.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,14 @@ function f1<T extends (props: {}) => React.ReactElement<any>>(Component: T) {
9999

100100
<Unresolved />;
101101
<Unresolved foo="abc" />;
102+
103+
// regression test for intrinsic containing `:`
104+
declare global {
105+
namespace JSX {
106+
interface IntrinsicElements {
107+
['fbt:enum']: { knownProp: string };
108+
}
109+
}
110+
}
111+
112+
<fbt:enum knownProp="accepted" unknownProp="rejected" />;

0 commit comments

Comments
 (0)