Skip to content

Commit a5e33a1

Browse files
authored
Merge pull request #20714 from emberjs/debug-cycle
Break eager cycle for "deprecate" function
2 parents 0da8387 + 89b6d9c commit a5e33a1

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

packages/@ember/debug/index.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { isChrome, isFirefox } from '@ember/-internals/browser-environment';
22
import type { AnyFn } from '@ember/-internals/utility-types';
33
import { DEBUG } from '@glimmer/env';
44
import type { DeprecateFunc, DeprecationOptions } from './lib/deprecate';
5-
import _deprecate from './lib/deprecate';
5+
import defaultDeprecate from './lib/deprecate';
66
import { isTesting } from './lib/testing';
77
import type { WarnFunc } from './lib/warn';
88
import _warn from './lib/warn';
@@ -75,7 +75,7 @@ let assert: AssertFunc = noop as unknown as AssertFunc;
7575
let info: InfoFunc = noop;
7676
let warn: WarnFunc = noop;
7777
let debug: DebugFunc = noop;
78-
let deprecate: DeprecateFunc = noop;
78+
let currentDeprecate: DeprecateFunc | undefined;
7979
let debugSeal: DebugSealFunc = noop;
8080
let debugFreeze: DebugFreezeFunc = noop;
8181
let runInDebug: RunInDebugFunc = noop;
@@ -86,6 +86,10 @@ let deprecateFunc: DeprecateFuncFunc = function () {
8686
return arguments[arguments.length - 1];
8787
};
8888

89+
export function deprecate(...args: Parameters<DeprecateFunc>): ReturnType<DeprecateFunc> {
90+
return (currentDeprecate ?? defaultDeprecate)(...args);
91+
}
92+
8993
if (DEBUG) {
9094
setDebugFunction = function (type: DebugFunctionType, callback: Function) {
9195
switch (type) {
@@ -98,7 +102,7 @@ if (DEBUG) {
98102
case 'debug':
99103
return (debug = callback as DebugFunc);
100104
case 'deprecate':
101-
return (deprecate = callback as DeprecateFunc);
105+
return (currentDeprecate = callback as DeprecateFunc);
102106
case 'debugSeal':
103107
return (debugSeal = callback as DebugSealFunc);
104108
case 'debugFreeze':
@@ -314,8 +318,6 @@ if (DEBUG) {
314318
}
315319
});
316320

317-
setDebugFunction('deprecate', _deprecate);
318-
319321
setDebugFunction('warn', _warn);
320322
}
321323

@@ -353,7 +355,6 @@ export {
353355
info,
354356
warn,
355357
debug,
356-
deprecate,
357358
debugSeal,
358359
debugFreeze,
359360
runInDebug,

0 commit comments

Comments
 (0)