-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Description
There have been a decent amount of bugs related to the AST node start and end being incorrect. I think we could help prevent regressions and make future node positions a little more testable if we develop a new test for this.
Perhaps beyond the current test that uses numbers it would be useful to create two typescript files (one jsx, one non-jsx) that hold all the different possible AST node combinations. Then a json test file that has all the AST nodes, but only contains the type, text, and any children. Maybe something like the following:
// perhaps we'd skip the root module text because that would just be long and not so useful
[{
"type": "FunctionDeclaration",
"text": "function test {}",
"name": {
"type": "Identifier",
"text": "test"
},
"params": [],
// etc...
}, {
// ... other statements go here ....
}]The file would be auto-generated similar to the input.ts.json files, but this would make it extremely easy to visually identify problems with node span lengths.
Thoughts?