Semicolons added to transformed statements
- Dominant language
- TypeScript
- Stars
- 5.3k
- Forks
- 364
- Avg merge
- 3d 8h
- Merged PRs (30d)
- 3
Description
When source contains no semicolons, just newlines. Transforming one statement into another inserts semicolons that weren't previously there:
```js
var prog = recast.parse("var m = require('module')\n var x");
prog.program.body[0].type = "ImportDeclaration";
prog.program.body[0].specifiers = [{type: "ImportDefaultSpecifier", local: {type: "Identifier", name: "m"}}];
prog.program.body[0].source = {type:"Literal", value: "module", raw: '"module"'};
console.log(recast.print(prog).code);
```
Expected output:
```
import m from "module"
var x
```
Actual output:
```
import m from "module";
var x
```
I think this will hinder the use of recast by people who have their source code formatted without semicolons. I think this also ties into issue #13 - there currently is no option to suppress semicolons.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by running the JavaScript reproduction in the issue and compare the printed output with the expected semicolon-free form. Trace the transformed statement through recast's printing or pretty-printing path; done means transformed statements preserve the source's lack of semicolons without adding one before the following declaration.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100