Files
Dunqing 8ab883afaa fix(codegen): preserve property key annotations (#25766)
`@__KEY__` and `#__KEY__` are currently treated as normal comments. Codegen can drop them before a later property-mangling pass. The property may then be renamed while the annotated string keeps its old name.

This classifies the marker as a property-key annotation. Codegen keeps it next to string and no-substitution template literals when annotation comments are enabled, and the property mangler reads that classification instead of scanning source text. Final output still follows the normal comment options, so whitespace-minified or annotation-disabled output removes the marker.

## Example

Input:

```js
const object = { _field: 1 };
const key = /* #__KEY__ */ "_field";
object[key];
```

Before, an intermediate codegen pass could remove the marker:

```js
const object = { _field: 1 };
const key = "_field";
object[key];
```

After, the marker survives for the later property-mangling pass.

Verified with the affected crate suites, `just minsize`, workspace lint, docs, AST generation, and independent review. `just ready` is only blocked locally by existing Node-version and terminal-color snapshot differences.

Implemented with AI assistance (OpenAI Codex). I reviewed and understand the changes and remain responsible for this contribution under the repository AI usage policy.
2026-08-17 09:23:04 +00:00
..

Oxc AST

Abstract Syntax Tree definitions for JavaScript, TypeScript, and JSX.

Overview

This crate provides comprehensive AST (Abstract Syntax Tree) node definitions that support the full spectrum of JavaScript and TypeScript syntax, including JSX. The AST closely follows ECMAScript specifications while providing ergonomic APIs for manipulation.

Key Features

  • Complete language support: JavaScript, TypeScript, JSX, and TSX
  • ECMAScript compliant: AST structure follows official specifications
  • Memory efficient: Designed to work with oxc_allocator for fast allocation
  • Visitor patterns: Integrates with oxc_ast_visit for traversal
  • Type-safe: Leverages Rust's type system for correctness

AST Design Principles

The AST design differs from estree in several important ways:

  • Explicit identifiers: Uses specific types like BindingIdentifier, IdentifierReference, and IdentifierName instead of generic Identifier
  • Precise assignment targets: AssignmentExpression.left uses AssignmentTarget instead of generic Pattern
  • Literal specialization: Replaces generic Literal with BooleanLiteral, NumericLiteral, StringLiteral, etc.
  • Evaluation order: Field order follows ECMAScript evaluation order for consistency

Architecture

The AST is designed for:

  • Parse: Efficient construction during parsing
  • Transform: Easy manipulation during transpilation
  • Visit: Systematic traversal for analysis
  • Codegen: Clean conversion back to source code

All AST nodes are allocated in an arena (oxc_allocator) for optimal performance.