SIGN IN SIGN UP
denoland / deno UNCLAIMED

A modern runtime for JavaScript and TypeScript.

0 0 3 Rust

feat(ops): add enum support to FromV8 derive (#34241)

Mirrors the externally-tagged-enum support that `ToV8` already has: unit
variants are read from a `v8::String`, single-element newtype variants
are read from a `v8::Object` with a single key matching the variant
name. Variant names are camelCased by default; `#[from_v8(rename =
"...")]` overrides, and `#[from_v8(serde)]` falls back to `serde_v8` for
the inner type so callers can adopt the derive without first migrating
every inner type.

Other modes (internally tagged, adjacently tagged, untagged) and
multi-element tuple / struct variants are left for follow-ups when a
caller actually needs them.

**Real caller** in this same commit: `TestResult` in
`cli/tools/test/mod.rs` is converted. Its JS-visible shape is preserved
— `"ok"` / `"ignored"` / `"cancelled"` strings for the unit variants and
`{ failed: ... }` for the newtype variant. `TestFailure` stays on serde
via `#[from_v8(serde)]` on the `Failed` variant.

Continues #34239 + #34240 (move `serde_v8` call sites off serde where
the v8-derive traits can handle the conversion directly).

---------

Co-authored-by: Leo Kettmeir <crowlkats@toaxl.com>
C
crowlbot committed
559b734a56531606df28645908ff431ec50fcce2
Parent: 5185f18
Committed by GitHub <noreply@github.com> on 6/1/2026, 4:26:16 PM