S
S
Svyatoslav Khusamov2018-11-23 12:16:39
typescript
Svyatoslav Khusamov, 2018-11-23 12:16:39

How to correctly create a package with the isolatedModules=true option enabled?

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 like this are generated:
TS1205: Cannot re-export a type when the '--isolatedModules' flag is provided.

How can I export classes now?
P.S.
This issue was introduced in CRA2.1. There forced to isolatedModules=true.
I am making a component library on CRA2.1

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Edunov, 2020-06-26
@Opty

the easiest way to get rid of the error is to name both the interface and the component with the same name

// BoundList.tsx
export interface BoundList {}
export const BoundList = () => null;

// index.tsx
export { BoundList } from './BoundList';

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question