forked from brucehuke/ts-testcase
-
Notifications
You must be signed in to change notification settings - Fork 0
/
obj_any.ts
50 lines (40 loc) · 1.18 KB
/
obj_any.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// case 1
class Test {
a: string = '111111'
b: string = '222222'
}
let t = new Test()
// waiot: ../deps/quickjs/quickjs.c:1983: JS_FreeRuntime: Assertion `list_empty(&rt->gc_obj_list)' failed.
// let anyObj: any = {
// a: 'aaa',
// b: 'bbb'
// }
// [ERROR] console - Semantic check error.
// t.a = anyObj.a
console.log('~~~~~~~~~~t.a', t.a)
// case 2
function anyTest(): string {
// work
// let a: any = 1;
// let a: any = 'eeee';
let a: any;
a = {b: '55555'};
return a.b as string;
}
// // console.log('anyTest simple res:', anyTest())
// [ ERR] WasmModuleEngine::Instantiate wasm module failed. _module:0xee101890 error: WASM module instantiate failed: Exception: unreachable
console.log('anyTest ref res:', anyTest())
// case3 ts-wasm/ts2wasm/tests/samples/any_box_obj.ts
function boxNestedObj() {
let obj: any;
obj = {
a: 1,
c: true,
d: {
e: 1,
},
};
return obj.d.e as number;
}
// waiot: ../deps/quickjs/quickjs.c:1983: JS_FreeRuntime: Assertion `list_empty(&rt->gc_obj_list)' failed.
console.log('boxNestedObj res:', boxNestedObj())