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?
TypeScript supports export = to model the traditional CommonJS and AMD workflow. The export = syntax specifies a single object that is exported from the module. This can be a class, interface, namespace, function, or enum.
Use a named export to export an interface in TypeScript, e.g. export interface Person{} . The exported interface can be imported by using a named import as import {Person} from './another-file' . You can have as many named exports as necessary in a single file.
The TypeScript declares module is one of the modules and keyword it is used for to surround and define the classes, interfaces; variables are also declared it will not originate with the TypeScript like that module is the set of files that contains values, classes, functions/methods, keywords, enum all these contains ...
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
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