Skip to content

guards.Function.and

github-actions[bot] edited this page Jun 8, 2026 · 2 revisions

@zenstone/ts-utils / guards / and

Function: and()

and<T>(...guards): TypeGuard<T>

Defined in: src/guards/index.ts:455

组合守卫(AND)

第一个守卫收窄类型到 T,后续守卫在 T 上做进一步筛选

Type Parameters

T

T

Parameters

guards

...[(val) => val is T, ...((val: T) => boolean)[]]

第一个为类型守卫,后续为断言函数

Returns

TypeGuard<T>

组合后的守卫函数

Example

const isStrAry = aryGuard(isStr);
const isNonEmptyStrAry = and(isStrAry, (arr) => arr.length > 0);

Clone this wiki locally