例如,我有一個類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();
該怎麼做?