add test for catch with type unknown

This commit is contained in:
Erik Krogh Kristensen
2020-08-13 09:37:55 +02:00
parent d95d427c5b
commit d35d3f4271
4 changed files with 18 additions and 0 deletions

View File

@@ -90,6 +90,13 @@
| tst.ts:43:26:43:48 | { foo: ... s const | { readonly foo: "foo"; } |
| tst.ts:43:28:43:30 | foo | "foo" |
| tst.ts:43:33:43:37 | "foo" | "foo" |
| tst.ts:47:8:47:8 | e | unknown |
| tst.ts:48:7:48:14 | typeof e | "string" \| "number" \| "bigint" \| "boolean" \| "s... |
| tst.ts:48:7:48:27 | typeof ... string" | boolean |
| tst.ts:48:14:48:14 | e | unknown |
| tst.ts:48:20:48:27 | "string" | "string" |
| tst.ts:49:11:49:11 | b | string |
| tst.ts:49:24:49:24 | e | string |
| type_alias.ts:3:5:3:5 | b | boolean |
| type_alias.ts:7:5:7:5 | c | ValueOrArray<number> |
| type_alias.ts:14:9:14:32 | [proper ... ]: Json | any |

View File

@@ -68,6 +68,7 @@
| tst.ts:39:60:39:65 | number | number |
| tst.ts:39:60:39:67 | number[] | number[] |
| tst.ts:40:18:40:24 | unknown | unknown |
| tst.ts:49:15:49:20 | string | string |
| type_alias.ts:1:6:1:6 | B | boolean |
| type_alias.ts:1:10:1:16 | boolean | boolean |
| type_alias.ts:3:8:3:8 | B | boolean |

View File

@@ -1 +1,3 @@
| tst.ts:40:5:40:15 | unknownType | unknown |
| tst.ts:47:8:47:8 | e | unknown |
| tst.ts:48:14:48:14 | e | unknown |

View File

@@ -41,3 +41,11 @@ let unknownType: unknown;
let constArrayLiteral = [1, 2] as const;
let constObjectLiteral = { foo: "foo" } as const;
try { }
catch (e: unknown) {
if (typeof e === "string") {
let b : string = e;
}
}