Rich-Harris / estree-walker

Traverse an ESTree-compliant AST

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Wrong TS types: BaseNode instead of Node

ksh-ns opened this issue · comments

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? 🤔