File: truthinessCallExpressionCoercion1.symbols

package info (click to toggle)
node-typescript 4.1.3-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 396,552 kB
  • sloc: javascript: 1,444,377; makefile: 7; sh: 3
file content (187 lines) | stat: -rw-r--r-- 8,324 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
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
=== tests/cases/compiler/truthinessCallExpressionCoercion1.ts ===
function onlyErrorsWhenTestingNonNullableFunctionType(required: () => boolean, optional?: () => boolean) {
>onlyErrorsWhenTestingNonNullableFunctionType : Symbol(onlyErrorsWhenTestingNonNullableFunctionType, Decl(truthinessCallExpressionCoercion1.ts, 0, 0))
>required : Symbol(required, Decl(truthinessCallExpressionCoercion1.ts, 0, 54))
>optional : Symbol(optional, Decl(truthinessCallExpressionCoercion1.ts, 0, 78))

    // error
    required ? console.log('required') : undefined;
>required : Symbol(required, Decl(truthinessCallExpressionCoercion1.ts, 0, 54))
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
>console : Symbol(console, Decl(lib.dom.d.ts, --, --))
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
>undefined : Symbol(undefined)

    // ok
    optional ? console.log('optional') : undefined;
>optional : Symbol(optional, Decl(truthinessCallExpressionCoercion1.ts, 0, 78))
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
>console : Symbol(console, Decl(lib.dom.d.ts, --, --))
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
>undefined : Symbol(undefined)

    // ok
    !!required ? console.log('not required') : undefined;
>required : Symbol(required, Decl(truthinessCallExpressionCoercion1.ts, 0, 54))
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
>console : Symbol(console, Decl(lib.dom.d.ts, --, --))
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
>undefined : Symbol(undefined)

    // ok
    required() ? console.log('required call') : undefined;
>required : Symbol(required, Decl(truthinessCallExpressionCoercion1.ts, 0, 54))
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
>console : Symbol(console, Decl(lib.dom.d.ts, --, --))
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
>undefined : Symbol(undefined)
}

function onlyErrorsWhenUnusedInBody() {
>onlyErrorsWhenUnusedInBody : Symbol(onlyErrorsWhenUnusedInBody, Decl(truthinessCallExpressionCoercion1.ts, 12, 1))

    function test() { return Math.random() > 0.5; }
>test : Symbol(test, Decl(truthinessCallExpressionCoercion1.ts, 14, 39))
>Math.random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --))
>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --))

    // error
    test ? console.log('test') : undefined;
>test : Symbol(test, Decl(truthinessCallExpressionCoercion1.ts, 14, 39))
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
>console : Symbol(console, Decl(lib.dom.d.ts, --, --))
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
>undefined : Symbol(undefined)

    // ok
    test ? console.log(test) : undefined;
>test : Symbol(test, Decl(truthinessCallExpressionCoercion1.ts, 14, 39))
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
>console : Symbol(console, Decl(lib.dom.d.ts, --, --))
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
>test : Symbol(test, Decl(truthinessCallExpressionCoercion1.ts, 14, 39))
>undefined : Symbol(undefined)

    // ok
    test ? test() : undefined;
>test : Symbol(test, Decl(truthinessCallExpressionCoercion1.ts, 14, 39))
>test : Symbol(test, Decl(truthinessCallExpressionCoercion1.ts, 14, 39))
>undefined : Symbol(undefined)

    // ok
    test
>test : Symbol(test, Decl(truthinessCallExpressionCoercion1.ts, 14, 39))

        ? [() => null].forEach(() => { test(); })
>[() => null].forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --))
>forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --))
>test : Symbol(test, Decl(truthinessCallExpressionCoercion1.ts, 14, 39))

        : undefined;
>undefined : Symbol(undefined)

    // error
    test
>test : Symbol(test, Decl(truthinessCallExpressionCoercion1.ts, 14, 39))

        ? [() => null].forEach(test => { test() })
>[() => null].forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --))
>forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --))
>test : Symbol(test, Decl(truthinessCallExpressionCoercion1.ts, 33, 31))
>test : Symbol(test, Decl(truthinessCallExpressionCoercion1.ts, 33, 31))

        : undefined;
>undefined : Symbol(undefined)
}

