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

[@babel/types]: Export type-level mapping between aliases and the types of nodes that have that alias. #9092

Open
cameron-martin opened this Issue Nov 27, 2018 · 1 comment

Comments

Projects
None yet
2 participants
@cameron-martin

cameron-martin commented Nov 27, 2018

Feature Request

Is your feature request related to a problem? Please describe.

Currently, the TypeScript definitions for Visitor do not allow aliases as properties. There is not enough information available in the auto-generated type definitions in @babel/types to support this.

Describe the solution you'd like

Add an interface that acts as a type-level mapping between aliases and the types of nodes that have those aliases, e.g.

export interface Aliases {
  Function: Function;
  Expression: Expression;
  LVal: LVal;
  // ...etc
}

Describe alternatives you've considered

An alternative would be to include all node types, not just aliases, in this interface. However, this can be easily created externally to this library by intersecting with the following type:

{ [P in Node["type"]]: Extract<Node, { type: P; }>; }

Teachability, Documentation, Adoption, Migration Strategy
If you can, explain how users will be able to use this and possibly write out a version the docs.
Maybe a screenshot or design?

I believe this section is not too relevant in this instance - please correct me if I'm wrong.

@babel-bot

This comment has been minimized.

Collaborator

babel-bot commented Nov 27, 2018

Hey @cameron-martin! We really appreciate you taking the time to report an issue. The collaborators
on this project attempt to help as many people as possible, but we're a limited number of volunteers,
so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack
community that typically always has someone willing to help. You can sign-up here
for an invite.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment