TS 3.8+
You can use type-only imports and exports with --isolatedModules
:
// types.ts
export type MyType = { a: string; b: number; };
// main.ts
// named import/export
import type { MyType } from './types'
export type { MyType }
// re-export
export type { MyType } from './types'
// namespace import
import type * as MyTypes from "./types";
export type RenamedType = MyTypes.MyType;
export { MyTypes };
// ^ Note the "type" keyword in statements above
Example Playground; Take a look at the PR for possible extension forms and proposals.
TS 3.7 or older
In previous versions, the following is not possible:
import { MyType } from './types';
export { MyType }; // error: Cannot re-export a type with --isolatedModules
export { MyType } from "./types"; // error, like above
Type re-exports have to use a workaround:
import { MyType as MyType_ } from "./types";
export type MyType = MyType_;
// or
export * from "./types"