Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: avoid cloning accessor properties #1305

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Hanake0
Copy link

@Hanake0 Hanake0 commented Feb 12, 2025

Ignore accessor properties to prevent assigning a “value” field when a getter or setter exists

This is my first pr, so please tell me if i missed someting.

This pr prevents the error "TypeError: Invalid property. 'value' present on property with getter or setter." when trying to parse an object with a getter or setter.

As an example, you would need to pass process.env with an spread operator({ process.env }) so it could be validated and not throw an error by the lib. With this fix, now it can be validated correctly without the spread operator.

I think the test "can clone process.env" at clone.test.ts might need to be changed to reflect this new behavior.

Ignore accessor properties to prevent assigning a “value” field when a getter or setter exists
@ssalbdivad
Copy link
Member

Thanks for the PR! Need to think about the implications a bit and will take another look after 2.1.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Planned
Development

Successfully merging this pull request may close these issues.

2 participants