Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adds custom code generator that returns a list of RtNodes. This is helpful when you need to generate classes/interfaces that depend on C# types but have specific characteristics in TypeScript that are not needed on the server side.
These generators can generate pretty much every type of TS. Classes/Interface like the library is already able to do but also objects that are generated from these generated types.
Usage Example: Localization
I have different C# DTO classes that represent form data and are used to automatically generate forms via TypeScript. The labels for the form fields are localizable.
A CustomCodeGenerator then generates a TS interface that combines localization fields for all properties of the two classes. This interface is not needed at all on the server and it would need to be maintained manually whenever one of the C# form classes is changed.
I use a localization framework that is initialized with an IFormLocales object and when I need a localized string I pass the path to the property of the object (e.g. translate("forms.userName")). To avoid typing the string every time my custom generator also generates a helper object for this: