Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions packages/@ember/-internals/utils/lib/internal-mixin-create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,14 @@
@private
*/
export const INTERNAL_MIXIN_CREATE = Symbol('__internal__mixin__');

/**
Key for the internal equivalent of `CoreObject.extend`.

The public `extend` notifies when a deprecated framework mixin such as
`Observable` is applied. Ember's own classes must still extend with those
mixins, so they use this Symbol-keyed method, which skips the notice.

@private
*/
export const INTERNAL_MIXIN_EXTEND = Symbol('__internal__mixin__extend__');
14 changes: 13 additions & 1 deletion packages/@ember/object/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ import { defineProperty } from '@ember/-internals/metal/lib/properties';
import { descriptorForProperty, isClassicDecorator } from '@ember/-internals/metal/lib/decorator';
import { DEBUG_INJECTION_FUNCTIONS } from '@ember/-internals/metal/lib/injected_property';
import Mixin, { applyMixin } from '@ember/object/mixin';
import { INTERNAL_MIXIN_CREATE } from '@ember/-internals/utils/lib/internal-mixin-create';
import {
INTERNAL_MIXIN_CREATE,
INTERNAL_MIXIN_EXTEND,
} from '@ember/-internals/utils/lib/internal-mixin-create';
import { deprecateAppliedMixins } from '@ember/-internals/utils/lib/deprecated-mixin';
import ActionHandler from '@ember/-internals/runtime/lib/mixins/action_handler';
import makeArray from '@ember/array/make';
Expand Down Expand Up @@ -716,6 +719,15 @@ class CoreObject {
): Readonly<Statics> & EmberClassConstructor<Instance> & MergeArray<M>;
static extend(...mixins: any[]) {
deprecateAppliedMixins(mixins);
return this[INTERNAL_MIXIN_EXTEND](...mixins);
}

/** @internal */
static [INTERNAL_MIXIN_EXTEND]<Statics, Instance, M extends Array<unknown>>(
this: Statics & EmberClassConstructor<Instance>,
...mixins: M
): Readonly<Statics> & EmberClassConstructor<Instance> & MergeArray<M>;
static [INTERNAL_MIXIN_EXTEND](...mixins: any[]) {
let Class = class extends this {};
reopen.apply(Class.PrototypeMixin, mixins);
return Class;
Expand Down
9 changes: 3 additions & 6 deletions packages/@ember/object/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { isElementDescriptor, setClassicDecorator } from '@ember/-internals/meta
import expandProperties from '@ember/-internals/metal/lib/expand_properties';
import { getFactoryFor } from '@ember/-internals/container/lib/container';
import { setObservers } from '@ember/-internals/utils/lib/super';
import { INTERNAL_MIXIN_EXTEND } from '@ember/-internals/utils/lib/internal-mixin-create';
import type { AnyFn } from '@ember/-internals/utility-types';
import CoreObject from '@ember/object/core';
import Observable from '@ember/object/observable';
Expand Down Expand Up @@ -36,12 +37,8 @@ export { default as computed } from '@ember/-internals/metal/lib/computed';
*/
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
interface EmberObject extends Observable {}
class EmberObject extends CoreObject {
static {
// `extend(Observable)` would fire the Observable deprecation for every app.
this.PrototypeMixin.reopen(Observable);
}

// `extend(Observable)` would fire the Observable deprecation for every app.
class EmberObject extends CoreObject[INTERNAL_MIXIN_EXTEND](Observable) {
get _debugContainerKey() {
let factory = getFactoryFor(this);
return factory !== undefined && factory.fullName;
Expand Down