File: tsxStatelessFunctionComponentsWithTypeArguments1.types

package info (click to toggle)
node-typescript 3.3.3333-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 324,548 kB
  • sloc: makefile: 6; sh: 3
file content (100 lines) | stat: -rw-r--r-- 2,881 bytes parent folder | download
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
=== tests/cases/conformance/jsx/file.tsx ===
import React = require('react')
>React : typeof React

declare function ComponentWithTwoAttributes<K,V>(l: {key1: K, value: V}): JSX.Element;
>ComponentWithTwoAttributes : <K, V>(l: { key1: K; value: V; }) => JSX.Element
>l : { key1: K; value: V; }
>key1 : K
>value : V
>JSX : any

// OK
function Baz<T,U>(key1: T, value: U) {
>Baz : <T, U>(key1: T, value: U) => void
>key1 : T
>value : U

    let a0 = <ComponentWithTwoAttributes key1={key1} value={value} />
>a0 : JSX.Element
><ComponentWithTwoAttributes key1={key1} value={value} /> : JSX.Element
>ComponentWithTwoAttributes : <K, V>(l: { key1: K; value: V; }) => JSX.Element
>key1 : T
>key1 : T
>value : U
>value : U

    let a1 = <ComponentWithTwoAttributes {...{key1, value: value}} key="Component" />
>a1 : JSX.Element
><ComponentWithTwoAttributes {...{key1, value: value}} key="Component" /> : JSX.Element
>ComponentWithTwoAttributes : <K, V>(l: { key1: K; value: V; }) => JSX.Element
>{key1, value: value} : { key1: T; value: U; }
>key1 : T
>value : U
>value : U
>key : string
}

declare function Link<U>(l: {func: (arg: U)=>void}): JSX.Element;
>Link : <U>(l: { func: (arg: U) => void; }) => JSX.Element
>l : { func: (arg: U) => void; }
>func : (arg: U) => void
>arg : U
>JSX : any

// OK
function createLink(func: (a: number)=>void) {
>createLink : (func: (a: number) => void) => void
>func : (a: number) => void
>a : number

    let o = <Link func={func} />
>o : JSX.Element
><Link func={func} /> : JSX.Element
>Link : <U>(l: { func: (arg: U) => void; }) => JSX.Element
>func : (a: number) => void
>func : (a: number) => void
}

function createLink1(func: (a: number)=>boolean) {
>createLink1 : (func: (a: number) => boolean) => void
>func : (a: number) => boolean
>a : number

    let o = <Link func={func} />
>o : JSX.Element
><Link func={func} /> : JSX.Element
>Link : <U>(l: { func: (arg: U) => void; }) => JSX.Element
>func : (a: number) => boolean
>func : (a: number) => boolean
}

interface InferParamProp<T> {
    values: Array<T>;
>values : T[]

    selectHandler: (selectedVal: T) => void;
>selectHandler : (selectedVal: T) => void
>selectedVal : T
}

declare function InferParamComponent<T>(attr: InferParamProp<T>): JSX.Element;
>InferParamComponent : <T>(attr: InferParamProp<T>) => JSX.Element
>attr : InferParamProp<T>
>JSX : any

// OK
let i = <InferParamComponent values={[1, 2, 3, 4]} selectHandler={(val) => { }} />;
>i : JSX.Element
><InferParamComponent values={[1, 2, 3, 4]} selectHandler={(val) => { }} /> : JSX.Element
>InferParamComponent : <T>(attr: InferParamProp<T>) => JSX.Element
>values : number[]
>[1, 2, 3, 4] : number[]
>1 : 1
>2 : 2
>3 : 3
>4 : 4
>selectHandler : (val: number) => void
>(val) => { } : (val: number) => void
>val : number