javascript - 从 ts 文件导出多个 typescript 类型别名时出现错误“Unexpected token”
问题描述
沙盒:https ://codesandbox.io/s/typescript-export-question-tlbd2
错误将开启export type {
type abc = {
a: string;
};
type bbc = {bbb: string}
export type {
abc,
bbc,
}
导出类型是不应该做的吗?我正在尝试尽可能多地重用类型。如果有更好的选择请告诉我
解决方案
如果您尝试导出类型以便可以像这样导入它们:
import { abc, bbc } from './my-types';
您可以在声明它们时简单地导出:
export type abc = {
a: string;
};
export type bbc = {bbb: string}
但您可能也在寻找 TypeScript namespace
,如果是这种情况,请查看此处的文档。
推荐阅读
- angular - 动态样式表链接
- java - 用于数字浮动的正则表达式黄瓜小黄瓜
- python - 在我的 Mac 上用 Python 安装 BeautifulSoup 时,我遇到了这个问题。我已经更新了设置工具,问题依然存在
- html - 通过 Excel VBA 实现 IE11 自动化 - 表单
- angular - 手势处理 AgmMap 不起作用
- c# - Access Api 在浏览器上创建了谷歌电子表格
- javascript - 在 ionic 3 中导入依赖于 jQuery 的库
- c++ - 多个重载函数实例
- python - Spark parquet 在组内分配索引
- http - 如何在golang中为http标头中的主机与url中的主机设置不同的值