Skip to content

Commit 6875104

Browse files
committed
improve typing for static .from() method
1 parent 21357a3 commit 6875104

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

CHANGELOG.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
# Changelog
22

33

4+
## [4.5.0](https://github.com/supercharge/arrays/compare/v4.4.0...v4.5.0) - 2024-07-xx
5+
6+
### Updated
7+
- static `from`: improve typing for returned instance type. This allows subclassing the `Arr` class and receiving the correct class instance type
8+
9+
410
## [4.4.0](https://github.com/supercharge/arrays/compare/v4.3.0...v4.4.0) - 2024-02-20
511

612
### Added
713
- `compact`: refined return type for truthy values
814

915
### Updated
1016
- `sort`: make the `comparator` parameter optional
11-
12-
### Updated
1317
- bump dependencies
1418
- bump dependencies in GitHub Actions testing workflow
1519

src/arr.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ export class Arr<T> {
2727
}
2828

2929
/**
30-
* Creates an array from an iterable object.
30+
* Creates an Arr instance from iterable values.
3131
*/
32-
static from<T> (...values: Values<T>): Arr<T> {
33-
return new this<T>(...values)
32+
static from<T, Ctor extends Arr<T>> (this: new (...values: Values<T>) => Ctor, ...values: Values<T>): Ctor {
33+
return new this(...values)
3434
}
3535

3636
/**

0 commit comments

Comments
 (0)