forked from microsoft/TypeScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjsxIntrinsicElementsCompatability.types
More file actions
50 lines (44 loc) · 1.66 KB
/
jsxIntrinsicElementsCompatability.types
File metadata and controls
50 lines (44 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//// [tests/cases/compiler/jsxIntrinsicElementsCompatability.tsx] ////
=== Performance Stats ===
Assignability cache: 2,500
Type Count: 10,000
Instantiation count: 100,000
Symbol count: 100,000
=== jsxIntrinsicElementsCompatability.tsx ===
/// <reference path="react16.d.ts" />
import * as React from "react";
>React : typeof React
> : ^^^^^^^^^^^^
function SomeComponent<T extends 'button' | 'a'>(props: { element?: T } & JSX.IntrinsicElements[T]): JSX.Element {
>SomeComponent : <T extends "button" | "a">(props: { element?: T; } & JSX.IntrinsicElements[T]) => JSX.Element
> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^
>props : { element?: T; } & JSX.IntrinsicElements[T]
> : ^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>element : T | undefined
> : ^^^^^^^^^^^^^
>JSX : any
> : ^^^
>JSX : any
> : ^^^
// Just so the return value is RectElement, the rendered element doesnt matter
return <div />
><div /> : JSX.Element
> : ^^^^^^^^^^^
>div : any
> : ^^^
}
function Test<T extends 'button' | 'a'>(el: T) {
>Test : <T extends "button" | "a">(el: T) => JSX.Element
> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^^^^^^^^
>el : T
> : ^
return <SomeComponent element={el} />
><SomeComponent element={el} /> : JSX.Element
> : ^^^^^^^^^^^
>SomeComponent : <T_1 extends "button" | "a">(props: { element?: T_1; } & JSX.IntrinsicElements[T_1]) => JSX.Element
> : ^^^^^^^^^^^^^ ^^ ^^ ^^^^^
>element : T
> : ^
>el : T
> : ^
}