Add test case for 'useUnknownInCatchVariables'.

This commit is contained in:
Daniel Rosenwasser
2020-10-08 16:43:00 -07:00
parent 1bd8e388ae
commit 67b4b9076d

View File

@@ -0,0 +1,23 @@
// @useUnknownInCatchVariables: true
try {
// ...
}
catch (e) {
// error!
void e.toUpperCase();
void e++;
void e();
if (typeof e === "string") {
// works!
// We've narrowed 'e' down to the type 'string'.
console.log(e.toUpperCase());
}
if (e instanceof Error) {
e.stack?.toUpperCase();
}
if (typeof e === "number") {
e++;
}
}