@@ -16,8 +16,18 @@ export const preMessage = (fn: preMessageFn) => {
16
16
preWarningFns . push ( fn ) ;
17
17
} ;
18
18
19
+ /**
20
+ * Warning if condition not match.
21
+ * @param valid Condition
22
+ * @param message Warning message
23
+ * @example
24
+ * ```js
25
+ * warning(false, 'some error'); // print some error
26
+ * warning(true, 'some error'); // print nothing
27
+ * warning(1 === 2, 'some error'); // print some error
28
+ * ```
29
+ */
19
30
export function warning ( valid : boolean , message : string ) {
20
- // Support uglify
21
31
if (
22
32
process . env . NODE_ENV !== 'production' &&
23
33
! valid &&
@@ -34,8 +44,8 @@ export function warning(valid: boolean, message: string) {
34
44
}
35
45
}
36
46
47
+ /** @see Similar to {@link warning} */
37
48
export function note ( valid : boolean , message : string ) {
38
- // Support uglify
39
49
if (
40
50
process . env . NODE_ENV !== 'production' &&
41
51
! valid &&
@@ -67,10 +77,12 @@ export function call(
67
77
}
68
78
}
69
79
80
+ /** @see Same as {@link warning}, but only warn once for the same message */
70
81
export function warningOnce ( valid : boolean , message : string ) {
71
82
call ( warning , valid , message ) ;
72
83
}
73
84
85
+ /** @see Same as {@link warning}, but only warn once for the same message */
74
86
export function noteOnce ( valid : boolean , message : string ) {
75
87
call ( note , valid , message ) ;
76
88
}
@@ -80,4 +92,3 @@ warningOnce.resetWarned = resetWarned;
80
92
warningOnce . noteOnce = noteOnce ;
81
93
82
94
export default warningOnce ;
83
- /* eslint-enable */
0 commit comments