benjamn / benjamn/recast

Bug: parenthesis are not preserved in unary arrow function

Open
#528 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
5.3k
Forks
363
Avg merge
3d 8h
Merged PRs (30d)
3

Description

Let's say we have an arrow function like this
`const identity = (a) => a;`
after parsing it and then printing ast back, parentheses will be lost:
`const identity = a => a;`.

The logics is described here: https://github.com/benjamn/recast/blob/master/lib/printer.js#L369
We need to check whether parentheses were present in the input and add them in the output if were present.

It is fixed in https://github.com/benjamn/recast/pull/529

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at lib/printer.js around line 369, where the issue identifies the parenthesis-printing logic, and compare the behavior with the linked pull request 529. Done means parsing and printing a unary arrow function preserves parentheses that were present in the input.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.