'visitObjectProperty' option of visit function did not work
- Dominant language
- TypeScript
- Stars
- 1.2k
- Forks
- 194
- Avg merge
- 22h 43m
- Merged PRs (30d)
- 10
Description
I tried to parse my code with `recast`, and traverse AST with `ast-types`.
But when I used `visitObjectProperty` option in `visit` function, it did't work.
All my code is below:
```
const { parse } = require('recast')
const { visit } = require('ast-types')
const rawCode = `
import Foo from "./Foo.vue"
export default {
components: {
Foo
},
data() {
return {
msg: 'Hello World'
}
}
}
`
const ast = parse(rawCode)
visit(ast, {
visitObjectExpression(path) {
// can access to object properties here.
console.log(path.value.properties)
this.traverse(path)
},
visitObjectProperty(path) {
// nothing print. cannot access to object property
console.log('------------Property-------------')
console.log(path)
this.traverse(path)
}
})
```
### Environment
node version: v16.9.1
ast-types version: v0.14.2
recast version: v0.20.5
OS: Mac OS 11.3.1
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by running the provided recast and ast-types reproduction and inspect the node types reached by visitObjectExpression and visitObjectProperty. Compare the parsed AST with the visitor names and verify that the property visitor is invoked for the object properties shown in the example; done means the reported behavior is explained and covered by a focused regression test if the issue is confirmed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100