diff --git a/core/utils/deprecation.ts b/core/utils/deprecation.ts index da7977c3e84..c793b5f57dd 100644 --- a/core/utils/deprecation.ts +++ b/core/utils/deprecation.ts @@ -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. * @@ -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); }