typescript-json-schema
typescript-json-schema copied to clipboard
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)
Please:
- [x] Make your pull request atomic, fixing one issue at a time unless there are many relevant issues that cannot be decoupled.
- [x] Provide a test case & update the documentation in the
Readme.md
closes #336
@YousefED it would be great if you could give me some feedback, if I took the right way to implement this feature. AFAICS it should be a bit more generic, but I'm not sure, if there may be some edge cases that are still not handled properly and should generate a warning.
The main change is, that I had to put the values of the user symbols into the sandbox to resolve constant/enum references.
In addition there are helper two functions to derive the value of the declarations and initializers. Additional logic can be easily added by switching the supported kinds.
All tests (including the new one at test/programs/default-properties-ref) are running successfully.