Skip to main content

m-type-tools

通用 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

更多的类型工具可见 👉 源码



Deno 支持

udeno 提供开箱支持

import { isString } from 'https://deno.land/x/mtype@v0.2.9/mod.ts'


组织 🦔

欢迎关注 帝莎编程



License

Made with markthree

Published under MIT License.