deno
559b734a - feat(ops): add enum support to FromV8 derive (#34241)

Commit
57 days ago
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>
Author
Parents
Loading