【文件属性】:
文件名称:ctors-union:通过构造函数定义联合类型
文件大小:8KB
文件格式:ZIP
更新时间:2021-04-04 18:33:49
TypeScript
工会
通过构造函数定义联合类型
如何安装
npm install ctors-union --save
介绍
要创建用于例如Redux操作的联合类型,您可以执行以下操作:
type Action = Foo | Bar | Curry ;
type Foo = { type : "Foo" ; foo : number } ;
type Bar = { type : "Bar" ; bar : string } ;
type Curry = { type : "Curry" ; one : string ; two : number } ;
function Foo ( foo : number ) {
return { type : "Foo" , foo } ;
}
function Bar ( bar : string ) {
return { type : "Bar" ,
【文件预览】:
ctors-union-main
----package.json(304B)
----src()
--------ctors-union.ts(2KB)
--------index.ts(31B)
--------__examples__()
----tsconfig.tsbuildinfo(16KB)
----tsconfig.json(625B)
----.gitignore(67B)
----README.md(2KB)
----yarn.lock(348B)