Legalize casting object literals to classes when linting

This commit is contained in:
dcodeIO 2018-07-14 15:00:07 +02:00
parent 29081b6323
commit c636eddcd2
6 changed files with 78 additions and 10 deletions

2
dist/asc.js vendored

File diff suppressed because one or more lines are too long

2
dist/asc.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -73,9 +73,6 @@
"no-misused-new": {
"severity": "error"
},
"no-object-literal-type-assertion": {
"severity": "error"
},
"no-require-imports": {
"severity": "error"
},

View File

@ -275,14 +275,33 @@
(call $~lib/env/abort
(i32.const 0)
(i32.const 36)
(i32.const 23)
(i32.const 26)
(i32.const 2)
)
(unreachable)
)
)
)
(func $start (; 6 ;) (type $v)
(func $object-literal/Foo2#test (; 6 ;) (type $iv) (param $0 i32)
(if
(i32.ne
(i32.load
(get_local $0)
)
(i32.const 3)
)
(block
(call $~lib/env/abort
(i32.const 0)
(i32.const 36)
(i32.const 21)
(i32.const 4)
)
(unreachable)
)
)
)
(func $start (; 7 ;) (type $v)
(local $0 i32)
(set_global $~lib/allocator/arena/startOffset
(i32.and
@ -322,5 +341,16 @@
(call $object-literal/bar2
(get_local $0)
)
(i32.store
(tee_local $0
(call $~lib/allocator/arena/allocate_memory
(i32.const 4)
)
)
(i32.const 3)
)
(call $object-literal/Foo2#test
(get_local $0)
)
)
)

View File

@ -17,10 +17,15 @@ class Foo2 {
constructor() {
this.bar = 1;
}
test(): void {
assert(this.bar == 3);
}
}
function bar2(foo: Foo2): void {
assert(foo.bar == 2);
}
bar2({ bar: 2 });
bar2(<Foo2>{ bar: 2 });
(<Foo2>{ bar: 3 }).test();

View File

@ -308,16 +308,38 @@
(call $~lib/env/abort
(i32.const 0)
(i32.const 36)
(i32.const 23)
(i32.const 26)
(i32.const 2)
)
(unreachable)
)
)
)
(func $start (; 6 ;) (type $v)
(func $object-literal/Foo2#test (; 6 ;) (type $iv) (param $0 i32)
(if
(i32.eqz
(i32.eq
(i32.load
(get_local $0)
)
(i32.const 3)
)
)
(block
(call $~lib/env/abort
(i32.const 0)
(i32.const 36)
(i32.const 21)
(i32.const 4)
)
(unreachable)
)
)
)
(func $start (; 7 ;) (type $v)
(local $0 i32)
(local $1 i32)
(local $2 i32)
(set_global $~lib/allocator/arena/startOffset
(i32.and
(i32.add
@ -365,5 +387,19 @@
(get_local $1)
)
)
(call $object-literal/Foo2#test
(block (result i32)
(set_local $2
(call $~lib/allocator/arena/allocate_memory
(i32.const 4)
)
)
(i32.store
(get_local $2)
(i32.const 3)
)
(get_local $2)
)
)
)
)