Auto-Generation of Node "Factory" Functions #3762
Closed
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.
This adds a
processTypes.ts
script that can be used to create afactory.generated.ts
file, which contains functions for creating, updating, and testing TypeScript AST nodes.The
processTypes.ts
script uses the LKG version of TypeScript to parse and reason over thesrc/compiler/types.ts
file. Output is controlled through the use of annotation-like comments (similar to@internal
):Annotations on Interface/Type Alias declarations
// @kind(SyntaxKind)
- Marks a type declaration as the type for the syntax kind.// @factoryparam(string)
- Marks a property, by name, that will be included in the parameter list for a create function, but not its associated update function.// @factoryhidden(boolean)
- Marks the entire type as either hidden (not included in the set of generated factory functions), or visible.// @factoryhidden(string, boolean)
- Marks a property, by name, that will be either hidden or visible.// @factoryorder(...string)
- Controls order of parameters to the create or update functions.Annotations on a property of an interface
// @factoryparam
- Marks the property as a parameter to the create function, but not the update function.// @factoryhidden(boolean)
- Marks the property as either hidden or visible.