Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Break eager cycle for "deprecate" function #20714

Merged
merged 1 commit into from
Jul 11, 2024
Merged
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
13 changes: 7 additions & 6 deletions packages/@ember/debug/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { isChrome, isFirefox } from '@ember/-internals/browser-environment';
import type { AnyFn } from '@ember/-internals/utility-types';
import { DEBUG } from '@glimmer/env';
import type { DeprecateFunc, DeprecationOptions } from './lib/deprecate';
import _deprecate from './lib/deprecate';
import defaultDeprecate from './lib/deprecate';
import { isTesting } from './lib/testing';
import type { WarnFunc } from './lib/warn';
import _warn from './lib/warn';
Expand Down Expand Up @@ -75,7 +75,7 @@ let assert: AssertFunc = noop as unknown as AssertFunc;
let info: InfoFunc = noop;
let warn: WarnFunc = noop;
let debug: DebugFunc = noop;
let deprecate: DeprecateFunc = noop;
let currentDeprecate: DeprecateFunc | undefined;
let debugSeal: DebugSealFunc = noop;
let debugFreeze: DebugFreezeFunc = noop;
let runInDebug: RunInDebugFunc = noop;
Expand All @@ -86,6 +86,10 @@ let deprecateFunc: DeprecateFuncFunc = function () {
return arguments[arguments.length - 1];
};

export function deprecate(...args: Parameters<DeprecateFunc>): ReturnType<DeprecateFunc> {
return (currentDeprecate ?? defaultDeprecate)(...args);
}

if (DEBUG) {
setDebugFunction = function (type: DebugFunctionType, callback: Function) {
switch (type) {
Expand All @@ -98,7 +102,7 @@ if (DEBUG) {
case 'debug':
return (debug = callback as DebugFunc);
case 'deprecate':
return (deprecate = callback as DeprecateFunc);
return (currentDeprecate = callback as DeprecateFunc);
case 'debugSeal':
return (debugSeal = callback as DebugSealFunc);
case 'debugFreeze':
Expand Down Expand Up @@ -314,8 +318,6 @@ if (DEBUG) {
}
});

setDebugFunction('deprecate', _deprecate);

setDebugFunction('warn', _warn);
}

Expand Down Expand Up @@ -353,7 +355,6 @@ export {
info,
warn,
debug,
deprecate,
debugSeal,
debugFreeze,
runInDebug,
Expand Down
Loading