File: tsxInferenceShouldNotYieldAnyOnUnions.symbols

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 (89 lines) | stat: -rw-r--r-- 3,460 bytes parent folder | download | duplicates (5)
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
=== tests/cases/compiler/index.tsx ===
namespace JSX {
>JSX : Symbol(JSX, Decl(index.tsx, 0, 0))

    export interface Element {}
>Element : Symbol(Element, Decl(index.tsx, 0, 15))
}

type Props<T> = PropsBase<string> | PropsWithConvert<T>;
>Props : Symbol(Props, Decl(index.tsx, 2, 1))
>T : Symbol(T, Decl(index.tsx, 4, 11))
>PropsBase : Symbol(PropsBase, Decl(index.tsx, 4, 56))
>PropsWithConvert : Symbol(PropsWithConvert, Decl(index.tsx, 8, 1))
>T : Symbol(T, Decl(index.tsx, 4, 11))

interface PropsBase<T> {
>PropsBase : Symbol(PropsBase, Decl(index.tsx, 4, 56))
>T : Symbol(T, Decl(index.tsx, 6, 20))

    data: T;
>data : Symbol(PropsBase.data, Decl(index.tsx, 6, 24))
>T : Symbol(T, Decl(index.tsx, 6, 20))
}

interface PropsWithConvert<T> extends PropsBase<T> {
>PropsWithConvert : Symbol(PropsWithConvert, Decl(index.tsx, 8, 1))
>T : Symbol(T, Decl(index.tsx, 10, 27))
>PropsBase : Symbol(PropsBase, Decl(index.tsx, 4, 56))
>T : Symbol(T, Decl(index.tsx, 10, 27))

    convert: (t: T) => string;
>convert : Symbol(PropsWithConvert.convert, Decl(index.tsx, 10, 52))
>t : Symbol(t, Decl(index.tsx, 11, 14))
>T : Symbol(T, Decl(index.tsx, 10, 27))
}

function ShouldInferFromData<T>(props: Props<T>): JSX.Element {
>ShouldInferFromData : Symbol(ShouldInferFromData, Decl(index.tsx, 12, 1))
>T : Symbol(T, Decl(index.tsx, 14, 29))
>props : Symbol(props, Decl(index.tsx, 14, 32))
>Props : Symbol(Props, Decl(index.tsx, 2, 1))
>T : Symbol(T, Decl(index.tsx, 14, 29))
>JSX : Symbol(JSX, Decl(index.tsx, 0, 0))
>Element : Symbol(JSX.Element, Decl(index.tsx, 0, 15))

    return <div />;
}

// Sanity check: function call equivalent versions work fine
ShouldInferFromData({ data: "1" });
>ShouldInferFromData : Symbol(ShouldInferFromData, Decl(index.tsx, 12, 1))
>data : Symbol(data, Decl(index.tsx, 19, 21))

ShouldInferFromData({ data: "1", convert: n => "" + n });
>ShouldInferFromData : Symbol(ShouldInferFromData, Decl(index.tsx, 12, 1))
>data : Symbol(data, Decl(index.tsx, 20, 21))
>convert : Symbol(convert, Decl(index.tsx, 20, 32))
>n : Symbol(n, Decl(index.tsx, 20, 41))
>n : Symbol(n, Decl(index.tsx, 20, 41))

ShouldInferFromData({ data: 2, convert: n => "" + n });
>ShouldInferFromData : Symbol(ShouldInferFromData, Decl(index.tsx, 12, 1))
>data : Symbol(data, Decl(index.tsx, 21, 21))
>convert : Symbol(convert, Decl(index.tsx, 21, 30))
>n : Symbol(n, Decl(index.tsx, 21, 39))
>n : Symbol(n, Decl(index.tsx, 21, 39))


const f1 = <ShouldInferFromData data={"1"} />;
>f1 : Symbol(f1, Decl(index.tsx, 24, 5))
>ShouldInferFromData : Symbol(ShouldInferFromData, Decl(index.tsx, 12, 1))
>data : Symbol(data, Decl(index.tsx, 24, 31))

const f2 = <ShouldInferFromData data={"1"} convert={n => "" + n} />;
>f2 : Symbol(f2, Decl(index.tsx, 25, 5))
>ShouldInferFromData : Symbol(ShouldInferFromData, Decl(index.tsx, 12, 1))
>data : Symbol(data, Decl(index.tsx, 25, 31))
>convert : Symbol(convert, Decl(index.tsx, 25, 42))
>n : Symbol(n, Decl(index.tsx, 25, 52))
>n : Symbol(n, Decl(index.tsx, 25, 52))

const f3 = <ShouldInferFromData data={2} convert={n => "" + n} />;
>f3 : Symbol(f3, Decl(index.tsx, 26, 5))
>ShouldInferFromData : Symbol(ShouldInferFromData, Decl(index.tsx, 12, 1))
>data : Symbol(data, Decl(index.tsx, 26, 31))
>convert : Symbol(convert, Decl(index.tsx, 26, 40))
>n : Symbol(n, Decl(index.tsx, 26, 50))
>n : Symbol(n, Decl(index.tsx, 26, 50))