-
Notifications
You must be signed in to change notification settings - Fork 0
guards.Function.or
github-actions[bot] edited this page Jun 8, 2026
·
2 revisions
@zenstone/ts-utils / guards / or
or<
G>(...guards):TypeGuard<InferGuard<G[number]>>
Defined in: src/guards/index.ts:488
组合守卫(OR)
任意一个守卫通过即返回 true,自动推断联合类型
G extends [TypeGuard<any>, ...TypeGuard<any>[]]
...G
一个或多个守卫函数
TypeGuard<InferGuard<G[number]>>
组合后的守卫函数
const isStrOrNum = or(isStr, isNumber);
if (isStrOrNum(value)) {
// value: string | number
}