Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Chris Krycho <hello@chriskrycho.com>
  • Loading branch information
kategengler and chriskrycho authored Dec 12, 2023
1 parent fdf9d8f commit 747cbc7
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions packages/@ember/debug/lib/warn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@ export interface WarnOptions {
}

export type RegisterHandlerFunc = (handler: HandlerCallback<WarnOptions>) => void;
export type WarnFunc = (
message: string,
test: boolean | WarnOptions,
options?: WarnOptions
) => void;
export interface WarnFunc {
(message: string, options: WarnOptions): void;
(
message: string,
test: boolean,
options: WarnOptions
): void;
}

let registerHandler: RegisterHandlerFunc = () => {};
let warn: WarnFunc = () => {};
Expand Down Expand Up @@ -111,7 +114,10 @@ if (DEBUG) {
assert(missingOptionsDeprecation, Boolean(options));
assert(missingOptionsIdDeprecation, Boolean(options && options.id));

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 747cbc7

Please sign in to comment.