Not
自 1.1.0 起
布尔类型的逻辑非运算。
签名
typescript
type Not<B extends boolean> = B extends true ? false : true参数
| 参数 | 描述 |
|---|---|
B | 要取反的布尔类型 |
示例
基本用法
typescript
import type { Not } from 'uni-types'
type A = Not<true> // false
type B = Not<false> // true条件类型
typescript
import type { Not, IsAny } from 'uni-types'
type IsDefined<T> = Not<IsAny<T>>
type A = IsDefined<string> // true
type B = IsDefined<any> // false