In a file where I export all the classes of my package on lines like the following:
export {default as BoundList, IBoundListOption, TBoundListFilterFn} from './list/BoundList';
errors of the form are generated:
TS1205: Cannot re-export a type when the '--isolatedModules' flag is provided.
How do I export classes now?
This problem occurred in CRA2.1. There was forced to isolatedModules=true. I'm making a component library on CRA2.1
CRA v3.4.1 facilitates type re-exports under --isolatedModules
. The contained @babel/preset-typescript
in version v7.9.0
+ (see corresponding Babel release and announcement) and TypeScript support TS 3.8 type-only imports and exports. You can now write:
export type { MyListType } from "./list/BoundList"
// or
import type { MyListType } from "./list/BoundList"
export type { MyListType }
// note additional "type" keyword
Take a look at this answer for more info on the import
/export
syntax.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With