Bug: Printing if statement inside bracketless if-else
- Dominant language
- TypeScript
- Stars
- 5.3k
- Forks
- 363
- Avg merge
- 3d 8h
- Merged PRs (30d)
- 3
Description
This
```
recast.print(
b.ifStatement(
b.literal(1), // test
b.ifStatement( // consequent
b.literal(2), // - test
b.expressionStatement(b.literal(3)) // - consequent
),
b.expressionStatement(b.literal(4)) // alternate
)
).code
```
produces:
```
if (1)
if (2)
3;
else
4;
```
but should produce this:
```
if (1)
{
if (2)
3;
} else
4;
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the provided recast.print and b.ifStatement reproduction, comparing the actual output with the expected braced if-else form. Done means the nested if statement prints with braces so the else binds to the intended outer statement, with the reproduction serving as the regression check.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100