Skip to content

Fix methods containing nested functions and arrows - #231

Open
Shubham-Padkonde wants to merge 2 commits into
yahoo:mainfrom
Shubham-Padkonde:fix/method-body-function-detection
Open

Shubham-Padkonde wants to merge 2 commits into
yahoo:mainfrom
Shubham-Padkonde:fix/method-body-function-detection

Conversation

@Shubham-Padkonde

@Shubham-Padkonde Shubham-Padkonde commented Oct 2, 2026 •

Copy link
Copy Markdown

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.

Validation: all four new tests fail on the original implementation. All 106 tests pass after the change (node --test test/unit/*.js); git diff --check passes.

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.

Bug when used an object with a function and a variable with a function and destructuring

1 participant