Repository navigation
Fix methods containing nested functions and arrows - #231
Conversation
|
Thanks for this, and for the thorough round-trip tests. Anchoring the checks to the outer signature is the right fix for #118, and it merges cleanly onto current Classes now fall through to the method conversion. A class source starts with class A { m() { return x => x } }
serialize({ A })
// main: {"A":class A { m() { return x => x } }} ← valid
// PR: {"A":function(){ return x => x } }} ← SyntaxError(On Could you detect a |
redonkulus
left a comment
There was a problem hiding this comment.
Thanks for the fix and the quick turnaround on the class regression! Verified against current main: all tests pass, and nested arrows/declarations in concise, async, generator and computed-key methods now round-trip correctly.
Fixes #118. The function-kind regexes currently match anywhere in the source, so a concise method containing an arrow or function declaration is returned unchanged. That source is invalid in the generated object-property value and fails to deserialize.
Anchor detection to the outer function signature so concise methods still receive the existing function-expression conversion. Added round-trip cases for nested declarations, destructured arrow arguments, async methods, and generator methods. Additional cases preserve commented async signatures and arrows with function-valued defaults.
Explicitly preserve class expressions as well, including classes with and without nested arrows. A concise method named
classstill receives method conversion.Validation (23 October 2026, Windows/Node 24.15.0): both new class regression tests fail before this follow-up and pass afterward; the concise-method guard passes. All 109 tests pass with
node --test test/unit/*.js.git diff --checkpasses.