Skip to content

Why can toCollection return a non-array? #366

Open
@dmitriybo

Description

@dmitriybo

Description

In my opinion, the toCollection method should always return an array (if it does not passed length, then length = 1). The reason for this is very simple: toCollection is used to generate an array of elements. If for some reason you think otherwise, then at least make the correct typing. Currently toCollection always returns the type Collection | Collection[], but should return Collection[] if length is passed.

image

The example in the specification also needs to be improved:

image

Proposed solution

No response

Alternatives considered

No response

Do you want to create a pull request?

No

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions