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
10 changes: 10 additions & 0 deletions 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

// Set of previously-emitted warnings.
const previousWarnings = new Set();

/**
* 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.';
}

// Don't log deprecation warnings multiple times.
if (previousWarnings.has(msg)) {
return;
}

previousWarnings.add(msg);
console.warn(msg);
}
Loading