Rich-Harris / estree-walker

Traverse an ESTree-compliant AST
MIT License
389 stars 37 forks source link

Wrong TS types: BaseNode instead of Node #28

Closed ksh-ns closed 1 year ago

ksh-ns commented 3 years ago

Hey, I'm using the svelte compiler to walk the AST. I'm using Typescript and it seems that the typings are wrong for the node that passed to the walk function - https://github.com/Rich-Harris/estree-walker/blob/master/src/async.js#L4

image

It's typed as BaseNode, but the possible results are some sort of of Node + INode mixed type (eg. ModuleSpecifier for import statements). The dependencies:

{
    "svelte": "^3.38.2",
    "@types/estree": "^0.0.48",
    "estree-walker": "^3.0.0"
}

P.S. Also Svelte doesn't automatically include those types, you need to install more of the packages. This isn't ideal as you could miss-match the dependency versions. Maybe there is a conventional way to bundle types, without the need for the user to install svelte's sub-dependencies? 🤔