Skip to content

Commit a6cae97

Browse files
committed
add test case
1 parent 6400c05 commit a6cae97

File tree

3 files changed

+118
-0
lines changed

3 files changed

+118
-0
lines changed

tests/baselines/reference/reachabilityChecks12.symbols

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,3 +111,41 @@ const d = (v: number) => {
111111
}
112112
};
113113

114+
// https://github.com/microsoft/TypeScript/issues/63004
115+
const report: (e: any) => never = (e): never => {
116+
>report : Symbol(report, Decl(reachabilityChecks12.ts, 59, 5))
117+
>e : Symbol(e, Decl(reachabilityChecks12.ts, 59, 15))
118+
>e : Symbol(e, Decl(reachabilityChecks12.ts, 59, 35))
119+
120+
throw e;
121+
>e : Symbol(e, Decl(reachabilityChecks12.ts, 59, 35))
122+
123+
};
124+
125+
const foo = async (): Promise<number> => {
126+
>foo : Symbol(foo, Decl(reachabilityChecks12.ts, 63, 5))
127+
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
128+
129+
try {
130+
return 3;
131+
} catch (e) {
132+
>e : Symbol(e, Decl(reachabilityChecks12.ts, 66, 11))
133+
134+
report(e);
135+
>report : Symbol(report, Decl(reachabilityChecks12.ts, 59, 5))
136+
>e : Symbol(e, Decl(reachabilityChecks12.ts, 66, 11))
137+
138+
} finally {
139+
if (Math.random()) {
140+
>Math.random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --))
141+
>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
142+
>random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --))
143+
144+
console.log("heh");
145+
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
146+
>console : Symbol(console, Decl(lib.dom.d.ts, --, --))
147+
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
148+
}
149+
}
150+
};
151+

tests/baselines/reference/reachabilityChecks12.types

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,3 +195,66 @@ const d = (v: number) => {
195195
}
196196
};
197197

198+
// https://github.com/microsoft/TypeScript/issues/63004
199+
const report: (e: any) => never = (e): never => {
200+
>report : (e: any) => never
201+
> : ^ ^^ ^^^^^
202+
>e : any
203+
>(e): never => { throw e;} : (e: any) => never
204+
> : ^ ^^^^^^^^^^
205+
>e : any
206+
207+
throw e;
208+
>e : any
209+
210+
};
211+
212+
const foo = async (): Promise<number> => {
213+
>foo : () => Promise<number>
214+
> : ^^^^^^
215+
>async (): Promise<number> => { try { return 3; } catch (e) { report(e); } finally { if (Math.random()) { console.log("heh"); } }} : () => Promise<number>
216+
> : ^^^^^^
217+
218+
try {
219+
return 3;
220+
>3 : 3
221+
> : ^
222+
223+
} catch (e) {
224+
>e : unknown
225+
> : ^^^^^^^
226+
227+
report(e);
228+
>report(e) : never
229+
> : ^^^^^
230+
>report : (e: any) => never
231+
> : ^ ^^ ^^^^^
232+
>e : unknown
233+
> : ^^^^^^^
234+
235+
} finally {
236+
if (Math.random()) {
237+
>Math.random() : number
238+
> : ^^^^^^
239+
>Math.random : () => number
240+
> : ^^^^^^
241+
>Math : Math
242+
> : ^^^^
243+
>random : () => number
244+
> : ^^^^^^
245+
246+
console.log("heh");
247+
>console.log("heh") : void
248+
> : ^^^^
249+
>console.log : (...data: any[]) => void
250+
> : ^^^^ ^^ ^^^^^
251+
>console : Console
252+
> : ^^^^^^^
253+
>log : (...data: any[]) => void
254+
> : ^^^^ ^^ ^^^^^
255+
>"heh" : "heh"
256+
> : ^^^^^
257+
}
258+
}
259+
};
260+

tests/cases/compiler/reachabilityChecks12.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,20 @@ const d = (v: number) => {
5959
}
6060
}
6161
};
62+
63+
// https://github.com/microsoft/TypeScript/issues/63004
64+
const report: (e: any) => never = (e): never => {
65+
throw e;
66+
};
67+
68+
const foo = async (): Promise<number> => {
69+
try {
70+
return 3;
71+
} catch (e) {
72+
report(e);
73+
} finally {
74+
if (Math.random()) {
75+
console.log("heh");
76+
}
77+
}
78+
};

0 commit comments

Comments
 (0)