Skip to content

Commit

Permalink
Fix the types for the mutation-methods of NativeArray
Browse files Browse the repository at this point in the history
(cherry picked from commit bdefd5f)
  • Loading branch information
boris-petrov authored and kategengler committed Jul 17, 2023
1 parent d65300e commit 150c4f9
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 150c4f9

Please sign in to comment.