From ff8d69ab8a549b21df0ff6f3b1b145ba2045ed26 Mon Sep 17 00:00:00 2001 From: Patrick Pircher Date: Sun, 10 Sep 2023 09:49:11 +0200 Subject: [PATCH 1/3] Overwrite addMixin (#8850) * use addMixin * here too (cherry picked from commit 5a771b39124ab7ee60953c95624c556e9491ad06) --- packages/model/src/-private/promise-many-array.ts | 4 ++-- packages/store/src/-private/record-arrays/identifier-array.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/model/src/-private/promise-many-array.ts b/packages/model/src/-private/promise-many-array.ts index fcd7ecbe0e1..be03f62abf7 100644 --- a/packages/model/src/-private/promise-many-array.ts +++ b/packages/model/src/-private/promise-many-array.ts @@ -58,7 +58,7 @@ export default class PromiseManyArray { if (DEPRECATE_A_USAGE) { const meta = Ember.meta(this); - meta.hasMixin = (mixin: Object) => { + meta.addMixin = (mixin: Object) => { deprecate(`Do not use A() on an EmberData PromiseManyArray`, false, { id: 'ember-data:no-a-with-array-like', until: '5.0', @@ -73,7 +73,7 @@ export default class PromiseManyArray { }; } else if (DEBUG) { const meta = Ember.meta(this); - meta.hasMixin = (mixin: Object) => { + meta.addMixin = (mixin: object) => { assert(`Do not use A() on an EmberData PromiseManyArray`); }; } diff --git a/packages/store/src/-private/record-arrays/identifier-array.ts b/packages/store/src/-private/record-arrays/identifier-array.ts index 475a08d35ed..006ca51553a 100644 --- a/packages/store/src/-private/record-arrays/identifier-array.ts +++ b/packages/store/src/-private/record-arrays/identifier-array.ts @@ -524,7 +524,7 @@ class IdentifierArray { }; } else if (DEBUG) { const meta = Ember.meta(this); - meta.hasMixin = (mixin: Object) => { + meta.addMixin = (mixin: Object) => { assert(`Do not call A() on EmberData RecordArrays`); }; } From 7d908163b9f6760cde016a23cb18ebf7a06d90c1 Mon Sep 17 00:00:00 2001 From: Katie Gengler Date: Fri, 9 Feb 2024 12:35:32 -0500 Subject: [PATCH 2/3] Change another hasMixin -> addMixin that I believe was missed only because the deprecated code was removed in later versions - Remove the type definition for `hasMixin` on `ember` - Add a type definition for `addMixin` on `ember` --- @types/ember/index.d.ts | 2 +- packages/store/src/-private/record-arrays/identifier-array.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/@types/ember/index.d.ts b/@types/ember/index.d.ts index 19ad6401313..9888d0c70c8 100644 --- a/@types/ember/index.d.ts +++ b/@types/ember/index.d.ts @@ -3,7 +3,7 @@ import EmberArrayProtoExtensions from '@ember/array/types/prototype-extensions'; declare module 'ember' { export function run(callback: Function); export function meta(obj: Object): { - hasMixin(mixin: Object): boolean; + addMixin(mixin: Object): boolean; }; interface ArrayPrototypeExtensions extends EmberArrayProtoExtensions {} } diff --git a/packages/store/src/-private/record-arrays/identifier-array.ts b/packages/store/src/-private/record-arrays/identifier-array.ts index 006ca51553a..2ddcd3ca921 100644 --- a/packages/store/src/-private/record-arrays/identifier-array.ts +++ b/packages/store/src/-private/record-arrays/identifier-array.ts @@ -509,7 +509,7 @@ class IdentifierArray { if (DEPRECATE_A_USAGE) { const meta = Ember.meta(this); - meta.hasMixin = (mixin: Object) => { + meta.addMixin = (mixin: Object) => { deprecate(`Do not call A() on EmberData RecordArrays`, false, { id: 'ember-data:no-a-with-array-like', until: '5.0', From f90ef11f68367817c6b9ac18c51922b1829f7f83 Mon Sep 17 00:00:00 2001 From: Kirill Shaplyko Date: Sat, 11 May 2024 22:37:22 +0200 Subject: [PATCH 3/3] Use both `addMixin` and `hasMixin` for deprecations --- @types/ember/index.d.ts | 3 ++- packages/model/src/-private/promise-many-array.ts | 10 +++++++++- .../src/-private/record-arrays/identifier-array.ts | 12 +++++++----- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/@types/ember/index.d.ts b/@types/ember/index.d.ts index 9888d0c70c8..213921acadb 100644 --- a/@types/ember/index.d.ts +++ b/@types/ember/index.d.ts @@ -3,7 +3,8 @@ import EmberArrayProtoExtensions from '@ember/array/types/prototype-extensions'; declare module 'ember' { export function run(callback: Function); export function meta(obj: Object): { - addMixin(mixin: Object): boolean; + addMixin(mixin: Object): void; + hasMixin(mixin: Object): boolean; }; interface ArrayPrototypeExtensions extends EmberArrayProtoExtensions {} } diff --git a/packages/model/src/-private/promise-many-array.ts b/packages/model/src/-private/promise-many-array.ts index be03f62abf7..30e347df74e 100644 --- a/packages/model/src/-private/promise-many-array.ts +++ b/packages/model/src/-private/promise-many-array.ts @@ -58,7 +58,7 @@ export default class PromiseManyArray { if (DEPRECATE_A_USAGE) { const meta = Ember.meta(this); - meta.addMixin = (mixin: Object) => { + meta.hasMixin = (mixin: Object) => { deprecate(`Do not use A() on an EmberData PromiseManyArray`, false, { id: 'ember-data:no-a-with-array-like', until: '5.0', @@ -71,6 +71,14 @@ export default class PromiseManyArray { } return false; }; + meta.addMixin = (mixin: object) => { + deprecate(`Do not use A() on an EmberData PromiseManyArray`, false, { + id: 'ember-data:no-a-with-array-like', + until: '5.0', + since: { enabled: '4.7', available: '4.7' }, + for: 'ember-data', + }); + }; } else if (DEBUG) { const meta = Ember.meta(this); meta.addMixin = (mixin: object) => { diff --git a/packages/store/src/-private/record-arrays/identifier-array.ts b/packages/store/src/-private/record-arrays/identifier-array.ts index 2ddcd3ca921..507996adddb 100644 --- a/packages/store/src/-private/record-arrays/identifier-array.ts +++ b/packages/store/src/-private/record-arrays/identifier-array.ts @@ -509,6 +509,13 @@ class IdentifierArray { if (DEPRECATE_A_USAGE) { const meta = Ember.meta(this); + meta.hasMixin = (mixin: Object) => { + // @ts-expect-error ArrayMixin is more than a type + if (mixin === NativeArray || mixin === ArrayMixin) { + return true; + } + return false; + }; meta.addMixin = (mixin: Object) => { deprecate(`Do not call A() on EmberData RecordArrays`, false, { id: 'ember-data:no-a-with-array-like', @@ -516,11 +523,6 @@ class IdentifierArray { since: { enabled: '4.7', available: '4.7' }, for: 'ember-data', }); - // @ts-expect-error ArrayMixin is more than a type - if (mixin === NativeArray || mixin === ArrayMixin) { - return true; - } - return false; }; } else if (DEBUG) { const meta = Ember.meta(this);