Skip to content

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

Closed

Description

@cameron-martin

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.

Activity

  1. babel-bot commented on Nov 27, 2018

    @babel-bot
    Collaborator

    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.

  2. added
    outdated
    on Mar 20, 2019
  3. locked as resolved and limited conversation to collaborators on Mar 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    outdated

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions