Reexport class in Typescript
I have two classes in two files.
//a.ts
export class A{}
//b.ts
export class B{}
How I can build file c.ts
from which I could import both classes?
import {A, B} from "c";
instead of
import {A} from "a";
import {B} from "b";
I want to make kind of export facade. How to reexport type?
I found answer by myself
https://www.typescriptlang.org/docs/handbook/modules.html @Re-exports
Code to do what I wanted
//c.ts
export {A} from "a";
export {B} from "b";
Default export
Assuming you have file
//d.ts
export default class D{}
Re-export have to look like this
//reexport.ts
export { default } from "d";
or
//reexport.ts
export { default as D } from "d";
What happens here is that you're saying "I want to re-export the default export
of module "D" but with the name of D
For anyone not wanting to deal with default you re-export an imported module like so
import {A} from './A.js';
import {B} from './B.js';
const C = 'some variable'
export {A, B, C}
This way you can export all the variables you either imported or declared in this file.
Taken from here