-
Notifications
You must be signed in to change notification settings - Fork 1
/
case38.ts
57 lines (43 loc) · 914 Bytes
/
case38.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
51
52
53
54
55
56
57
export default {}
// work
class Test {
private _a: string = 'aaa'
get a(): string {
console.log('~~~~~~~~~getter')
return this._a
}
set a(val: string) {
console.log('~~~~~~~~~setter')
this._a = val
}
}
let test: Test = new Test()
console.log(test.a)
test.a = 'bbb'
console.log(test.a)
// 复杂类型
interface Opt {
val: string
}
class Test2 {
private _a: Opt = {
val: '_aaaa'
}
get a(): Opt {
console.log('~~~~~~~~~getter')
return this._a
}
set a(val: Opt) {
console.log('~~~~~~~~~setter')
this._a = val
}
}
let test2: Test2 = new Test2()
// [ERROR] console - Aborted(Assertion failed: isStruct(), at: /home/runner/work/binaryen.js/binaryen.js/binaryen/src/wasm/wasm-type.cpp,1330,getStruct). Build with -sASSERTIONS for more info.
console.log(test2.a.val)
test2.a = {
val: '_bbbb123'
}
// work
let o: Opt = test2.a
console.log(o.val)