What is the `external:AST` type?
the jsdoc comments have
@param {?external:AST} node
around. what does this mean? Where can I find the AST type?
I am trying to write a .ts version of esquery but im having trouble figuring out where the following exist:
- external:AST
- PlainObject
You can see my progress here: https://github.com/sakgoyal/esquery/tree/esm
Also, what is the [?type] syntax?
I made the assumption that ? means nullable here since [] already means optional
external: is the pre-TypeScript way of JSDoc to refer to an external source (pointed to by an @external tag).
You can see in the @types/esquery package, that the proper AST should be import('estree').Node.
PlainObject was a way to indicate an arbitrary object. It needs to be elaborated (as does SelectorMatcher).
As per https://jsdoc.app/tags-type , ?type is type or null (though undefined may also be relevant here I think).
Before doing more work, however, I'd confirm that @michaelficarra would accept a TypeScript PR.
so does this mean I should do this in my code?
import type { Node as AST } from "estree";
I dont quite understand what you are trying to tell me. Same with the "elaborate". I dont quite understand what this means either.
so does this mean I should do this in my code?
import type { Node as AST } from "estree";
I think that should work. I normally use JSDoc for TypeScript rather than pure TS, but that looks right.
I dont quite understand what you are trying to tell me. Same with the "elaborate". I dont quite understand what this means either.
It means you will need more type info than we provided. Look at the @types/esquery package (or just use that).