在一个文件中,我将我的包的所有类导出到如下行:
export {default as BoundList, IBoundListOption, TBoundListFilterFn} from './list/BoundList';
产生了以下形式的错误:
TS1205: Cannot re-export a type when the '--isolatedModules' flag is provided.
我现在如何导出类?
这个问题出现在CRA2.1。被迫将 isolatedModules=true。 我正在 CRA2.1 上制作组件库
最佳答案
加拿大税务局 v3.4.1促进类型再导出 --isolatedModules
.包含@babel/preset-typescript
在版本 v7.9.0
+(参见相应的 Babel 版本和 announcement )和 TypeScript 支持 TS 3.8 type-only imports and exports .你现在可以写:
export type { MyListType } from "./list/BoundList"
// or
import type { MyListType } from "./list/BoundList"
export type { MyListType }
// note additional "type" keyword
看看this answer有关 import
/export
语法的更多信息。
关于reactjs - 如何创建启用了 isolatedModules=true 选项的包?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53444390/