mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-13 06:51:34 +00:00
Implement object literal parsing; Instantiate classes from object literals
Essentially, if the contextual type is a class with a constructor that takes zero arguments or doesn't have a constructor at all, an object literal can be used to initialize a new instance of that class with preset values.
This commit is contained in:
9
tests/parser/object-literal.ts
Normal file
9
tests/parser/object-literal.ts
Normal file
@ -0,0 +1,9 @@
|
||||
var obj = {
|
||||
a: 123,
|
||||
b: "234",
|
||||
"c": false,
|
||||
d: {
|
||||
a: 123,
|
||||
"b": {}
|
||||
}
|
||||
};
|
9
tests/parser/object-literal.ts.fixture.ts
Normal file
9
tests/parser/object-literal.ts.fixture.ts
Normal file
@ -0,0 +1,9 @@
|
||||
var obj = {
|
||||
a: 123,
|
||||
b: "234",
|
||||
"c": false,
|
||||
d: {
|
||||
a: 123,
|
||||
"b": {}
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user