Skip to content

Commit

Permalink
Emit fewer deprecation warnings.
Browse files Browse the repository at this point in the history
In theory, you want to see any unique issue, but in practice… that’s
super annoying. Just changing this to key off the _message_ instead of
the _stack_. This means we will get at most one warning per deprecated
interface usage.
  • Loading branch information
theengineear committed Dec 5, 2024
1 parent fab50a7 commit f7dd569
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion ts/x-template.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 5 additions & 6 deletions x-template.js
Original file line number Diff line number Diff line change
Expand Up @@ -1016,14 +1016,13 @@ class TemplateEngine {
}
}

static #interfaceDeprecatedStacks = new Set();
static #interfaceDeprecatedMessages = new Set();
static #interfaceDeprecated(name, callback) {
return (...args) => {
const error = new Error(`Deprecated "${name}" from default templating engine interface.`);
const stack = error.stack;
if (!this.#interfaceDeprecatedStacks.has(stack)) {
this.#interfaceDeprecatedStacks.add(stack);
console.warn(error); // eslint-disable-line no-console
const message = `Deprecated "${name}" from default templating engine interface.`;
if (!this.#interfaceDeprecatedMessages.has(message)) {
this.#interfaceDeprecatedMessages.add(message);
console.warn(new Error(message)); // eslint-disable-line no-console
}
return callback(...args);
};
Expand Down

0 comments on commit f7dd569

Please sign in to comment.