negate() function
述語関数の反対の結果を返す関数を作成します。
Signature:
typescript
declare function negate<T, N extends T>(
predicate: (input: T) => input is N,
): (input: T) => input is Exclude<T, N>;Example
ts
const isDefined: (input: string | undefined) => input is string = negate(isUndefined)<string | undefined>
const isDefined: (input: unknown) => boolean = negate((input) => input === undefined)