chore: fix assertNumber for undefined value

This commit is contained in:
Evan You 2022-11-14 16:57:44 +08:00
parent 7d0c63ff43
commit ce363e55a8
2 changed files with 6 additions and 2 deletions

View File

@ -168,7 +168,9 @@ function formatProp(key: string, value: unknown, raw?: boolean): any {
*/ */
export function assertNumber(val: unknown, type: string) { export function assertNumber(val: unknown, type: string) {
if (!__DEV__) return if (!__DEV__) return
if (typeof val !== 'number') { if (val === undefined) {
return
} else if (typeof val !== 'number') {
warn(`${type} is not a valid number - ` + `got ${JSON.stringify(val)}.`) warn(`${type} is not a valid number - ` + `got ${JSON.stringify(val)}.`)
} else if (isNaN(val)) { } else if (isNaN(val)) {
warn(`${type} is NaN - ` + 'the duration expression might be incorrect.') warn(`${type} is NaN - ` + 'the duration expression might be incorrect.')

View File

@ -283,7 +283,9 @@ function normalizeDuration(
function NumberOf(val: unknown): number { function NumberOf(val: unknown): number {
const res = toNumber(val) const res = toNumber(val)
if (__DEV__) assertNumber(res, '<transition> explicit duration') if (__DEV__) {
assertNumber(res, '<transition> explicit duration')
}
return res return res
} }