path.scope not accurate for const and let
- Dominant language
- TypeScript
- Stars
- 1.2k
- Forks
- 194
- Avg merge
- 22h 43m
- Merged PRs (30d)
- 10
Description
Variables declared with `let` and `const` are block-scoped, not function-scoped. Yet `path.scope` is the same for both blocked-scoped variables and function-scoped variables declared with `var`. The following
```
var recast = require("recast");
var types = require("ast-types");
var ast = recast.parse(`
function f() {
if (true) {
const x = 3;
}
}
`);
types.visit(ast, {
visitVariableDeclaration: function(path) {
console.log(path.scope.node.type);
return false;
}
});
```
Outputs "FunctionDeclaration", but I think it should be "BlockStatement".
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.