Find out params order for a particular builder
- Dominant language
- TypeScript
- Stars
- 1.2k
- Forks
- 194
- Avg merge
- 22h 43m
- Merged PRs (30d)
- 10
Description
I want to automate building AST subtrees, something like:
``` js
var types = require('ast-types');
var nodeParams = { /* my params here */};
types.builders[nodeParams.type].apply(this, ???);
```
Is there a way to find out what is the proper order of params I should pass to a node builder of a specific type?
There are [`.buildParams`](https://github.com/benjamn/ast-types/blob/27af2dff60cb27452b6ed43cf4fa295d8de471ea/lib/types.js#L462) defined on a type, but for now it seems impossible to get access to that list from external module.
It would be nice to have something like `types.namedTypes[type].fields` I suppose?
Or to make `getFieldNames(node)` return properly ordered fields?
Or just to make any builder accept object with params, not only list of arguments.
@benjamn I can probably do a PR, if you wish.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.