文件名称:type_guard_util
文件大小:60KB
文件格式:ZIP
更新时间:2024-05-01 10:17:34
TypeScript
TS中的类型开关
一些在golang使用type guard utils在golang进行type-switch ,例如golang 。
使用
安装包
npm install type_guard_util
使用
import { TypeIs } from '../src/TypeIs'
type Water = {
drink: string
}
type Food = {
eat: string
}
const example = (waterOrfood: Water | Food) => {
if(TypeIs
【文件预览】:
type_guard_util-master
----example()
--------typeis_example.ts(715B)
----index.js(0B)
----package.json(757B)
----test()
--------TypeIs.test.ts(435B)
----.prettierrc(95B)
----jest.config.js(73B)
----package-lock.json(201KB)
----src()
--------TypeIs.ts(370B)
----tsconfig.json(6KB)
----.gitignore(19B)
----README.md(600B)
----LICENSE.txt(1KB)