例如,我有一个类A.ts
如何导入所有类在一个文件中,并利用它们从那里打字稿
export class A(){
public constructor() {}
public method() : string {
return "hello from A";
}
}
和类B.ts
export class B(){
public constructor() {}
public method() : string {
return "hello from B";
}
public static methodStatic() : string {
return "hello from static B";
}
}
那么我想将它们全部导入到一个文件中Headers.ts
imports {A} from "../A_path";
imports * as b from "../B_path";
//Or just to export it? Make it public.
export * from "../A_path";
export * from "../B_path";
Headers.ts将只包含imports/exports
,没有类实现或任何其他代码。 然后我的问题:我想在app.ts称他们在Headers.ts
文件中使用A
和B
类。
import * as headers from './HEADERS_path';
headers.A.method();
headers.B.method();
该怎么做?