File: catchClauseWithTypeAnnotation.symbols

package info (click to toggle)
node-typescript 4.9.5%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 533,908 kB
  • sloc: javascript: 2,018,330; makefile: 7; sh: 1
file content (137 lines) | stat: -rw-r--r-- 6,703 bytes parent folder | download | duplicates (3)
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
=== tests/cases/conformance/statements/tryStatements/catchClauseWithTypeAnnotation.ts ===
type any1 = any;
>any1 : Symbol(any1, Decl(catchClauseWithTypeAnnotation.ts, 0, 0))

type unknown1 = unknown;
>unknown1 : Symbol(unknown1, Decl(catchClauseWithTypeAnnotation.ts, 0, 16))

function fn(x: boolean) {
>fn : Symbol(fn, Decl(catchClauseWithTypeAnnotation.ts, 1, 24))
>x : Symbol(x, Decl(catchClauseWithTypeAnnotation.ts, 3, 12), Decl(catchClauseWithTypeAnnotation.ts, 29, 27), Decl(catchClauseWithTypeAnnotation.ts, 30, 27))

    // no type annotation allowed other than `any` and `unknown`
    try { } catch (x) { } // should be OK
>x : Symbol(x, Decl(catchClauseWithTypeAnnotation.ts, 6, 19))

    try { } catch (x: any) { } // should be OK
>x : Symbol(x, Decl(catchClauseWithTypeAnnotation.ts, 7, 19))

    try { } catch (x: any1) { } // should be OK
>x : Symbol(x, Decl(catchClauseWithTypeAnnotation.ts, 8, 19))
>any1 : Symbol(any1, Decl(catchClauseWithTypeAnnotation.ts, 0, 0))

    try { } catch (x: unknown) { } // should be OK
>x : Symbol(x, Decl(catchClauseWithTypeAnnotation.ts, 9, 19))

    try { } catch (x: unknown1) { } // should be OK
>x : Symbol(x, Decl(catchClauseWithTypeAnnotation.ts, 10, 19))
>unknown1 : Symbol(unknown1, Decl(catchClauseWithTypeAnnotation.ts, 0, 16))

    try { } catch (x) { x.foo; } // should be OK
>x : Symbol(x, Decl(catchClauseWithTypeAnnotation.ts, 11, 19))
>x : Symbol(x, Decl(catchClauseWithTypeAnnotation.ts, 11, 19))

    try { } catch (x: any) { x.foo; } // should be OK
>x : Symbol(x, Decl(catchClauseWithTypeAnnotation.ts, 12, 19))
>x : Symbol(x, Decl(catchClauseWithTypeAnnotation.ts, 12, 19))

    try { } catch (x: any1) { x.foo; } // should be OK
>x : Symbol(x, Decl(catchClauseWithTypeAnnotation.ts, 13, 19))
>any1 : Symbol(any1, Decl(catchClauseWithTypeAnnotation.ts, 0, 0))
>x : Symbol(x, Decl(catchClauseWithTypeAnnotation.ts, 13, 19))

    try { } catch (x: unknown) { console.log(x); } // should be OK
>x : Symbol(x, Decl(catchClauseWithTypeAnnotation.ts, 14, 19))
>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, --, --))
>x : Symbol(x, Decl(catchClauseWithTypeAnnotation.ts, 14, 19))

    try { } catch (x: unknown1) { console.log(x); } // should be OK
>x : Symbol(x, Decl(catchClauseWithTypeAnnotation.ts, 15, 19))
>unknown1 : Symbol(unknown1, Decl(catchClauseWithTypeAnnotation.ts, 0, 16))
>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, --, --))
>x : Symbol(x, Decl(catchClauseWithTypeAnnotation.ts, 15, 19))

    try { } catch (x: unknown) { x.foo; } // error in the body
>x : Symbol(x, Decl(catchClauseWithTypeAnnotation.ts, 16, 19))
>x : Symbol(x, Decl(catchClauseWithTypeAnnotation.ts, 16, 19))

    try { } catch (x: unknown1) { x.foo; } // error in the body
