recast + babel parser generate wrong start property
- Dominant language
- TypeScript
- Stars
- 5.3k
- Forks
- 364
- Avg merge
- 3d 8h
- Merged PRs (30d)
- 3
Description
When I parse the js code:
```
function test() {
}
test()
```
Th e `start` property of the first function declaration is wrong of `recast + babel parser`:
```javascript
const { resolve } = require("path");
const fs = require("fs");
const recast = require("recast");
const jsCode = fs.readFileSync(resolve(__dirname, "./test.js"), {
encoding: "UTF-8"
});
const ast = recast.parse(jsCode, { parser: require("@babel/parser") });
console.log(ast)
```

If use the `babel parser` only is right:
```javascript
const { resolve } = require("path");
const fs = require("fs");
const { parse: babelParse } = require("@babel/parser");
const jsCode = fs.readFileSync(resolve(__dirname, "./test.js"), {
encoding: "UTF-8"
});
const ast = babelParse(jsCode);
console.log(ast)
```

One thing that must be pointed out is that there are two empty lines before the function declaration.
Contributor guide
No contributing guide indexed for this repository
Research direction
No project files or tests are named. Start by reproducing the supplied recast.parse example with @babel/parser and the JavaScript input containing two blank lines before the function; compare its start property with direct Babel parsing. Done means the function declaration receives the expected start position in the recast AST.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100