Repository navigation
feat(ast)!: remove duplicated VariableDeclarator::kind - #25319
Conversation
Merging this PR will not alter performance
Comparing Footnotes
|
There was a problem hiding this comment.
Pull request overview
This PR removes the duplicated VariableDeclarator::kind field from the Rust AST, making VariableDeclaration::kind the single source of truth and updating all affected consumers (parser validation, semantic binding, lints, transforms, minifier, NAPI JS bindings, and generated layout/ancestor accessors) to derive the declarator kind from its parent declaration.
Changes:
- Eliminates
VariableDeclarator::kindfrom the Rust AST and updates generated builders/layout assertions accordingly. - Updates semantic/lint/minifier/transformer logic to read variable declaration kind from the containing
VariableDeclaration(or traversal ancestry) instead of the declarator. - Updates NAPI JS lazy constructors and deserializers to account for the changed raw layout offset of
VariableDeclarator.definite.
Reviewed changes
Copilot reviewed 58 out of 73 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| napi/parser/src-js/generated/lazy/constructors.js | Adjusts lazy field offsets for VariableDeclarator.definite in JS bindings. |
| napi/parser/src-js/generated/deserialize/ts.js | Adjusts TS deserializer offset for VariableDeclarator.definite. |
| napi/parser/src-js/generated/deserialize/ts_range.js | Adjusts TS-range deserializer offset for VariableDeclarator.definite. |
| napi/parser/src-js/generated/deserialize/ts_range_parent.js | Adjusts TS-range-parent deserializer offset for VariableDeclarator.definite. |
| napi/parser/src-js/generated/deserialize/ts_parent.js | Adjusts TS-parent deserializer offset for VariableDeclarator.definite. |
| crates/oxc_traverse/src/generated/ancestor.rs | Removes generated raw-offset accessors for removed VariableDeclarator::kind. |
| crates/oxc_transformer/src/typescript/namespace.rs | Switches const-ness checks and declarator construction to parent VariableDeclaration::kind. |
| crates/oxc_transformer/src/typescript/module.rs | Updates declarator construction to new kind-less VariableDeclarator::new. |
| crates/oxc_transformer/src/typescript/enum.rs | Updates declarator construction to new kind-less VariableDeclarator::new. |
| crates/oxc_transformer/src/plugins/tagged_template_transform.rs | Removes now-invalid VariableDeclarationKind argument from declarator construction. |
| crates/oxc_transformer/src/jsx/refresh.rs | Removes now-invalid VariableDeclarationKind argument from declarator construction. |
| crates/oxc_transformer/src/jsx/jsx_source.rs | Removes now-invalid VariableDeclarationKind argument from declarator construction. |
| crates/oxc_transformer/src/es2026/explicit_resource_management.rs | Removes redundant per-declarator kind synchronization and updates constructor calls. |
| crates/oxc_transformer/src/es2022/class_properties/utils.rs | Removes now-invalid kind argument from declarator construction helper. |
| crates/oxc_transformer/src/es2022/class_properties/constructor.rs | Removes now-invalid VariableDeclarationKind argument from declarator construction. |
| crates/oxc_transformer/src/es2018/object_rest_spread.rs | Threads parent declaration kind through helpers instead of reading from declarator. |
| crates/oxc_transformer/src/es2018/async_generator_functions/for_await.rs | Captures kind from VariableDeclaration before moving a declarator. |
| crates/oxc_transformer/src/es2017/async_to_generator.rs | Removes now-invalid VariableDeclarationKind argument from declarator construction. |
| crates/oxc_transformer/src/decorator/legacy/mod.rs | Removes now-invalid VariableDeclarationKind argument from declarator construction. |
| crates/oxc_transformer/src/common/var_declarations.rs | Updates declarator construction helpers to new kind-less constructor. |
| crates/oxc_transformer/src/common/module_imports.rs | Updates declarator construction to new kind-less constructor. |
| crates/oxc_transformer/src/common/arrow_function_converter.rs | Removes now-invalid VariableDeclarationKind argument from declarator construction sites. |
| crates/oxc_transformer_plugins/src/module_runner_transform.rs | Updates declarator construction to new kind-less constructor. |
| crates/oxc_semantic/src/lib.rs | Updates tests to derive kind from parent VariableDeclaration. |
| crates/oxc_semantic/src/checker/javascript.rs | Updates semantic checks to use VariableDeclaration::kind via ancestry. |
| crates/oxc_semantic/src/binder.rs | Updates binding logic to use parent VariableDeclaration for kind/declare. |
| crates/oxc_react_compiler/src/react_compiler/entrypoint/program.rs | Updates declarator construction to new kind-less constructor. |
| crates/oxc_react_compiler/src/react_compiler_reactive_scopes/codegen_reactive_function.rs | Updates declarator construction to new kind-less constructor. |
| crates/oxc_parser/src/js/statement.rs | Passes declaration kind into missing-initializer validation. |
| crates/oxc_parser/src/js/declaration.rs | Removes kind from declarator creation; updates initializer validation to take parent kind. |
| crates/oxc_minifier/src/peephole/substitute_alternate_syntax.rs | Uses ancestry to reject using when deciding if init-result is unused. |
| crates/oxc_minifier/src/peephole/remove_unused_declaration.rs | Threads parent declaration kind into “remove unused declarator” logic. |
| crates/oxc_minifier/src/peephole/normalize.rs | Removes redundant per-declarator kind synchronization. |
| crates/oxc_minifier/src/peephole/minimize_statements.rs | Threads parent declaration kind into unused-declarator checks and related logic. |
| crates/oxc_minifier/src/peephole/inline.rs | Derives declaration kind from traversal parent ancestry instead of declarator field. |
| crates/oxc_minifier/src/keep_var.rs | Updates declarator construction to new kind-less constructor. |
| crates/oxc_minifier/src/generated/ancestor.rs | Removes generated raw-offset accessors for removed VariableDeclarator::kind. |
| crates/oxc_linter/src/utils/this_expression.rs | Uses parent-derived declaration kind for const checks. |
| crates/oxc_linter/src/rules/vue/valid_define_options.rs | Uses parent-derived declaration kind for const/literal allowances. |
| crates/oxc_linter/src/rules/vue/no_multiple_slot_args.rs | Uses parent-derived declaration kind for const override logic. |
| crates/oxc_linter/src/rules/unicorn/prefer_top_level_await.rs | Uses parent-derived declaration kind when matching const declarations. |
| crates/oxc_linter/src/rules/unicorn/prefer_set_size.rs | Uses parent-derived declaration kind when validating const bindings. |
| crates/oxc_linter/src/rules/unicorn/prefer_set_has.rs | Uses parent-derived declaration kind for var/let filtering. |
| crates/oxc_linter/src/rules/unicorn/prefer_import_meta_properties.rs | Uses parent-derived declaration kind for const-only checks. |
| crates/oxc_linter/src/rules/unicorn/prefer_at.rs | Uses parent-derived declaration kind for const-only stability heuristics. |
| crates/oxc_linter/src/rules/unicorn/prefer_array_flat.rs | Uses parent-derived declaration kind for const initializer checks. |
| crates/oxc_linter/src/rules/unicorn/no_useless_undefined.rs | Uses parent-derived declaration kind for const exclusions. |
| crates/oxc_linter/src/rules/unicorn/no_array_fill_with_reference_type.rs | Uses parent-derived declaration kind for const initializer resolution. |
| crates/oxc_linter/src/rules/unicorn/consistent_existence_index_check.rs | Uses parent-derived declaration kind when requiring const. |
| crates/oxc_linter/src/rules/react/exhaustive_deps.rs | Uses parent-derived declaration kind when determining stable values. |
| crates/oxc_linter/src/rules/oxc/bad_char_at_comparison.rs | Threads lint context to enable parent-derived declaration kind checks. |
| crates/oxc_linter/src/rules/eslint/require_unicode_regexp.rs | Uses parent-derived declaration kind when resolving const initializers. |
| crates/oxc_linter/src/rules/eslint/prefer_destructuring.rs | Uses parent-derived declaration kind to skip using variants. |
| crates/oxc_linter/src/rules/eslint/no_unused_vars/mod.rs | Passes lint context through to allowed-variable-declaration logic. |
| crates/oxc_linter/src/rules/eslint/no_unused_vars/allowed.rs | Uses parent-derived declaration kind for var/using allowlisting logic. |
| crates/oxc_linter/src/rules/eslint/no_underscore_dangle.rs | Uses parent-derived declaration kind to detect using binding context. |
| crates/oxc_linter/src/rules/eslint/no_unassigned_vars.rs | Uses parent-derived declaration kind for const exemptions. |
| crates/oxc_linter/src/rules/eslint/no_magic_numbers.rs | Uses parent-derived declaration kind when enforcing const declarations. |
| crates/oxc_linter/src/rules/eslint/no_const_assign.rs | Uses parent-derived declaration kind to select const/using bindings to track. |
| crates/oxc_linter/src/rules/eslint/init_declarations.rs | Uses parent-derived declaration kind for const behavior in init-declarations. |
| crates/oxc_linter/src/ast_util.rs | Adds shared helper variable_declaration_kind to get kind from parent node. |
| crates/oxc_isolated_declarations/src/module.rs | Updates declarator construction to new kind-less constructor. |
| crates/oxc_isolated_declarations/src/lib.rs | Threads parent declaration kind into declarator transformation. |
| crates/oxc_isolated_declarations/src/declaration.rs | Threads parent kind through inference logic; updates declarator construction. |
| crates/oxc_formatter/src/ast_nodes/generated/ast_nodes.rs | Removes generated VariableDeclarator.kind() accessor. |
| crates/oxc_ast/src/generated/derive_dummy.rs | Removes dummy-derive initialization for removed VariableDeclarator::kind. |
| crates/oxc_ast/src/generated/derive_content_eq.rs | Removes kind from VariableDeclarator content equality comparison. |
| crates/oxc_ast/src/generated/derive_clone_in.rs | Removes kind from VariableDeclarator clone-in implementation. |
| crates/oxc_ast/src/generated/ast_builder.rs | Updates generated VariableDeclarator::new signature and field init. |
| crates/oxc_ast/src/generated/assert_layouts.rs | Updates layout assertions/offsets for VariableDeclarator after field removal. |
| crates/oxc_ast/src/ast/js.rs | Removes the kind field from the AST definition of VariableDeclarator. |
| crates/oxc_ast_macros/src/generated/structs.rs | Updates macro metadata (field order) for the new VariableDeclarator shape. |
| apps/oxlint/src-js/generated/deserialize.js | Adjusts oxlint JS deserializer offset for VariableDeclarator.definite. |
|
@codex review |
|
Codex Review: Didn't find any major issues. Swish! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Merge activity
|
## Summary
- Removes `VariableDeclarator::kind`.
- Makes `VariableDeclaration::kind` the single source of truth for every declarator in its declaration list.
- Makes contradictory parent and child declaration kinds unrepresentable.
## Breaking Change
The Rust AST changes from:
```rust
pub struct VariableDeclaration<'a> {
pub node_id: Cell<NodeId>,
pub span: Span,
pub kind: VariableDeclarationKind,
pub declarations: Vec<'a, VariableDeclarator<'a>>,
#[ts]
pub declare: bool,
}
pub struct VariableDeclarator<'a> {
pub node_id: Cell<NodeId>,
pub span: Span,
#[estree(skip)]
pub kind: VariableDeclarationKind,
#[estree(via = VariableDeclaratorId)]
pub id: BindingPattern<'a>,
#[ts]
#[estree(skip)]
pub type_annotation: Option<Box<'a, TSTypeAnnotation<'a>>>,
pub init: Option<Expression<'a>>,
#[ts]
pub definite: bool,
}
```
to:
```rust
pub struct VariableDeclaration<'a> {
pub node_id: Cell<NodeId>,
pub span: Span,
pub kind: VariableDeclarationKind,
pub declarations: Vec<'a, VariableDeclarator<'a>>,
#[ts]
pub declare: bool,
}
pub struct VariableDeclarator<'a> {
pub node_id: Cell<NodeId>,
pub span: Span,
#[estree(via = VariableDeclaratorId)]
pub id: BindingPattern<'a>,
#[ts]
#[estree(skip)]
pub type_annotation: Option<Box<'a, TSTypeAnnotation<'a>>>,
pub init: Option<Expression<'a>>,
#[ts]
pub definite: bool,
}
```
## Why?
A variable declaration has one declaration kind shared by every declarator in its declaration list:
```js
const first = 1, second = 2;
```
Previously, the AST stored that kind on both the parent declaration and every child declarator:
```text
VariableDeclaration {
kind: Const,
declarations: [
VariableDeclarator { kind: Const, ... },
VariableDeclarator { kind: Const, ... },
],
}
```
This allowed contradictory ASTs to be constructed:
```text
VariableDeclaration {
kind: Const,
declarations: [
VariableDeclarator { kind: Var, ... },
],
}
```
Different consumers read different copies:
- Code generation used `VariableDeclaration::kind`.
- Semantic binding used `VariableDeclarator::kind`.
- Lint rules, transforms, and minifier passes used a mixture of both.
As a result, one AST could be emitted as `const` while its binding was treated as function-scoped `var`.
Transforms also had to keep the copies synchronized manually. For example, const-to-let normalization updated the parent and then looped through every declarator to update each child. Explicit resource management performed similar paired mutations for `using` declarations.
Keeping the kind only on `VariableDeclaration` removes this synchronization requirement and prevents consumers from observing conflicting declaration semantics.
## Declaration forms
The declaration kind now belongs exclusively to the node that owns the declaration list:
```js
let value;
```
```text
VariableDeclaration {
kind: Let,
declarations: [
VariableDeclarator { id: value, ... },
],
}
```
Multiple declarators share the same parent kind:
```js
const first = 1, second = 2;
```
```text
VariableDeclaration {
kind: Const,
declarations: [
VariableDeclarator { id: first, ... },
VariableDeclarator { id: second, ... },
],
}
```
## How to migrate
Code that previously read the kind from a declarator:
```rust
if declarator.kind.is_const() {
// ...
}
```
should now read it from the containing declaration:
```rust
if declaration.kind.is_const() {
// ...
}
```
Consumers operating through an AST node store should retrieve the parent `VariableDeclaration`:
```rust
let AstKind::VariableDeclaration(declaration) =
nodes.parent_kind(declarator.node_id())
else {
unreachable!();
};
let kind = declaration.kind;
```
Common migrations:
| Previous representation | New representation |
| --- | --- |
| `declarator.kind` | Containing `declaration.kind` |
| Match `VariableDeclarator::kind` during semantic binding | Read the parent `VariableDeclaration` from ancestry |
| Pass `kind` to `VariableDeclarator::new` | Remove the `kind` argument |
| Update parent and every child kind | Update only `VariableDeclaration::kind` |
| Recover kind after detaching a declarator | Capture or pass the parent kind before detaching it |
| Inspect a symbol’s declarator kind in lint rules | Resolve its parent declaration through the node store |
When constructing declarators, use the generated kindless `VariableDeclarator` builders and place them inside a `VariableDeclaration` carrying the required kind.
fixes https://github.com/oxc-project/backlog/issues/237
267faab to
6be314f
Compare
oxc-project/oxc#25319 Oxc-Revision: 6be314f22605c3ea83cfe8d5d22c2bad76212a35
oxc-project/oxc#25319 Oxc-Revision: 6be314f22605c3ea83cfe8d5d22c2bad76212a35
### 💥 BREAKING CHANGES - a33788e ast: [**BREAKING**] Group class heritage into `ClassHeritage` (#25360) (camc314) - 5c5cdcd ast: [**BREAKING**] Narrow `TSInterfaceHeritage::expression` to TSTypeName (#24360) (camc314) - 6be314f ast: [**BREAKING**] Remove duplicated `VariableDeclarator::kind` (#25319) (camc314) - 44fd320 ast: [**BREAKING**] Split TS external modules & Namespace Declarations (#25284) (camc314) ### 🚀 Features - 9a37c41 napi: Restructure React transform options (#25326) (Boshen) - b3c1b30 allocator: Add `ArenaVec::push_mut` (#25338) (overlookmotel) ### 🐛 Bug Fixes - bbd6ed3 codegen: Wrap string literal in parens after directives (#25435) (overlookmotel) - d07a293 codegen: Preserve cast parentheses in conditional tests (#25115) (camc314) - 8b7d441 codegen: Preserve satisfies parentheses before bitwise operators (#25113) (camc314) - e0fb2d7 minifier: Avoid unsafe return removal in labeled blocks (#25406) (Armano) - c49f4ce parser: Preserve terminal license comments (#25400) (camc314) - 9d19ab3 transform_react: Downgrade nonfatal compiler diagnostics (#25418) (Boshen) - 937825c react_compiler: Disable exhaustive memo validation by default (#25417) (Boshen) - 12937b3 parser: Reject comma expressions in class fields (#25385) (Cameron) - 7d8a9b5 react_compiler: Preserve hook spans for React Refresh (#25393) (Boshen) - 9e93ba6 parser: Reset auto-accessor initializer context (#25384) (camc314) - cc2e28d parser: Reject trailing tokens in `Parser::parse_expression` (#25371) (camc314) - 697c629 minifier: Preserve Annex B labeled-function bindings in implicit-return rewrite (#25349) (Armano) - 4d723ca parser: Report TS1035 for quoted module names (#25305) (camc314) - 0c9b980 semantic: Report module declaration diagnostics (#25285) (camc314) - 2a1058a napi: Omit parser header from WASI declarations (#25254) (camc314) ### ⚡ Performance - dd1430b semantic: Avoid allocation in class overload check (#25440) (camc314) - e420816 parser: Optimize trailing comma tracking (#25376) (camc314) - 6529d1a minifier: Short-circuit scope check when alternate already determines result (#25318) (Armano) ### 📚 Documentation - fe111eb allocator: Improve doc comments for `Arena` methods (#24922) (overlookmotel)
# Oxlint ### 💥 BREAKING CHANGES - a33788e ast: [**BREAKING**] Group class heritage into `ClassHeritage` (#25360) (camc314) - 5c5cdcd ast: [**BREAKING**] Narrow `TSInterfaceHeritage::expression` to TSTypeName (#24360) (camc314) - 6be314f ast: [**BREAKING**] Remove duplicated `VariableDeclarator::kind` (#25319) (camc314) - 44fd320 ast: [**BREAKING**] Split TS external modules & Namespace Declarations (#25284) (camc314) ### 🚀 Features - ccb8fe8 linter/jsdoc: Implement `no-blank-blocks` rule (#25207) (Mikhail Baev) - d4a897c linter/eslint: Implement `one-var` rule (#24470) (Cole Ellison) - 5ab9340 linter/jsx-a11y/anchor-has-content: Add options to match eslint (#24571) (Cole Ellison) ### 🐛 Bug Fixes - b746e00 linter/eslint/no-implicit-coercion: Preserve template coercion whitespace (#25470) (camc314) - a92c541 linter: Preserve source text for JS plugin ignore fixes (#25280) (Norcleeh) - 675c840 linter/eslint/prefer-promise-reject-errors: Handle parenthesized calls (#25378) (camc314) - 1703739 linter/unicorn/new-for-builtins: Ignore optional chains (#25411) (tanakalucky) - 95ece63 linter/unicorn/prefer-code-point: Downgrade the auto-fix to dangerous (#25412) (leemr) - c451a0e linter/vitest: Validate `consistent-test-filename` regex patterns (#25408) (Mikhail Baev) - 937825c react_compiler: Disable exhaustive memo validation by default (#25417) (Boshen) - f0f7dae linter/eslint/no-unused-vars: Report invalid regex options (#25380) (Cameron) - 44e73fd linter/unicorn/prefer-array-flat: Fix `concat.apply` suggestions (#25373) (Cameron) - 6846a9a linter/react/rules-of-hooks: Detect constructor callbacks (#25377) (camc314) - b247a9d linter/unicorn/new-for-builtins: Support `Float16Array` (#25382) (tanakalucky) - 19109cd linter/unicorn/error-message: Support `SuppressedError` messages (#25375) (camc314) - 9c13f5e linter: Assert token lookup invariants (#25368) (camc314) - bc35f83 linter/eslint/no-unused-vars: Bound catch parameter lookup (#25367) (camc314) - c159fb9 linter/unicorn/switch-case-braces: Bound token lookup (#25363) (camc314) - 03b2eb2 linter/unicorn/no-static-only-class: Bound token lookup (#25361) (camc314) - 0afc59e linter/unicorn/empty-brace-spaces: Bound token lookup (#25353) (camc314) - 2963d98 linter/eslint/no-unreachable-loop: Do not report loops whose body has a finally block (#25335) (Todor Andonov) - 589e5fb linter/eslint/no-param-reassign: Validate `ignorePropertyModificationsForRegex` property (#25346) (Mikhail Baev) - aae5d8b linter/eslint/no-throw-literal: False positive on variable declared without initializer (#25275) (cjnoname) - 6b1c479 oxlint: Normalize customized rule names (#25316) (camc314) - d494eb5 linter/unicorn/consistent-existence-index-check: Bound token lookup (#25325) (camc314) - 4266037 linter/typescript/prefer-namespace-keyword: Bound token lookup (#25322) (camc314) - 4745b4e linter/typescript/no-namespace: Bound token lookup (#25321) (camc314) - 648a481 linter/eslint/one-var: Avoid joining exported declarations (#25314) (camc314) - 9573937 linter/typescript: Validate `ban-ts-comment` description_format (#25320) (Mikhail Baev) - ebf7d18 linter/typescript/consistent-type-definitions: Bound token lookup (#25281) (camc314) - 1501ccf linter/typescript/consistent-generic-constructors: Bound token lookup (#25258) (camc314) ### ⚡ Performance - 8f784f3 linter: Reduce rule config dispatch size (#25461) (Boshen) - 2de4ec2 linter: Reduce visitor code size (#25441) (Boshen) - 6fb7f47 linter/unicorn/prefer-export-from: Narrow `ExportFromDeclaration` lookup (#25381) (camc314) - e3f6263 linter/unicorn/prefer-default-parameters: Avoid reference allocation (#25379) (camc314) - d863473 linter/vue/max-props: Narrow AST dispatch (#25372) (camc314) - 273d867 linter: Avoid diagnostic sorting after applying fixes (#25079) (Sysix) - 4ec9189 oxlint/lsp: Avoid second lock for getting/removing unused directives (#25350) (Sysix) - 6c0d01b oxlint/lsp: Preallocate fix-content vec (#25351) (Sysix) - 3a94055 linter: Avoid per-call heap allocations in jest and unicorn helpers (#25210) (Connor Shea) - 4abff11 linter: Avoid redundant message work in the agent reporter (#25315) (Connor Shea) - 6bb5421 linter: Hoist `current_dir` out of the stylish reporter loop (#25313) (Connor Shea) - 9a7c323 linter: Compute diagnostic `Info` once per diagnostic in junit reporter (#25312) (Connor Shea) - 1cf7dde oxlint: Render JSON report into a single buffer (#25295) (connorshea) - 8492cfd linter/typescript/ban-ts-comment: Bail early with substring guard (#25301) (Jacob Asper) - 7607f04 linter/typescript/ban-tslint-comment: Replace regex with manual parser (#25299) (Jacob Asper) # Oxfmt ### 💥 BREAKING CHANGES - a33788e ast: [**BREAKING**] Group class heritage into `ClassHeritage` (#25360) (camc314) - 5c5cdcd ast: [**BREAKING**] Narrow `TSInterfaceHeritage::expression` to TSTypeName (#24360) (camc314) - 6be314f ast: [**BREAKING**] Remove duplicated `VariableDeclarator::kind` (#25319) (camc314) - 44fd320 ast: [**BREAKING**] Split TS external modules & Namespace Declarations (#25284) (camc314) ### 🚀 Features - fd02a89 oxfmt: Dispatch yaml-in-css(frontmatter) to `oxc_formatter_yaml` (#25336) (leaysgur) - ab12665 formatter_core: Add `hardlineWithoutBreakParent` equivalent IR (#25273) (leaysgur) ### 🐛 Bug Fixes - 95dc917 oxfmt: Drop IR Space at line start for js-in-xxx (#25460) (leaysgur) - b63eccc formatter: Keep comments after TS this_param (#25459) (leaysgur) - ab52a59 formatter: Format xxx-in-js inside JSDoc js fence (#25414) (leaysgur) - 1a2c64a formatter,oxfmt: Apply effective print width for JSDoc fence (#25413) (leaysgur) - 2eaede9 formatter_core: Unify leading-BOM handlings (#25340) (leaysgur) - ef1d04b formatter: Break mapped type brackets (#25297) (leaysgur) - 4e6f3f1 formatter: Break index signature brackets (#25296) (leaysgur) - e23dccf formatter_css: Bump oxc-css-parser to accept unknown at-rule with interpolated (#25277) (leaysgur) - c29b587 formatter_core: Measure decided-flat fill separator as flat during group re-measure (#25276) (leaysgur) - f3c6953 formatter_yaml: Don't rewrite overflowing key to implicit (#25274) (leaysgur) ### ⚡ Performance - c9d1a5b oxfmt: Spawn tinypool lazily (#25298) (leaysgur) ### 📚 Documentation - 6eae5c9 formatter,oxfmt: Record embed-layer decisions in place (#25422) (leaysgur) - 51224a7 formatter_yaml: Pin EOF blank lines divergence (#25269) (leaysgur)
This PR updates oxc to 0.144.0, and migrates rolldown following the breaking changes. Please review commit by commit - oxc-project/oxc#25284 [dc3f407](dc3f407) - oxc-project/oxc#25319 [a8a7931](a8a7931) - oxc-project/oxc#25360 [e6db5d1](e6db5d1)
Summary
VariableDeclarator::kind.VariableDeclaration::kindthe single source of truth for every declarator in its declaration list.Breaking Change
The Rust AST changes from:
to:
Why?
A variable declaration has one declaration kind shared by every declarator in its declaration list:
Previously, the AST stored that kind on both the parent declaration and every child declarator:
This allowed contradictory ASTs to be constructed:
Different consumers read different copies:
VariableDeclaration::kind.VariableDeclarator::kind.As a result, one AST could be emitted as
constwhile its binding was treated as function-scopedvar.Transforms also had to keep the copies synchronized manually. For example, const-to-let normalization updated the parent and then looped through every declarator to update each child. Explicit resource management performed similar paired mutations for
usingdeclarations.Keeping the kind only on
VariableDeclarationremoves this synchronization requirement and prevents consumers from observing conflicting declaration semantics.Declaration forms
The declaration kind now belongs exclusively to the node that owns the declaration list:
Multiple declarators share the same parent kind:
How to migrate
Code that previously read the kind from a declarator:
should now read it from the containing declaration:
Consumers operating through an AST node store should retrieve the parent
VariableDeclaration:Common migrations:
declarator.kinddeclaration.kindVariableDeclarator::kindduring semantic bindingVariableDeclarationfrom ancestrykindtoVariableDeclarator::newkindargumentVariableDeclaration::kindWhen constructing declarators, use the generated kindless
VariableDeclaratorbuilders and place them inside aVariableDeclarationcarrying the required kind.fixes #25686