File: typeGuardsObjectMethods.symbols

package info (click to toggle)
node-typescript 4.9.5%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 533,908 kB
  • sloc: javascript: 2,018,330; makefile: 7; sh: 1
file content (133 lines) | stat: -rw-r--r-- 6,539 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
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
=== tests/cases/conformance/expressions/typeGuards/typeGuardsObjectMethods.ts ===
// Note that type guards affect types of variables and parameters only and 
// have no effect on members of objects such as properties. 

// variables in global
var num: number;
>num : Symbol(num, Decl(typeGuardsObjectMethods.ts, 4, 3))

var strOrNum: string | number;
>strOrNum : Symbol(strOrNum, Decl(typeGuardsObjectMethods.ts, 5, 3))

var var1: string | number;
>var1 : Symbol(var1, Decl(typeGuardsObjectMethods.ts, 6, 3))

var obj1 = {
>obj1 : Symbol(obj1, Decl(typeGuardsObjectMethods.ts, 7, 3))

    // Inside method
    method(param: string | number) {
>method : Symbol(method, Decl(typeGuardsObjectMethods.ts, 7, 12))
>param : Symbol(param, Decl(typeGuardsObjectMethods.ts, 9, 11))

        // global vars in function declaration
        num = typeof var1 === "string" && var1.length; // string
>num : Symbol(num, Decl(typeGuardsObjectMethods.ts, 4, 3))
>var1 : Symbol(var1, Decl(typeGuardsObjectMethods.ts, 6, 3))
>var1.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
>var1 : Symbol(var1, Decl(typeGuardsObjectMethods.ts, 6, 3))
>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))

        // variables in function declaration
        var var2: string | number;
>var2 : Symbol(var2, Decl(typeGuardsObjectMethods.ts, 14, 11))

        num = typeof var2 === "string" && var2.length; // string
>num : Symbol(num, Decl(typeGuardsObjectMethods.ts, 4, 3))
>var2 : Symbol(var2, Decl(typeGuardsObjectMethods.ts, 14, 11))
>var2.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
>var2 : Symbol(var2, Decl(typeGuardsObjectMethods.ts, 14, 11))
>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))

        // parameters in function declaration
        num = typeof param === "string" && param.length; // string
>num : Symbol(num, Decl(typeGuardsObjectMethods.ts, 4, 3))
>param : Symbol(param, Decl(typeGuardsObjectMethods.ts, 9, 11))
>param.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
>param : Symbol(param, Decl(typeGuardsObjectMethods.ts, 9, 11))
>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))

        return strOrNum;
>strOrNum : Symbol(strOrNum, Decl(typeGuardsObjectMethods.ts, 5, 3))

    },
    get prop() {
>prop : Symbol(prop, Decl(typeGuardsObjectMethods.ts, 21, 6), Decl(typeGuardsObjectMethods.ts, 31, 6))

        // global vars in function declaration
        num = typeof var1 === "string" && var1.length; // string
>num : Symbol(num, Decl(typeGuardsObjectMethods.ts, 4, 3))
>var1 : Symbol(var1, Decl(typeGuardsObjectMethods.ts, 6, 3))
>var1.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
>var1 : Symbol(var1, Decl(typeGuardsObjectMethods.ts, 6, 3))
>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))

        // variables in function declaration
        var var2: string | number;
>var2 : Symbol(var2, Decl(typeGuardsObjectMethods.ts, 27, 11))

        num = typeof var2 === "string" && var2.length; // string
>num : Symbol(num, Decl(typeGuardsObjectMethods.ts, 4, 3))
>var2 : Symbol(var2, Decl(typeGuardsObjectMethods.ts, 27, 11))
>var2.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
>var2 : Symbol(var2, Decl(typeGuardsObjectMethods.ts, 27, 11))
>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))

        return strOrNum;
>strOrNum : Symbol(strOrNum, Decl(typeGuardsObjectMethods.ts, 5, 3))

    },
    set prop(param: string | number) {
>prop : Symbol(prop, Decl(typeGuardsObjectMethods.ts, 21, 6), Decl(typeGuardsObjectMethods.ts, 31, 6))
>param : Symbol(param, Decl(typeGuardsObjectMethods.ts, 32, 13))

        // global vars in function declaration
        num = typeof var1 === "string" && var1.length; // string
>num : Symbol(num, Decl(typeGuardsObjectMethods.ts, 4, 3))
>var1 : Symbol(var1, Decl(typeGuardsObjectMethods.ts, 6, 3))
>var1.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
>var1 : Symbol(var1, Decl(typeGuardsObjectMethods.ts, 6, 3))
>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))

        // variables in function declaration
        var var2: string | number;
>var2 : Symbol(var2, Decl(typeGuardsObjectMethods.ts, 37, 11))

        num = typeof var2 === "string" && var2.length; // string
>num : Symbol(num, Decl(typeGuardsObjectMethods.ts, 4, 3))
>var2 : Symbol(var2, Decl(typeGuardsObjectMethods.ts, 37, 11))
>var2.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
>var2 : Symbol(var2, Decl(typeGuardsObjectMethods.ts, 37, 11))
>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))

        // parameters in function declaration
        num = typeof param === "string" && param.length; // string
>num : Symbol(num, Decl(typeGuardsObjectMethods.ts, 4, 3))
>param : Symbol(param, Decl(typeGuardsObjectMethods.ts, 32, 13))
>param.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
>param : Symbol(param, Decl(typeGuardsObjectMethods.ts, 32, 13))
>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
    }
};
// return expression of the method
strOrNum = typeof obj1.method(strOrNum) === "string" && obj1.method(strOrNum); 
>strOrNum : Symbol(strOrNum, Decl(typeGuardsObjectMethods.ts, 5, 3))
>obj1.method : Symbol(method, Decl(typeGuardsObjectMethods.ts, 7, 12))
>obj1 : Symbol(obj1, Decl(typeGuardsObjectMethods.ts, 7, 3))
>method : Symbol(method, Decl(typeGuardsObjectMethods.ts, 7, 12))
>strOrNum : Symbol(strOrNum, Decl(typeGuardsObjectMethods.ts, 5, 3))
>obj1.method : Symbol(method, Decl(typeGuardsObjectMethods.ts, 7, 12))
>obj1 : Symbol(obj1, Decl(typeGuardsObjectMethods.ts, 7, 3))
>method : Symbol(method, Decl(typeGuardsObjectMethods.ts, 7, 12))
>strOrNum : Symbol(strOrNum, Decl(typeGuardsObjectMethods.ts, 5, 3))

// accessing getter property
strOrNum = typeof obj1.prop === "string" && obj1.prop; 
>strOrNum : Symbol(strOrNum, Decl(typeGuardsObjectMethods.ts, 5, 3))
>obj1.prop : Symbol(prop, Decl(typeGuardsObjectMethods.ts, 21, 6), Decl(typeGuardsObjectMethods.ts, 31, 6))
>obj1 : Symbol(obj1, Decl(typeGuardsObjectMethods.ts, 7, 3))
>prop : Symbol(prop, Decl(typeGuardsObjectMethods.ts, 21, 6), Decl(typeGuardsObjectMethods.ts, 31, 6))
>obj1.prop : Symbol(prop, Decl(typeGuardsObjectMethods.ts, 21, 6), Decl(typeGuardsObjectMethods.ts, 31, 6))
>obj1 : Symbol(obj1, Decl(typeGuardsObjectMethods.ts, 7, 3))
>prop : Symbol(prop, Decl(typeGuardsObjectMethods.ts, 21, 6), Decl(typeGuardsObjectMethods.ts, 31, 6))