Skip to content

feat(ast_tools): generate TS declaration files for deserializer and walk files#16912

Merged
graphite-app[bot] merged 1 commit intomainfrom
c/12-15-feat_ast_tools_generate_typescript_declaration_files_for_deserializer_and_walk_modules
Dec 15, 2025
Merged

feat(ast_tools): generate TS declaration files for deserializer and walk files#16912
graphite-app[bot] merged 1 commit intomainfrom
c/12-15-feat_ast_tools_generate_typescript_declaration_files_for_deserializer_and_walk_modules

Conversation

@camc314
Copy link
Contributor

@camc314 camc314 commented Dec 15, 2025

this fixes some ts-expect-errors in oxlint by generating declaration files.

We could also consider using oxc_isolated_declarations to generate these

@github-actions github-actions bot added A-linter Area - Linter A-parser Area - Parser A-cli Area - CLI A-ast-tools Area - AST tools A-linter-plugins Area - Linter JS plugins C-enhancement Category - New feature or request labels Dec 15, 2025
Copy link
Contributor Author

camc314 commented Dec 15, 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.

@camc314 camc314 changed the title feat(ast_tools): generate TypeScript declaration files for deserializer and walk modules feat(ast_tools): generate TS declaration files for deserializer and walk files Dec 15, 2025
@camc314 camc314 marked this pull request as ready for review December 15, 2025 15:55
Copilot AI review requested due to automatic review settings December 15, 2025 15:55
@camc314 camc314 force-pushed the c/12-15-feat_ast_tools_generate_typescript_declaration_files_for_deserializer_and_walk_modules branch 2 times, most recently from ca60261 to e0048cf Compare December 15, 2025 16:03
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 generates TypeScript declaration files (.d.ts) for auto-generated deserializer and AST walker files, improving type safety for TypeScript consumers. Previously, these generated JavaScript files lacked type definitions, requiring @ts-expect-error comments in oxlint's TypeScript code.

Key changes:

  • Added type definition generation for 8 parser deserialize variants and 1 oxlint deserialize variant
  • Added type definition generation for parser and oxlint walk modules
  • Removed 3 @ts-expect-error comments that are no longer needed (replaced with 1 more specific comment)

Reviewed changes

