Skip to content

fix: keep class features and using native where Node.js runs them - #819

Merged
Brooooooklyn merged 1 commit into
mainfrom
claude/native-syntax-target-f6rv1w
Oct 10, 2026
Merged

Brooooooklyn merged 1 commit into
mainfrom
claude/native-syntax-target-f6rv1w

Conversation

@Brooooooklyn

Copy link
Copy Markdown
Member

Requested by Brooklyn · project thread

Closes #808

Before: class fields, #private members and static blocks were always lowered (_defineProperty, WeakMaps, helper imports), and using / await using were always lowered to usingCtx, on every Node.js version. Function.prototype.toString(), stack traces and the debugger saw the lowered class.

After: class features reach Node.js as written unless the class has to differ from the source, which means [[Set]] field semantics (useDefineForClassFields: false) or experimentalDecorators. using is lowered only when the running Node.js is older than 24. Most scripts now import no helpers at all.

How: transform_program sets class_properties / class_static_block from set_public_class_fields || legacy_decorators, as the issue proposes. A module_exports hook reads Env::get_node_version() once when the addon loads and stores whether using is native. If the version can't be read (for example a WASI host without the call, or cargo test), using stays lowered.

One visible change: with native fields, a field initializer that reads a TypeScript parameter property (b = this.a; constructor(public a) {}) now runs before the parameter is assigned. That is exactly what tsc emits for ES2022+ with [[Define]], and tsc reports it as TS2729.

Tests:

  • class-fields.spec.ts checks that class features stay native by default and with useDefineForClassFields: true, that they are still lowered with useDefineForClassFields: false or experimentalDecorators, and that using is native exactly on Node.js ≥ 24.
  • The helper-imports.spec.ts fixtures now set experimentalDecorators, so they still emit a helper on every Node.js version. The bare-directory and poisoned-copy rows gained that tsconfig too, because without it they would pass without loading any helper.
  • cargo clippy -D warnings, cargo test, vp check and pnpm test pass locally on Node.js 22.22 and 24.21.

🤖 Generated with Claude Code

https://claude.ai/code/session_01J7Bsyf8U45ySQyKDX1bAU3


Generated by Claude Code

Class fields, #private members and static blocks are now lowered only when
the emitted class has to differ from the source ([[Set]] field semantics or
legacy decorators). `using` / `await using` are lowered only when the
running Node.js is older than 24.

Closes #808

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01J7Bsyf8U45ySQyKDX1bAU3
@Brooooooklyn Brooooooklyn self-assigned this Oct 10, 2026
@Brooooooklyn
Brooooooklyn marked this pull request as ready for review October 10, 2026 03:21
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-10T03:25:55.648880Z e029959 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e029959edc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

Comment thread src/lib.rs Resolved
@Brooooooklyn
Brooooooklyn merged commit 7977433 into main Oct 10, 2026
67 checks passed
@Brooooooklyn
Brooooooklyn deleted the claude/native-syntax-target-f6rv1w branch October 10, 2026 07:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Do not lower class fields, private members, static blocks, and using on runtimes that run them natively

2 participants