简体   繁体   English

在typescript中导出联合类型别名

[英]Export a union type alias in typescript

Is it possible to export something like this: 是否可以导出这样的东西:

export TypeA | TypeB as TypeAB;

and declare a variable of TypeAB that can be either of TypeA or TypeB : 并声明TypeAB的变量,可以是TypeATypeB

import {TypeAB} from './typeab';
var ab: TypeAB;

是的,只需要类型别名的正确语法:

export type TypeAB = TypeA | TypeB;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM