通用 ts
的类型工具
pnpm i m-type-tools
import { isString } from 'm-type-tools'
isString('foo') // true
isString(1) // false
let bar: any = 'bar'
if (isString(bar)) {
bar.toLowerCase() // 类型正确的
}
import type { UnArray } from 'm-type-tools'
type Foo = UnArray<number[]> // number
type Bar = UnArray<string[]> // string
更多的类型工具可见 👉 源码
由 udeno 提供开箱支持
import { isString } from 'https://deno.land/x/mtype@v0.2.9/mod.ts'
欢迎关注 帝莎编程
Made with markthree
Published under MIT License.