Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bcb3d5a

Browse files
committed
add tests for nested type unions through aliases
1 parent 85ed402 commit bcb3d5a

2 files changed

Lines changed: 39 additions & 0 deletions

File tree

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

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,17 @@ getExprType
114114
| tst.ts:63:5:63:8 | Ctor | abstract new () => HasArea |
115115
| tst.ts:63:11:63:36 | abstrac ... HasArea | abstract new () => HasArea |
116116
| tst.ts:63:40:63:44 | Shape | any |
117+
| tst.ts:65:17:65:23 | myUnion | true |
118+
| tst.ts:65:35:65:46 | stillMyUnion | true |
119+
| tst.ts:66:5:66:10 | union1 | MyUnion |
120+
| tst.ts:66:23:66:37 | {myUnion: true} | MyUnion |
121+
| tst.ts:66:24:66:30 | myUnion | true |
122+
| tst.ts:66:33:66:36 | true | true |
123+
| tst.ts:68:28:68:41 | yetAnotherType | true |
124+
| tst.ts:69:5:69:10 | union2 | MyUnion2 |
125+
| tst.ts:69:24:69:45 | {yetAno ... : true} | MyUnion2 |
126+
| tst.ts:69:25:69:38 | yetAnotherType | true |
127+
| tst.ts:69:41:69:44 | true | true |
117128
| type_alias.ts:3:5:3:5 | b | boolean |
118129
| type_alias.ts:7:5:7:5 | c | ValueOrArray<number> |
119130
| type_alias.ts:14:9:14:32 | [proper ... ]: Json | any |
@@ -165,6 +176,8 @@ getExprType
165176
getTypeDefinitionType
166177
| tst.ts:54:1:56:1 | interfa ... mber;\\n} | NonAbstractDummy |
167178
| tst.ts:58:1:60:1 | interfa ... mber;\\n} | HasArea |
179+
| tst.ts:65:1:65:54 | type My ... true}; | MyUnion |
180+
| tst.ts:68:1:68:49 | type My ... true}; | MyUnion2 |
168181
| type_alias.ts:1:1:1:17 | type B = boolean; | boolean |
169182
| type_alias.ts:5:1:5:50 | type Va ... ay<T>>; | ValueOrArray<T> |
170183
| type_alias.ts:9:1:15:13 | type Js ... Json[]; | Json |
@@ -260,6 +273,19 @@ getTypeExprType
260273
| tst.ts:59:14:59:19 | number | number |
261274
| tst.ts:63:11:63:36 | abstrac ... HasArea | abstract new () => HasArea |
262275
| tst.ts:63:30:63:36 | HasArea | HasArea |
276+
| tst.ts:65:6:65:12 | MyUnion | MyUnion |
277+
| tst.ts:65:16:65:30 | {myUnion: true} | { myUnion: true; } |
278+
| tst.ts:65:16:65:53 | {myUnio ... : true} | { myUnion: true; } \| { stillMyUnion: true; } |
279+
| tst.ts:65:26:65:29 | true | true |
280+
| tst.ts:65:34:65:53 | {stillMyUnion: true} | { stillMyUnion: true; } |
281+
| tst.ts:65:49:65:52 | true | true |
282+
| tst.ts:66:13:66:19 | MyUnion | MyUnion |
283+
| tst.ts:68:6:68:13 | MyUnion2 | MyUnion2 |
284+
| tst.ts:68:17:68:23 | MyUnion | MyUnion |
285+
| tst.ts:68:17:68:48 | MyUnion ... : true} | MyUnion \| { yetAnotherType: true; } |
286+
| tst.ts:68:27:68:48 | {yetAno ... : true} | { yetAnotherType: true; } |
287+
| tst.ts:68:44:68:47 | true | true |
288+
| tst.ts:69:13:69:20 | MyUnion2 | MyUnion2 |
263289
| type_alias.ts:1:6:1:6 | B | boolean |
264290
| type_alias.ts:1:10:1:16 | boolean | boolean |
265291
| type_alias.ts:3:8:3:8 | B | boolean |
@@ -336,6 +362,8 @@ referenceDefinition
336362
| I<S> | type_definitions.ts:3:1:5:1 | interfa ... x: S;\\n} |
337363
| I<number> | type_definitions.ts:3:1:5:1 | interfa ... x: S;\\n} |
338364
| Json | type_alias.ts:9:1:15:13 | type Js ... Json[]; |
365+
| MyUnion | tst.ts:65:1:65:54 | type My ... true}; |
366+
| MyUnion2 | tst.ts:68:1:68:49 | type My ... true}; |
339367
| NonAbstractDummy | tst.ts:54:1:56:1 | interfa ... mber;\\n} |
340368
| ValueOrArray<T> | type_alias.ts:5:1:5:50 | type Va ... ay<T>>; |
341369
| ValueOrArray<number> | type_alias.ts:5:1:5:50 | type Va ... ay<T>>; |
@@ -415,3 +443,8 @@ unionIndex
415443
| { [key: string]: any; } | 1 | string \| { [key: string]: any; } |
416444
| { [key: string]: any; } | 2 | VirtualNode \| { [key: string]: any; } |
417445
| { [property: string]: Json; } | 4 | string \| number \| boolean \| { [property: string... |
446+
| { myUnion: true; } | 0 | MyUnion \| { yetAnotherType: true; } |
447+
| { myUnion: true; } | 0 | { myUnion: true; } \| { stillMyUnion: true; } |
448+
| { stillMyUnion: true; } | 1 | MyUnion \| { yetAnotherType: true; } |
449+
| { stillMyUnion: true; } | 1 | { myUnion: true; } \| { stillMyUnion: true; } |
450+
| { yetAnotherType: true; } | 2 | MyUnion \| { yetAnotherType: true; } |

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,9 @@ interface HasArea {
6161

6262
// abstract construct signature!
6363
let Ctor: abstract new () => HasArea = Shape;
64+
65+
type MyUnion = {myUnion: true} | {stillMyUnion: true};
66+
let union1: MyUnion = {myUnion: true};
67+
68+
type MyUnion2 = MyUnion | {yetAnotherType: true};
69+
let union2: MyUnion2 = {yetAnotherType: true};

0 commit comments

Comments
 (0)