Skip to content

Commit

Permalink
Merge pull request #20501 from boris-petrov/fix-native-array-mutation…
Browse files Browse the repository at this point in the history
…-method-types

[BUGFIX stable] Fix the types for the mutation-methods of `NativeArray`
  • Loading branch information
wagenet committed Jul 11, 2023
2 parents 3d43480 + bdefd5f commit 9e51c36
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/@ember/array/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1899,7 +1899,7 @@ const MutableArray = Mixin.create(EmberArray, MutableEnumerable, {
@module ember
*/

type AnyArray<T> = EmberArray<T> | Array<T>;
type AnyArray<T> = EmberArray<T> | Array<T> | ReadonlyArray<T>;

/**
* The final definition of NativeArray removes all native methods. This is the list of removed methods
Expand Down
4 changes: 4 additions & 0 deletions packages/@ember/array/type-tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,10 @@ expectTypeOf(arr.without(foo)).toEqualTypeOf<NativeArray<Foo>>();
// @ts-expect-error invalid type
arr.without(1);

expectTypeOf(arr.pushObjects(arr)).toEqualTypeOf<NativeArray<Foo>>();
expectTypeOf(arr.pushObjects([foo] as Foo[])).toEqualTypeOf<NativeArray<Foo>>();
expectTypeOf(arr.pushObjects([foo] as readonly Foo[])).toEqualTypeOf<NativeArray<Foo>>();

expectTypeOf(isArray(arr)).toEqualTypeOf<boolean>();

expectTypeOf(makeArray(arr)).toEqualTypeOf<NativeArray<Foo>>();
Expand Down

0 comments on commit 9e51c36

Please sign in to comment.