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

fix: prevent console logging duplicate deprecation warnings #7733

Merged
merged 9 commits into from
Jan 9, 2024
12 changes: 11 additions & 1 deletion core/utils/deprecation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

// Former goog.module ID: Blockly.utils.deprecation

// create a set variable to store messages
const checkMsg = new Set();
ebrahim95 marked this conversation as resolved.
Show resolved Hide resolved

/**
* Warn developers that a function or property is deprecated.
*
Expand Down Expand Up @@ -33,5 +36,12 @@ export function warn(
if (opt_use) {
msg += '\nUse ' + opt_use + ' instead.';
}
console.warn(msg);

// this will help prevent logging deprecation warnings multiple times
if (!checkMsg.has(msg)) {
checkMsg.add(msg);
console.warn(msg);
} else {
return;
}
ebrahim95 marked this conversation as resolved.
Show resolved Hide resolved
}
Loading