forked from microsoft/TypeScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjsxInferenceProducesLiteralAsExpected.types
More file actions
91 lines (79 loc) · 2.22 KB
/
jsxInferenceProducesLiteralAsExpected.types
File metadata and controls
91 lines (79 loc) · 2.22 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
//// [tests/cases/compiler/jsxInferenceProducesLiteralAsExpected.tsx] ////
=== Performance Stats ===
Assignability cache: 1,000
Type Count: 5,000
Instantiation count: 10,000
=== jsxInferenceProducesLiteralAsExpected.tsx ===
import React = require("react");
>React : typeof React
> : ^^^^^^^^^^^^
type FunctionPropertyNames<T> = { [K in keyof T]: T[K] extends Function ? K : never }[keyof T];
>FunctionPropertyNames : FunctionPropertyNames<T>
> : ^^^^^^^^^^^^^^^^^^^^^^^^
class TestObject {
>TestObject : TestObject
> : ^^^^^^^^^^
a: string = '';
>a : string
> : ^^^^^^
>'' : ""
> : ^^
b: number = 1;
>b : number
> : ^^^^^^
>1 : 1
> : ^
c: () => void = () => { };
>c : () => void
> : ^^^^^^
>() => { } : () => void
> : ^^^^^^^^^^
}
interface TestProps<T> {
model: T;
>model : T
> : ^
foo: FunctionPropertyNames<T>;
>foo : FunctionPropertyNames<T>
> : ^^^^^^^^^^^^^^^^^^^^^^^^
}
function Test<T>(props: TestProps<T>) { return <></>; }
>Test : <T>(props: TestProps<T>) => JSX.Element
> : ^ ^^ ^^ ^^^^^^^^^^^^^^^^
>props : TestProps<T>
> : ^^^^^^^^^^^^
><></> : JSX.Element
> : ^^^^^^^^^^^
const model = new TestObject();
>model : TestObject
> : ^^^^^^^^^^
>new TestObject() : TestObject
> : ^^^^^^^^^^
>TestObject : typeof TestObject
> : ^^^^^^^^^^^^^^^^^
const el1 = <Test model={model} foo="c" />;
>el1 : JSX.Element
> : ^^^^^^^^^^^
><Test model={model} foo="c" /> : JSX.Element
> : ^^^^^^^^^^^
>Test : <T>(props: TestProps<T>) => JSX.Element
> : ^ ^^ ^^ ^^^^^^^^^^^^^^^^
>model : TestObject
> : ^^^^^^^^^^
>model : TestObject
> : ^^^^^^^^^^
>foo : "c"
> : ^^^
const el2 = <Test<TestObject> model={model} foo="c" />;
>el2 : JSX.Element
> : ^^^^^^^^^^^
><Test<TestObject> model={model} foo="c" /> : JSX.Element
> : ^^^^^^^^^^^
>Test : <T>(props: TestProps<T>) => JSX.Element
> : ^ ^^ ^^ ^^^^^^^^^^^^^^^^
>model : TestObject
> : ^^^^^^^^^^
>model : TestObject
> : ^^^^^^^^^^
>foo : "c"
> : ^^^