Skip to content

Conversation

@overlookmotel
Copy link
Member

@overlookmotel overlookmotel commented Sep 19, 2025

Add visitor keys export to oxc-parser NPM package. This is useful in itself, but also the first step towards an ESTree walker.

Visitor keys are based on @typescript-eslint/visitor-keys.

It'd be ideal to generate visitor keys direct from Oxc's own types, but that's proving difficult due to all the custom serializers we use to translate to ESTree. So using the shortcut of borrowing from TS-ESLint for now.

Oxc's AST is slightly different from TS-ESTree (notably Oxc's AST adds ParenthesizedExpression). But apart from those few differences, TS-ESLint's AST and Oxc's are identical, and I made a PR to TS-ESLint earlier this year (typescript-eslint/typescript-eslint#11279) to ensure visitor key order is correct, and matches Oxc.

To avoid adding a runtime dependency on @typescript-eslint/visitor-keys, extract the data from TS-ESLint in oxc_ast_tools, amend for Oxc/TS-ESTree differences, and re-output it as a simple object literal.

This approach will be faster at runtime, as the object's shape is consistent, and also avoids a dependency.

@github-actions github-actions bot added A-parser Area - Parser A-ast-tools Area - AST tools C-enhancement Category - New feature or request labels Sep 19, 2025
Copy link
Member Author

overlookmotel commented Sep 19, 2025


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@codspeed-hq
Copy link

codspeed-hq bot commented Sep 19, 2025

CodSpeed Instrumentation Performance Report

Merging #13927 will not alter performance

Comparing 09-17-feat_napi_parser_export_visitor_keys (4ee94a3) with main (605621d)1

Summary

✅ 37 untouched

Footnotes

  1. No successful run was found on main (4ee94a3) during the generation of this report, so 605621d was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@overlookmotel overlookmotel force-pushed the 09-17-feat_napi_parser_export_visitor_keys branch from af8fbe1 to 60ae4c7 Compare September 19, 2025 14:57
@overlookmotel overlookmotel marked this pull request as ready for review September 19, 2025 15:05
Copilot AI review requested due to automatic review settings September 19, 2025 15:05
@overlookmotel overlookmotel self-assigned this Sep 19, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds visitor keys export to the oxc-parser NPM package by generating them from TypeScript ESLint's visitor keys with modifications for Oxc-specific AST nodes. This functionality will enable ESTree walker support for Oxc's AST.

Key changes:

  • Creates a new generator that extracts visitor keys from @typescript-eslint/visitor-keys
  • Adds Oxc-specific AST nodes like ParenthesizedExpression and V8IntrinsicExpression
  • Exports visitor keys through the parser package's main index

Reviewed Changes

Copilot reviewed 11 out of 15 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tasks/ast_tools/src/generators/estree_visit.rs New generator that creates visitor keys by running a Node.js script and processing the output
tasks/ast_tools/src/utils.rs Adds string! macro for creating String instances
napi/parser/scripts/visitor-keys.mjs Node.js script that extracts visitor keys from TypeScript ESLint
napi/parser/src-js/index.mjs Exports the generated visitor keys
napi/parser/test/parse.test.ts Adds tests for the visitor keys functionality
.github/workflows/ci.yml Adds Node.js setup for CI workflow
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@overlookmotel overlookmotel force-pushed the 09-17-feat_napi_parser_export_visitor_keys branch from 60ae4c7 to f694cda Compare September 19, 2025 17:02
@overlookmotel overlookmotel marked this pull request as draft September 19, 2025 17:27
@overlookmotel overlookmotel force-pushed the 09-17-feat_napi_parser_export_visitor_keys branch 3 times, most recently from f68cffb to f7f9e3a Compare September 19, 2025 21:01
@overlookmotel overlookmotel marked this pull request as ready for review September 19, 2025 21:02
@overlookmotel overlookmotel force-pushed the 09-17-feat_napi_parser_export_visitor_keys branch from f7f9e3a to b0abdfd Compare September 20, 2025 09:43
@overlookmotel overlookmotel changed the base branch from main to graphite-base/13927 September 21, 2025 09:58
@overlookmotel overlookmotel force-pushed the 09-17-feat_napi_parser_export_visitor_keys branch from b0abdfd to 7091e82 Compare September 21, 2025 09:58
@overlookmotel overlookmotel changed the base branch from graphite-base/13927 to 09-21-fix_napi_parser_raw_transfer_preserveparens_option_apply_to_tsparenthesizedtype_ September 21, 2025 09:58
@graphite-app graphite-app bot changed the base branch from 09-21-fix_napi_parser_raw_transfer_preserveparens_option_apply_to_tsparenthesizedtype_ to graphite-base/13927 September 21, 2025 10:13
@overlookmotel overlookmotel force-pushed the 09-17-feat_napi_parser_export_visitor_keys branch from 7091e82 to fe80787 Compare September 21, 2025 10:31
@overlookmotel overlookmotel changed the base branch from graphite-base/13927 to main September 21, 2025 10:31
@overlookmotel
Copy link
Member Author

Needs to be changed after #13978.

@overlookmotel overlookmotel marked this pull request as draft September 21, 2025 14:49
@overlookmotel overlookmotel force-pushed the 09-17-feat_napi_parser_export_visitor_keys branch from fe80787 to 2395e3a Compare September 21, 2025 15:00
@overlookmotel
Copy link
Member Author

Needs to be changed after #13978.

Done.

@overlookmotel overlookmotel marked this pull request as ready for review September 21, 2025 15:01
@overlookmotel overlookmotel force-pushed the 09-17-feat_napi_parser_export_visitor_keys branch from 2395e3a to 2bd7aa7 Compare September 22, 2025 10:59
@overlookmotel overlookmotel added the 0-merge Merge with Graphite Merge Queue label Sep 22, 2025
Copy link
Member Author

overlookmotel commented Sep 22, 2025

Merge activity

Add visitor keys export to `oxc-parser` NPM package. This is useful in itself, but also the first step towards an ESTree walker.

Visitor keys are based on `@typescript-eslint/visitor-keys`.

It'd be ideal to generate visitor keys direct from Oxc's own types, but that's proving difficult due to all the custom serializers we use to translate to ESTree. So using the shortcut of borrowing from TS-ESLint for now.

Oxc's AST is slightly different from TS-ESTree (notably Oxc's AST adds `ParenthesizedExpression`). But apart from those few differences, TS-ESLint's AST and Oxc's are identical, and I made a PR to TS-ESLint earlier this year (typescript-eslint/typescript-eslint#11279) to ensure visitor key order is correct, and matches Oxc.

To avoid adding a runtime dependency on `@typescript-eslint/visitor-keys`, extract the data from TS-ESLint in `oxc_ast_tools`, amend for Oxc/TS-ESTree differences, and re-output it as a simple object literal.

This approach will be faster at runtime, as the object's shape is consistent, and also avoids a dependency.
@graphite-app graphite-app bot force-pushed the 09-17-feat_napi_parser_export_visitor_keys branch from 2bd7aa7 to 4ee94a3 Compare September 22, 2025 11:08
@graphite-app graphite-app bot merged commit 4ee94a3 into main Sep 22, 2025
29 checks passed
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Sep 22, 2025
@graphite-app graphite-app bot deleted the 09-17-feat_napi_parser_export_visitor_keys branch September 22, 2025 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-ast-tools Area - AST tools A-parser Area - Parser C-enhancement Category - New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants