Skip to content

fix(cdk): preserve prototype chains in array helpers #1874

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

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

Conversation

Karnaukhov-kh
Copy link
Member

@Karnaukhov-kh Karnaukhov-kh commented Jun 11, 2025

update, upsert, and toDictionary functions were losing the prototype chain of objects, causing instanceof checks to fail. Spread operator was the cause of it.

Key Changes:

  • Prototype Preservation: Replaced the use of the spread operator with Object.create and Object.assign to preserver prototype chain.
  • Unit Tests: Added unit tests in update.spec.ts, upsert.spec.ts, and toDictionary.spec.ts to verify that class instances maintain the prototype after transform.

Closes #1480

@github-actions github-actions bot added 🛂 Test Unit tests, e2e tests, integration tests, test coverage 🛠️ CDK CDK related labels Jun 11, 2025
@Karnaukhov-kh Karnaukhov-kh requested a review from hoebbelsB June 11, 2025 17:32
Copy link

nx-cloud bot commented Jun 11, 2025

View your CI Pipeline Execution ↗ for commit c75f07c.

Command Status Duration Result
nx affected -t lint build test component-test e... ❌ Failed 15s View ↗
nx-cloud record -- npx nx format:check ✅ Succeeded 1s View ↗

☁️ Nx Cloud last updated this comment at 2025-07-02 18:28:29 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🛠️ CDK CDK related 🛂 Test Unit tests, e2e tests, integration tests, test coverage
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update transformation looses typing
1 participant