File: jsxChildrenGenericContextualTypes.types

package info (click to toggle)
node-typescript 5.0.4%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 459,140 kB
  • sloc: javascript: 1,972,754; makefile: 6; sh: 1
file content (143 lines) | stat: -rw-r--r-- 4,958 bytes parent folder | download | duplicates (4)
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
=== tests/cases/compiler/jsxChildrenGenericContextualTypes.tsx ===
namespace JSX {
    export interface Element {}
    export interface ElementAttributesProperty { props: {}; }
>props : {}

    export interface ElementChildrenAttribute { children: {}; }
>children : {}

    export interface IntrinsicAttributes {}
    export interface IntrinsicElements { [key: string]: Element }
>key : string
}
const Elem = <T,U=never>(p: { prop: T, children: (t: T) => T }) => <div></div>;
>Elem : <T, U = never>(p: { prop: T; children: (t: T) => T; }) => JSX.Element
><T,U=never>(p: { prop: T, children: (t: T) => T }) => <div></div> : <T, U = never>(p: { prop: T; children: (t: T) => T; }) => JSX.Element
>p : { prop: T; children: (t: T) => T; }
>prop : T
>children : (t: T) => T
>t : T
><div></div> : JSX.Element
>div : any
>div : any

Elem({prop: {a: "x"}, children: i => ({a: "z"})});
>Elem({prop: {a: "x"}, children: i => ({a: "z"})}) : JSX.Element
>Elem : <T, U = never>(p: { prop: T; children: (t: T) => T; }) => JSX.Element
>{prop: {a: "x"}, children: i => ({a: "z"})} : { prop: { a: string; }; children: (i: { a: string; }) => { a: string; }; }
>prop : { a: string; }
>{a: "x"} : { a: string; }
>a : string
>"x" : "x"
>children : (i: { a: string; }) => { a: string; }
>i => ({a: "z"}) : (i: { a: string; }) => { a: string; }
>i : { a: string; }
>({a: "z"}) : { a: string; }
>{a: "z"} : { a: string; }
>a : string
>"z" : "z"

const q = <Elem prop={{a: "x"}} children={i => ({a: "z"})} />
>q : JSX.Element
><Elem prop={{a: "x"}} children={i => ({a: "z"})} /> : JSX.Element
>Elem : <T, U = never>(p: { prop: T; children: (t: T) => T; }) => JSX.Element
>prop : { a: string; }
>{a: "x"} : { a: string; }
>a : string
>"x" : "x"
>children : (i: { a: string; }) => { a: string; }
>i => ({a: "z"}) : (i: { a: string; }) => { a: string; }
>i : { a: string; }
>({a: "z"}) : { a: string; }
>{a: "z"} : { a: string; }
>a : string
>"z" : "z"

const qq = <Elem prop={{a: "x"}}>{i => ({a: "z"})}</Elem>
>qq : JSX.Element
><Elem prop={{a: "x"}}>{i => ({a: "z"})}</Elem> : JSX.Element
>Elem : <T, U = never>(p: { prop: T; children: (t: T) => T; }) => JSX.Element
>prop : { a: string; }
>{a: "x"} : { a: string; }
>a : string
>"x" : "x"
>i => ({a: "z"}) : (i: { a: string; }) => { a: string; }
>i : { a: string; }
>({a: "z"}) : { a: string; }
>{a: "z"} : { a: string; }
>a : string
>"z" : "z"
>Elem : <T, U = never>(p: { prop: T; children: (t: T) => T; }) => JSX.Element

interface LitProps<T> { prop: T, children: (x: this) => T }
>prop : T
>children : (x: this) => T
>x : this

const ElemLit = <T extends string>(p: LitProps<T>) => <div></div>;
>ElemLit : <T extends string>(p: LitProps<T>) => JSX.Element
><T extends string>(p: LitProps<T>) => <div></div> : <T extends string>(p: LitProps<T>) => JSX.Element
>p : LitProps<T>
><div></div> : JSX.Element
>div : any
>div : any

ElemLit({prop: "x", children: () => "x"});
>ElemLit({prop: "x", children: () => "x"}) : JSX.Element
>ElemLit : <T extends string>(p: LitProps<T>) => JSX.Element
>{prop: "x", children: () => "x"} : { prop: "x"; children: () => "x"; }
>prop : "x"
>"x" : "x"
>children : () => "x"
>() => "x" : () => "x"
>"x" : "x"

const j = <ElemLit prop="x" children={() => "x"} />
>j : JSX.Element
><ElemLit prop="x" children={() => "x"} /> : JSX.Element
>ElemLit : <T extends string>(p: LitProps<T>) => JSX.Element
>prop : "x"
>children : () => "x"
>() => "x" : () => "x"
>"x" : "x"

const jj = <ElemLit prop="x">{() => "x"}</ElemLit>
>jj : JSX.Element
><ElemLit prop="x">{() => "x"}</ElemLit> : JSX.Element
>ElemLit : <T extends string>(p: LitProps<T>) => JSX.Element
>prop : "x"
>() => "x" : () => "x"
>"x" : "x"
>ElemLit : <T extends string>(p: LitProps<T>) => JSX.Element

// Should error
const arg = <ElemLit prop="x" children={p => "y"} />
>arg : JSX.Element
><ElemLit prop="x" children={p => "y"} /> : JSX.Element
>ElemLit : <T extends string>(p: LitProps<T>) => JSX.Element
>prop : "x"
>children : (p: JSX.IntrinsicAttributes & LitProps<"x">) => "y"
>p => "y" : (p: JSX.IntrinsicAttributes & LitProps<"x">) => "y"
>p : JSX.IntrinsicAttributes & LitProps<"x">
>"y" : "y"

const argchild = <ElemLit prop="x">{p => "y"}</ElemLit>
>argchild : JSX.Element
><ElemLit prop="x">{p => "y"}</ElemLit> : JSX.Element
>ElemLit : <T extends string>(p: LitProps<T>) => JSX.Element
>prop : "x"
>p => "y" : (p: JSX.IntrinsicAttributes & LitProps<"x">) => "y"
>p : JSX.IntrinsicAttributes & LitProps<"x">
>"y" : "y"
>ElemLit : <T extends string>(p: LitProps<T>) => JSX.Element

const mismatched = <ElemLit prop="x">{() => 12}</ElemLit>
>mismatched : JSX.Element
><ElemLit prop="x">{() => 12}</ElemLit> : JSX.Element
>ElemLit : <T extends string>(p: LitProps<T>) => JSX.Element
>prop : "x"
>() => 12 : () => number
>12 : 12
>ElemLit : <T extends string>(p: LitProps<T>) => JSX.Element