-
-
Notifications
You must be signed in to change notification settings - Fork 601
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
base: main
Are you sure you want to change the base?
Add ArrayFlat
type
#1085
Conversation
There was a problem hiding this 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()`.
3c19644
to
6ef28ba
Compare
There was a problem hiding this 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.
Flat
(equivalent toArray.prototype.flat()
) #1075