Skip to content

Commit

Permalink
Merge pull request #20224 from r-52/r/warn-ts
Browse files Browse the repository at this point in the history
Integrate types for the `warn` method
  • Loading branch information
kategengler authored Jan 10, 2024
2 parents 370cf34 + 46134da commit a18f149
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions packages/@ember/debug/lib/warn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,11 @@ if (DEBUG) {
@for @ember/debug
@static
@param {String} message A warning to display.
@param {Boolean} test An optional boolean. If falsy, the warning
will be displayed.
@param {Object} options An object that can be used to pass a unique
`id` for this warning. The `id` can be used by Ember debugging tools
@param {Boolean|Object} test An optional boolean. If falsy, the warning
will be displayed. If `test` is an object, the `test` parameter can
be used as the `options` parameter and the warning is displayed.
@param {Object} options
@param {String} options.id The `id` can be used by Ember debugging tools
to change the behavior (raise, log, or silence) for that specific warning.
The `id` should be namespaced by dots, e.g. "ember-debug.feature-flag-with-features-stripped"
@public
Expand All @@ -111,8 +112,10 @@ if (DEBUG) {
assert(missingOptionsDeprecation, Boolean(options));
assert(missingOptionsIdDeprecation, Boolean(options && options.id));

// SAFETY: we checked this by way of the `arguments` check above.
invoke('warn', message, test as boolean, options);
// SAFETY: we have explicitly assigned `false` if the user invoked the
// arity-2 version of the overload, so we know `test` is always either
// `undefined` or a `boolean` for type-safe callers.
invoke('warn', message, test as boolean | undefined, options);
};
}

Expand Down

0 comments on commit a18f149

Please sign in to comment.