-
Notifications
You must be signed in to change notification settings - Fork 323
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support property defaults with constant and enum refs (#336)
* add helper functions getDeclarationValue() and getInitializerValue() * make user symbols available to sandbox evaluation * simplify initializer logic (eliminate ifs)
- Loading branch information
1 parent
3426762
commit 5ae6704
Showing
5 changed files
with
167 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
|
||
const defaultBooleanFalse = false; | ||
const defaultBooleanTrue = true; | ||
const defaultFloat = 12.3; | ||
const defaultInteger = 123; | ||
const defaultString = "test" | ||
|
||
enum FruitEnum { | ||
Apple = 'apple', | ||
Orange = 'orange' | ||
} | ||
|
||
class MyObject { | ||
propBooleanFalse: boolean = defaultBooleanFalse; | ||
propBooleanTrue: boolean = defaultBooleanTrue; | ||
propFloat: number = defaultFloat; | ||
propInteger: number = defaultInteger; | ||
propString: string = defaultString; | ||
propEnum: FruitEnum = FruitEnum.Apple; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"additionalProperties": false, | ||
"definitions": { | ||
"FruitEnum": { | ||
"enum": [ | ||
"apple", | ||
"orange" | ||
], | ||
"type": "string" | ||
} | ||
}, | ||
"properties": { | ||
"propBooleanFalse": { | ||
"type": "boolean", | ||
"default": false | ||
}, | ||
"propBooleanTrue": { | ||
"type": "boolean", | ||
"default": true | ||
}, | ||
"propEnum": { | ||
"$ref": "#/definitions/FruitEnum", | ||
"default": "apple" | ||
}, | ||
"propFloat": { | ||
"type": "number", | ||
"default": 12.3 | ||
}, | ||
"propInteger": { | ||
"type": "number", | ||
"default": 123 | ||
}, | ||
"propString": { | ||
"type": "string", | ||
"default": "test" | ||
} | ||
}, | ||
"required": [ | ||
"propBooleanFalse", | ||
"propBooleanTrue", | ||
"propEnum", | ||
"propFloat", | ||
"propInteger", | ||
"propString" | ||
], | ||
"type": "object" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters