typescript-json-schema icon indicating copy to clipboard operation
typescript-json-schema copied to clipboard

feat: support property defaults with constant and enum refs (#336)

Open ahochsteger opened this issue 1 year ago • 1 comments

  • 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

ahochsteger avatar May 02 '24 04:05 ahochsteger

@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.

ahochsteger avatar May 02 '24 05:05 ahochsteger