>x : Symbol(x, Decl(catchClauseWithTypeAnnotation.ts, 17, 19))
>unknown1 : Symbol(unknown1, Decl(catchClauseWithTypeAnnotation.ts, 0, 16))
>x : Symbol(x, Decl(catchClauseWithTypeAnnotation.ts, 17, 19))

    try { } catch (x: Error) { } // error in the type
>x : Symbol(x, Decl(catchClauseWithTypeAnnotation.ts, 18, 19))
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))

    try { } catch (x: object) { } // error in the type
>x : Symbol(x, Decl(catchClauseWithTypeAnnotation.ts, 19, 19))

    try { console.log(); }
>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, --, --))

    // @ts-ignore
    catch (e: number) { // e should not be a `number`
>e : Symbol(e, Decl(catchClauseWithTypeAnnotation.ts, 23, 11))

        console.log(e.toLowerCase());
>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, --, --))
>e : Symbol(e, Decl(catchClauseWithTypeAnnotation.ts, 23, 11))
    }

    // minor bug: shows that the `catch` argument is skipped when checking scope
    try { } catch (x) { let x: string; }
>x : Symbol(x, Decl(catchClauseWithTypeAnnotation.ts, 28, 19))
>x : Symbol(x, Decl(catchClauseWithTypeAnnotation.ts, 28, 27))

    try { } catch (x) { var x: string; }
>x : Symbol(x, Decl(catchClauseWithTypeAnnotation.ts, 29, 19))
>x : Symbol(x, Decl(catchClauseWithTypeAnnotation.ts, 3, 12), Decl(catchClauseWithTypeAnnotation.ts, 29, 27), Decl(catchClauseWithTypeAnnotation.ts, 30, 27))

    try { } catch (x) { var x: boolean; }
>x : Symbol(x, Decl(catchClauseWithTypeAnnotation.ts, 30, 19))
>x : Symbol(x, Decl(catchClauseWithTypeAnnotation.ts, 3, 12), Decl(catchClauseWithTypeAnnotation.ts, 29, 27), Decl(catchClauseWithTypeAnnotation.ts, 30, 27))

    try { } catch ({ x }) { } // should be OK
>x : Symbol(x, Decl(catchClauseWithTypeAnnotation.ts, 32, 20))

    try { } catch ({ x }: any) { x.foo; } // should be OK
>x : Symbol(x, Decl(catchClauseWithTypeAnnotation.ts, 33, 20))
>x : Symbol(x, Decl(catchClauseWithTypeAnnotation.ts, 33, 20))

    try { } catch ({ x }: any1) { x.foo;} // should be OK
>x : Symbol(x, Decl(catchClauseWithTypeAnnotation.ts, 34, 20))
>any1 : Symbol(any1, Decl(catchClauseWithTypeAnnotation.ts, 0, 0))
>x : Symbol(x, Decl(catchClauseWithTypeAnnotation.ts, 34, 20))

    try { } catch ({ x }: unknown) { console.log(x); } // should be OK
>x : Symbol(x, Decl(catchClauseWithTypeAnnotation.ts, 35, 20))
>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, --, --))
>x : Symbol(x, Decl(catchClauseWithTypeAnnotation.ts, 35, 20))

    try { } catch ({ x }: unknown1) { console.log(x); } // should be OK
>x : Symbol(x, Decl(catchClauseWithTypeAnnotation.ts, 36, 20))
>unknown1 : Symbol(unknown1, Decl(catchClauseWithTypeAnnotation.ts, 0, 16))
>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, --, --))
>x : Symbol(x, Decl(catchClauseWithTypeAnnotation.ts, 36, 20))

    try { } catch ({ x }: object) { } // error in the type
>x : Symbol(x, Decl(catchClauseWithTypeAnnotation.ts, 37, 20))

    try { } catch ({ x }: Error) { } // error in the type
>x : Symbol(x, Decl(catchClauseWithTypeAnnotation.ts, 38, 20))
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
}