function checksPropertyAccess() {
>checksPropertyAccess : Symbol(checksPropertyAccess, Decl(truthinessCallExpressionCoercion1.ts, 35, 1))

    const x = {
>x : Symbol(x, Decl(truthinessCallExpressionCoercion1.ts, 38, 9))

        foo: {
>foo : Symbol(foo, Decl(truthinessCallExpressionCoercion1.ts, 38, 15))

            bar() { return true; }
>bar : Symbol(bar, Decl(truthinessCallExpressionCoercion1.ts, 39, 14))
        }
    }

    // error
    x.foo.bar ? console.log('x.foo.bar') : undefined;
>x.foo.bar : Symbol(bar, Decl(truthinessCallExpressionCoercion1.ts, 39, 14))
>x.foo : Symbol(foo, Decl(truthinessCallExpressionCoercion1.ts, 38, 15))
>x : Symbol(x, Decl(truthinessCallExpressionCoercion1.ts, 38, 9))
>foo : Symbol(foo, Decl(truthinessCallExpressionCoercion1.ts, 38, 15))
>bar : Symbol(bar, Decl(truthinessCallExpressionCoercion1.ts, 39, 14))
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
>console : Symbol(console, Decl(lib.dom.d.ts, --, --))
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
>undefined : Symbol(undefined)

    // ok
    x.foo.bar ? x.foo.bar : undefined;
>x.foo.bar : Symbol(bar, Decl(truthinessCallExpressionCoercion1.ts, 39, 14))
>x.foo : Symbol(foo, Decl(truthinessCallExpressionCoercion1.ts, 38, 15))
>x : Symbol(x, Decl(truthinessCallExpressionCoercion1.ts, 38, 9))
>foo : Symbol(foo, Decl(truthinessCallExpressionCoercion1.ts, 38, 15))
>bar : Symbol(bar, Decl(truthinessCallExpressionCoercion1.ts, 39, 14))
>x.foo.bar : Symbol(bar, Decl(truthinessCallExpressionCoercion1.ts, 39, 14))
>x.foo : Symbol(foo, Decl(truthinessCallExpressionCoercion1.ts, 38, 15))
>x : Symbol(x, Decl(truthinessCallExpressionCoercion1.ts, 38, 9))
>foo : Symbol(foo, Decl(truthinessCallExpressionCoercion1.ts, 38, 15))
>bar : Symbol(bar, Decl(truthinessCallExpressionCoercion1.ts, 39, 14))
>undefined : Symbol(undefined)
}

class Foo {
>Foo : Symbol(Foo, Decl(truthinessCallExpressionCoercion1.ts, 49, 1))

    maybeIsUser?: () => boolean;
>maybeIsUser : Symbol(Foo.maybeIsUser, Decl(truthinessCallExpressionCoercion1.ts, 51, 11))

    isUser() {
>isUser : Symbol(Foo.isUser, Decl(truthinessCallExpressionCoercion1.ts, 52, 32))

        return true;
    }

    test() {
>test : Symbol(Foo.test, Decl(truthinessCallExpressionCoercion1.ts, 56, 5))

        // error
        this.isUser ? console.log('this.isUser') : undefined;
>this.isUser : Symbol(Foo.isUser, Decl(truthinessCallExpressionCoercion1.ts, 52, 32))
>this : Symbol(Foo, Decl(truthinessCallExpressionCoercion1.ts, 49, 1))
>isUser : Symbol(Foo.isUser, Decl(truthinessCallExpressionCoercion1.ts, 52, 32))
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
>console : Symbol(console, Decl(lib.dom.d.ts, --, --))
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
>undefined : Symbol(undefined)

        // ok
        this.maybeIsUser ? console.log('this.maybeIsUser') : undefined;
>this.maybeIsUser : Symbol(Foo.maybeIsUser, Decl(truthinessCallExpressionCoercion1.ts, 51, 11))
>this : Symbol(Foo, Decl(truthinessCallExpressionCoercion1.ts, 49, 1))
>maybeIsUser : Symbol(Foo.maybeIsUser, Decl(truthinessCallExpressionCoercion1.ts, 51, 11))
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
>console : Symbol(console, Decl(lib.dom.d.ts, --, --))
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
>undefined : Symbol(undefined)

        // ok
        if (this.isUser) {
>this.isUser : Symbol(Foo.isUser, Decl(truthinessCallExpressionCoercion1.ts, 52, 32))
>this : Symbol(Foo, Decl(truthinessCallExpressionCoercion1.ts, 49, 1))
>isUser : Symbol(Foo.isUser, Decl(truthinessCallExpressionCoercion1.ts, 52, 32))

            this.isUser();
>this.isUser : Symbol(Foo.isUser, Decl(truthinessCallExpressionCoercion1.ts, 52, 32))
>this : Symbol(Foo, Decl(truthinessCallExpressionCoercion1.ts, 49, 1))
>isUser : Symbol(Foo.isUser, Decl(truthinessCallExpressionCoercion1.ts, 52, 32))
        }
    }
}