Skip to content

Add ArrayFlat type #1085

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 8 commits into
base: main
Choose a base branch
from
Open

Conversation

Emiyaaaaa
Copy link
Collaborator

@Emiyaaaaa Emiyaaaaa requested a review from Copilot March 31, 2025 03:09
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request adds tests for the new ArrayFlat type and updates the README to document its behavior.

  • Added comprehensive tests in test-d/array-flat.ts to verify ArrayFlat across various array structures and depth parameters.
  • Updated readme.md to include an entry for ArrayFlat, describing its behavior similar to Array#flat().

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
test-d/array-flat.ts Added tests for the ArrayFlat type covering basic, nested, explicit depth, union, rest elements, and readonly arrays cases.
readme.md Added documentation for the ArrayFlat type.
Comments suppressed due to low confidence (3)

test-d/array-flat.ts:13

  • [nitpick] Consider renaming 'Arr' to a more descriptive name like 'NestedArray' to improve clarity.
type Arr = [[0, [1, [2, [3, [4, [5]]]]]]];

test-d/array-flat.ts:40

  • [nitpick] Consider clarifying the intent behind using 'Array<3>'. If it is meant to represent an array of the literal 3, a more descriptive type alias could improve readability.
expectType<ArrayFlat<[1, [2, ...Array<3>], 4]>>([1, 2, ...(null! as Array<3>), 4]);

readme.md:288

  • [nitpick] Consider expanding the description to clarify how 'ArrayFlat' handles explicit depths and union types, which may help users better understand its usage.
+ [`ArrayFlat`](source/array-flat.d.ts) - Creates a new array type by flattening an array to a specified depth, just like `Array#flat()`.

Copy link
Collaborator

@som-sm som-sm left a comment

Choose a reason for hiding this comment

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

@Emiyaaaaa Added comments on the tests — haven’t reviewed the implementation yet.

@Emiyaaaaa Emiyaaaaa requested a review from som-sm April 30, 2025 09:27
@Emiyaaaaa Emiyaaaaa marked this pull request as draft April 30, 2025 09:41
@Emiyaaaaa Emiyaaaaa marked this pull request as ready for review April 30, 2025 09:58
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.

Proposal: Flat (equivalent to Array.prototype.flat())
3 participants