Copilot reviewed 5 out of 17 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tasks/ast_tools/src/generators/raw_transfer.rs Added templates for deserialize type definitions and logic to generate .d.ts files for all deserialize variants
tasks/ast_tools/src/generators/estree_visit.rs Added templates and output generation for walk module type definitions for both parser and oxlint variants
napi/parser/generated/deserialize/*.d.ts (8 files) Generated declaration files for parser deserialize variants with consistent type signatures
napi/parser/generated/visit/walk.d.ts Generated declaration file for parser walk module (exports only walkProgram)
apps/oxlint/src-js/generated/deserialize.d.ts Generated declaration file for oxlint deserialize module with linter-specific signatures
apps/oxlint/src-js/generated/walk.d.ts Generated declaration file for oxlint walk module (exports walkProgram and ancestors)
apps/oxlint/src-js/plugins/source_code.ts Removed @ts-expect-error comment and added defensive buffer assertion
apps/oxlint/src-js/plugins/selector.ts Removed generic @ts-expect-error comment, added specific one for type incompatibility between Node[] and EsqueryNode[]
apps/oxlint/src-js/plugins/lint.ts Removed @ts-expect-error comment and added defensive ast assertion
.github/generated/ast_changes_watch_list.yml Added all 11 new .d.ts files to the watch list

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Member

@overlookmotel overlookmotel left a comment

Choose a reason for hiding this comment

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

I keep meaning to convert napi/parser to TS, and bundle it with TSDown. Then we could make all the generated files actual TS, and get better type safety / check the correctness of our types. But I haven't got around to it.

In the meantime, this is a good solution.

@overlookmotel overlookmotel added the 0-merge Merge with Graphite Merge Queue label Dec 15, 2025
Copy link
Member

overlookmotel commented Dec 15, 2025

Merge activity

…alk files (#16912)

this fixes some ts-expect-errors in oxlint by generating declaration files.

We could also consider using oxc_isolated_declarations to generate these
@graphite-app graphite-app bot force-pushed the c/12-15-feat_ast_tools_generate_typescript_declaration_files_for_deserializer_and_walk_modules branch from e0048cf to 291b57b Compare December 15, 2025 20:50
@graphite-app graphite-app bot merged commit 291b57b into main Dec 15, 2025
18 checks passed
@graphite-app graphite-app bot deleted the c/12-15-feat_ast_tools_generate_typescript_declaration_files_for_deserializer_and_walk_modules branch December 15, 2025 20:56
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Dec 15, 2025
@camc314
Copy link
Contributor Author

camc314 commented Dec 15, 2025

keep meaning to convert napi/parser to TS, and bundle it with TSDown. Then we could make all the generated files actual TS, and get better type safety / check the correctness of our types. But I haven't got around to it.

I was going to do this, but i fear it may be a pain.

The problem is that the minifier doesn't support TS, and we run the generated code through the minifier before formatting + writing to disk. I think the minification we need to do is fairly trivial, so maybe we just have a manual implementation.

@overlookmotel
Copy link
Member

The problem is that the minifier doesn't support TS, and we run the generated code through the minifier before formatting + writing to disk. I think the minification we need to do is fairly trivial, so maybe we just have a manual implementation.

Ah ha good point.

I suppose if we're using TSDown, we don't actually need to run code through minifier in ast_tools, because TSDown will minify later. It's nice for the generated files to be post-minifier, because then it's easier to check minifier is doing what it's supposed to, but that's not essential.

overlookmotel added a commit that referenced this pull request Dec 19, 2025
### 🚀 Features

- d209c21 allocator: Add cap to FixedSizeAllocatorPool and block when
exhausted (#17023) (Cameron)
- fb2af91 allocator: Add bitset utils (#17042) (zhaoting zhou)
- c16082c tasks/compat_data: Integrate `node-compat-table` (#16831)
(Boshen)
- 5586823 span: Extract TS declaration file check to its own function
(#17037) (camchenry)
- 3d2b492 minifier: Fold iife arrow functions in call expressions
(#16477) (Armano)
- 67e9f9e codegen: Keep comments on the export specifiers (#16943)
(夕舞八弦)
- cb515fa parser: Improve error message for `yield` as identifier usage
(#16950) (sapphi-red)
- dcc856b parser: Add help for `new_dynamic_import` error (#16949)
(sapphi-red)
- c3c79f8 parser: Improve import attribute value error message (#16948)
(sapphi-red)
- 291b57b ast_tools: Generate TS declaration files for deserializer and
walk files (#16912) (camc314)
- 74eae13 minifier: Remove unused import specifiers (#16797) (camc314)

### 🐛 Bug Fixes

- fb9e193 linter: OOM problems with custom plugins (#17082)
(overlookmotel)
- e59132b parser/napi: Fix lazy deser (#17069) (overlookmotel)
- a92faf0 ast_tools: Support `u128` in `assert_layouts` generator
(#17050) (overlookmotel)
- 47b4c2f minifier/docs: Correct hyperlink path in OPTIMIZATIONS.md
(#16986) (GRK)
- 3002649 transformer/typescript: Remove unused import equals
declaration (#16776) (Dunqing)
- 5a2af88 regular_expression: Correct named capture group reference
error (#16952) (sapphi-red)

### ⚡ Performance

- b657bb6 allocator: Reduce time `Mutex` lock is held in
`FixedSizeAllocatorPool::get` (#17079) (overlookmotel)
- 1f3b19b ast: `#[ast]` macro use `#[repr(transparent)]` for
single-field structs (#17052) (overlookmotel)
- 225f229 parser: Use SmallVec for duplicate default export detection
(#16801) (camc314)

### 📚 Documentation

- a9c419f traverse: Update safety comments (#16944) (overlookmotel)

Co-authored-by: overlookmotel <[email protected]>
overlookmotel added a commit that referenced this pull request Dec 19, 2025
# Oxlint
### 🚀 Features

- 6cc3fdf linter/no-inferrable-types: Implement fixer (#17090) (camc314)
- 2067997 linter/no-negation-in-equality-check: Implement suggestion
(#17084) (camc314)
- 552f9ef vscode: Auto-generate VSCode README configuration from
package.json (#16970) (Copilot)
- 9190c4b linter/no-unnecessary-array-flat-depth: Implement fixer
(#17057) (camc314)
- ed789de linter/misrefactored-assign-op: Implement fixer (#17056)
(camc314)
- a0f74a0 linter/config: Allow aliasing plugin names to allow names the
same as builtin plugins (#15569) (Cameron)
- a43d251 linter/plugins: `RuleTester` support `languageOptions.globals`
(#17009) (overlookmotel)
- 35070d9 linter/bad-bitwise-operator: Implement fixer (#17006)
(camc314)
- 322d995 linter/prefer-enum-initializers: Implement fixer (#17004)
(camc314)
- ae1e5bc vscode: Add support for tsgolint binary configuration (#16921)
(ColemanDunn)
- 3bfe31e linter/eslint-plugin-vitest: Add prefer-called-with as vitest
compatible jest rule (#16993) (Said Atrahouch)
- 0cd075f linter/eslint-plugin-jest: Add fix capabilities to
prefer-called-with rule (#16987) (Said Atrahouch)
- 357564b linter: Add options for
`typescript/require-array-sort-compare` rule. (#16980) (connorshea)
- 2b0ffba linter: Add options for
`typescript/no-meaningless-void-operator` rule. (#16981) (connorshea)
- 8bc4287 linter/plugins: Validate options against schema (#16974)
(overlookmotel)
- fdc7d08 linter: Implement eslint/capitalized-comments (#16896) (Tu
Shaokun)
- f8b6561 linter: Add support for `test.for` in vitest (#16925)
(camchenry)
- 7ee0379 linter/eslint-plugin-vitest: Implement prefer-spy-on (#16426)
(Said Atrahouch)
- fc96ee0 linter: Implement jest/prefer-to-have-been-called-times
(#16938) (秦宇航)
- 291b57b ast_tools: Generate TS declaration files for deserializer and
walk files (#16912) (camc314)
- e31da2a linter: Implement jest/perfer-to-have-been-called (#16899)
(秦宇航)
- 1a31306 linter/eslint-plugin-vitest: Add require-hook as vitest
compatible jest rule (#16880) (Said Atrahouch)
- cd3db21 linter: Add ignoredTypeNames option to no-base-to-string rule
(#16898) (camc314)
- 763b25a linter: Implement eslint/no-inline-comments (#16885) (Tu
Shaokun)

### 🐛 Bug Fixes

- fb9e193 linter: OOM problems with custom plugins (#17082)
(overlookmotel)
- 005ec25 linter: Permit `$schema` `.oxlintrc.json` struct (#17060)
(Copilot)
- fd03131 linter/plugins: Handle plugin names containing slashes
(#17073) (overlookmotel)
- b2a4fac linter/plugins: Error if plugin name alias is not normalized
(#17071) (overlookmotel)
- e046c4e linter/no-misused-spread: Add rule options support (#17054)
(camc314)
- 5c1a9e0 linter/no-deprecated: Add rule options support (#17053)
(camc314)
- 8c9cafe linter: `import/consistent-type-specifier-style`: add support
for declaration files (#16979) (camchenry)
- dab4780 linter/no-empty-pattern: Misleading help message for arrays
(#17039) (Copilot)
- 67f8c5d linter/plugins: Get correct plugin name in all cases (#17033)
(overlookmotel)
- 674dab9 linter/plugins: Fix indentation in error message (#17018)
(overlookmotel)
- 6524f72 linter/plugins: Add `@types/node` dev dependency to `oxlint`
package (#17016) (overlookmotel)
- 7a35513 linter/plugins: Better error for `null` in `globals` in
`RuleTester` (#17011) (overlookmotel)
- 42603ba linter/plugins: Always define `languageOptions.globals`
(#17008) (overlookmotel)
- 4cdc2f8 linter: Fix VITEST override rule list and add test for
alphabetizing the two lists (#16975) (Connor Shea)
- e466562 linter/consistent-type-definitions: Handle parenthesized types
in rule (#16998) (camc314)
- fce267c linter: Correct vitest plugin source to be
`@vitest/eslint-plugin` (#16976) (connorshea)
- 477bb57 linter: Fix `vitest/no-restricted-vi-methods` and add tests
for it. (#16971) (connorshea)
- 7d6974d linter: Ignore oxlint directive comments in
capitalized-comments (#16989) (Tu Shaokun)
- 23ac6b1 linter/plugins: Apply defaults from `meta.schema` to options
(#16930) (overlookmotel)
- 2f946cf linter/plugins: Error if `defaultOptions` is not
JSON-serializable (#16959) (overlookmotel)
- d8b8a57 linter/plugins: Freeze whole of merged options (#16958)
(overlookmotel)
- d446c43 linter: Prevent extra fields from being present on oxlint
config file (#16874) (connorshea)
- b845871 linter/plugins: Correctly handle object with `__proto__` keys
in options merging (#16928) (overlookmotel)
- c897794 linter: Fix eslint/sort-imports allowSeparatedGroups not
working with single empty line (#16012) (Duc Nghiem Xuan)
- 0c347a1 linter/array-type: Handle satisfies expression (#16903)
(camc314)

### ⚡ Performance

- 70d853c linter: Avoid cloning source text when cloning AST into
fixed-size allocator (#17088) (overlookmotel)
- 4d389f7 linter: Less bounds checks in `normalize_plugin_name` (#17030)
(overlookmotel)
- fd8e9c6 linter/plugins: Speed up cloning JSON objects (#16997)
(overlookmotel)
- d77e22d linter/plugins: Use `DEFAULT_OPTIONS` for rules with empty
array as default options (#16913) (overlookmotel)

### 📚 Documentation

- 6d053b4 linter: Fix typo in doc comment (#17091) (overlookmotel)
- b5f3c91 linter: Document intentional exclusion of ignoreCase option in
jsx-no-duplicate-props (#17046) (Copilot)
- a0bf5d8 linter: Fix the config option docs for no-inline-comments
rule. (#16983) (connorshea)
- ca26a11 linter/plugins: Fix typo in doc comment (#16966)
(overlookmotel)
- 3183bf8 linter/plugins: Fix typo in JSDoc comment (#16900)
(overlookmotel)
# Oxfmt
### 🚀 Features

- 15dfb55 oxfmt: Respect single nearest `.editorconfig` (#17043)
(leaysgur)
- 8c33ff4 oxfmt: Expose Node.js API: `format(fileName, sourceText,
options?)` (#16939) (leaysgur)

### 🐛 Bug Fixes

- d340c87 oxfmt: Update api `FormatOptions` type with `& Record<string,
unknown>` (#17036) (leaysgur)
- 827a256 oxfmt: Place ignorePatterns at bottom of JSON in --migrate
prettier (#16926) (Boshen)

Co-authored-by: overlookmotel <[email protected]>
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-cli Area - CLI A-linter Area - Linter A-linter-plugins Area - Linter JS plugins 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

Comments