empty node type for easy composition
- Dominant language
- TypeScript
- Stars
- 5.3k
- Forks
- 363
- Avg merge
- 3d 8h
- Merged PRs (30d)
- 3
Description
I often find myself wanting to conditionally add a node to a list when building an AST. For example when building the argument list for a `b.callExpression`. Currently the way to do it is to pull out the args array and conditionally push something to it and then pass it to the builder function. It'd be nice to have an empty node type that recast can ignore.
```
b.callExpression(
fun,
[
a,
b,
condition ? b.literal(c) : b.empty()
]
);
```
This will also make `.map`ing over nodes much easier.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by tracing the builder entry points shown in the example, especially b.callExpression and the proposed b.empty(), and inspect how recast processes nodes in lists. Done means an empty node can be returned from conditional expressions or mapped lists and is ignored during output without requiring manual array edits.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100