Skip to content

Commit d35d3f4

Browse files
committed
add test for catch with type unknown
1 parent d95d427 commit d35d3f4

File tree

4 files changed

+18
-0
lines changed

4 files changed

+18
-0
lines changed

javascript/ql/test/library-tests/TypeScript/Types/GetExprType.expected

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,13 @@
9090
| tst.ts:43:26:43:48 | { foo: ... s const | { readonly foo: "foo"; } |
9191
| tst.ts:43:28:43:30 | foo | "foo" |
9292
| tst.ts:43:33:43:37 | "foo" | "foo" |
93+
| tst.ts:47:8:47:8 | e | unknown |
94+
| tst.ts:48:7:48:14 | typeof e | "string" \| "number" \| "bigint" \| "boolean" \| "s... |
95+
| tst.ts:48:7:48:27 | typeof ... string" | boolean |
96+
| tst.ts:48:14:48:14 | e | unknown |
97+
| tst.ts:48:20:48:27 | "string" | "string" |
98+
| tst.ts:49:11:49:11 | b | string |
99+
| tst.ts:49:24:49:24 | e | string |
93100
| type_alias.ts:3:5:3:5 | b | boolean |
94101
| type_alias.ts:7:5:7:5 | c | ValueOrArray<number> |
95102
| type_alias.ts:14:9:14:32 | [proper ... ]: Json | any |

javascript/ql/test/library-tests/TypeScript/Types/GetTypeExprType.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
| tst.ts:39:60:39:65 | number | number |
6969
| tst.ts:39:60:39:67 | number[] | number[] |
7070
| tst.ts:40:18:40:24 | unknown | unknown |
71+
| tst.ts:49:15:49:20 | string | string |
7172
| type_alias.ts:1:6:1:6 | B | boolean |
7273
| type_alias.ts:1:10:1:16 | boolean | boolean |
7374
| type_alias.ts:3:8:3:8 | B | boolean |
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
| tst.ts:40:5:40:15 | unknownType | unknown |
2+
| tst.ts:47:8:47:8 | e | unknown |
3+
| tst.ts:48:14:48:14 | e | unknown |

javascript/ql/test/library-tests/TypeScript/Types/tst.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,11 @@ let unknownType: unknown;
4141

4242
let constArrayLiteral = [1, 2] as const;
4343
let constObjectLiteral = { foo: "foo" } as const;
44+
45+
46+
try { }
47+
catch (e: unknown) {
48+
if (typeof e === "string") {
49+
let b : string = e;
50+
}
51+
}

0 commit comments

Comments
 (0)