Skip to content

fix: support native array methods on collections - #1214

Open
Jannik-cmyk wants to merge 2 commits into
asyncapi:masterfrom
Jannik-cmyk:agent/fix-collection-native-array-methods
Open

fix: support native array methods on collections#1214
Jannik-cmyk wants to merge 2 commits into
asyncapi:masterfrom
Jannik-cmyk:agent/fix-collection-native-array-methods

Conversation

@Jannik-cmyk

@Jannik-cmyk Jannik-cmyk commented Aug 2, 2026

Copy link
Copy Markdown

Summary

  • make native Collection transforms return plain arrays through Symbol.species
  • preserve the existing constructor and metadata invariants
  • add regression tests for map, filter, and slice

Root cause

Native Array transforms use the subclass species constructor. They pass an array length, but Collection expects an iterable of models and spreads it into super(), causing the reported error. Returning Array from Symbol.species keeps Collection construction strict while making transforms return normal arrays.

Validation

  • reproduced the old failure in a focused harness
  • verified map, filter, and slice return plain arrays
  • verified the source collection and metadata remain unchanged
  • TypeScript transpilation checks
  • git diff --check
  • branch changes only the implementation, regression tests, and patch changeset

Fixes #874

@changeset-bot

changeset-bot Bot commented Aug 2, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 0794048

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@asyncapi/parser Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Welcome to AsyncAPI. Thanks a lot for creating your first pull request. Please check out our contributors guide useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.

@sonarqubecloud

sonarqubecloud Bot commented Aug 2, 2026

Copy link
Copy Markdown

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.

javascript map() function doesn't work on SecurityRequirements object.

1 participant