UNPKG

1.45 kBTypeScriptView Raw
1export type preMessageFn = (message: string, type: 'warning' | 'note') => string | null | undefined | number;
2/**
3 * Pre warning enable you to parse content before console.error.
4 * Modify to null will prevent warning.
5 */
6export declare const preMessage: (fn: preMessageFn) => void;
7/**
8 * Warning if condition not match.
9 * @param valid Condition
10 * @param message Warning message
11 * @example
12 * ```js
13 * warning(false, 'some error'); // print some error
14 * warning(true, 'some error'); // print nothing
15 * warning(1 === 2, 'some error'); // print some error
16 * ```
17 */
18export declare function warning(valid: boolean, message: string): void;
19/** @see Similar to {@link warning} */
20export declare function note(valid: boolean, message: string): void;
21export declare function resetWarned(): void;
22export declare function call(method: (valid: boolean, message: string) => void, valid: boolean, message: string): void;
23/** @see Same as {@link warning}, but only warn once for the same message */
24export declare function warningOnce(valid: boolean, message: string): void;
25export declare namespace warningOnce {
26 var preMessage: (fn: preMessageFn) => void;
27 var resetWarned: typeof import("./warning").resetWarned;
28 var noteOnce: typeof import("./warning").noteOnce;
29}
30/** @see Same as {@link warning}, but only warn once for the same message */
31export declare function noteOnce(valid: boolean, message: string): void;
32export default warningOnce;