Ramon Balthazar
Ramon Balthazar

Reputation: 4260

How to re-export all types from module?

I want to re-export all types in a module. Is there a way to achieve this?

I did try:

export type * from 'react-router-dom';

But it doesn't work:

Only named exports may use 'export type'. ts(1383)

Upvotes: 12

Views: 6317

Answers (2)

Justin Dalrymple
Justin Dalrymple

Reputation: 868

Typescript 5.0 now has support for this:

export type * from "external-module"

//OR

export type * as ns from "external-module".

Update typescript and you’ll be able to!

Upvotes: 13

Ahmed Hall
Ahmed Hall

Reputation: 49

First, you need to import the type as Types then export it like this way.

// your-module
import type * as Types from "external-module";
export { Types };

// Usage by the end user
import { Types } from "your-module";
let a:Types.Class;

hope it's helpful.

Upvotes: 4

Related Questions