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

@oxc-project/types to export a Node union type #9573

Open
privatenumber opened this issue Mar 6, 2025 · 0 comments · Fixed by #9574
Open

@oxc-project/types to export a Node union type #9573

privatenumber opened this issue Mar 6, 2025 · 0 comments · Fixed by #9574
Labels
C-enhancement Category - New feature or request

Comments

@privatenumber
Copy link

A Node type export from @oxc-project/types would be super convenient when writing a function that can accept any AST node. For example, when writing a minimal tree traverser.

For reference, estree types does something like this https://unpkg.com/browse/@types/estree@1.0.6/index.d.ts:

export interface NodeMap {
  AssignmentProperty: AssignmentProperty;
  CatchClause: CatchClause;
  Class: Class;
  ClassBody: ClassBody;
  Expression: Expression;
  Function: Function;
  Identifier: Identifier;
  Literal: Literal;
  MethodDefinition: MethodDefinition;
  ModuleDeclaration: ModuleDeclaration;
  ModuleSpecifier: ModuleSpecifier;
  Pattern: Pattern;
  PrivateIdentifier: PrivateIdentifier;
  Program: Program;
  Property: Property;
  PropertyDefinition: PropertyDefinition;
  SpreadElement: SpreadElement;
  Statement: Statement;
  Super: Super;
  SwitchCase: SwitchCase;
  TemplateElement: TemplateElement;
  VariableDeclarator: VariableDeclarator;
}

export type Node = NodeMap[keyof NodeMap];
@privatenumber privatenumber added the C-enhancement Category - New feature or request label Mar 6, 2025
graphite-app bot pushed a commit that referenced this issue Mar 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category - New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant