fix: keep getter-based names when adding methods from structures by kerdofficial · Pull Request #1693 · dsherret/ts-morph · GitHub
Skip to content

fix: keep getter-based names when adding methods from structures - #1693

Open
kerdofficial wants to merge 1 commit into
dsherret:latestfrom
kerdofficial:fix/1527-getter-structure-name
Open

kerdofficial wants to merge 1 commit into
dsherret:latestfrom
kerdofficial:fix/1527-getter-structure-name

Conversation

@kerdofficial

Copy link
Copy Markdown

Fixes #1527

insertMethods() copied each structure with { ...s }. A spread only copies own enumerable properties, so a structure class with a name getter lost its name and the insert failed with a ManipulationError.

The copy isn't needed: nothing in the insert path writes to the passed structures (overload defaults are applied to their own copies). This removes it.

Added a test with a getter-based name (fails without the change), and one that passes frozen structures to show the input is not modified. deno task test, deno task code-verification and deno task type-check pass.

This branch has not been deployed

No deployments
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.

ClassDeclaration::set() can't take instances of a class structure with getters among the methods safely

1 participant