Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What is the external:AST type? #150

Open
sakgoyal opened this issue Feb 27, 2025 · 4 comments
Open

What is the external:AST type? #150

sakgoyal opened this issue Feb 27, 2025 · 4 comments

Comments

@sakgoyal
Copy link

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

@sakgoyal
Copy link
Author

Also, what is the [?type] syntax?
I made the assumption that ? means nullable here since [] already means optional

@brettz9
Copy link
Contributor

brettz9 commented Feb 27, 2025

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.

@sakgoyal
Copy link
Author

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.

@brettz9
Copy link
Contributor

brettz9 commented Feb 27, 2025

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants