私はTSモジュール内でエクスポートする必要があるモデルとサービスをたくさん持っています。 最終的なTypsecriptエクスポートをモジュールでラップしますか?
モデル/ User.ts
import {IModel} from "./IModel";
export interface User extends IModel {
// ...
}
サービス/ UserService.ts
import {inject} from 'aurelia-framework';
import {HttpClient} from 'aurelia-fetch-client';
import {BaseService} from "./BaseService";
import {User as ModelType} from "../models/User";
@inject(HttpClient)
export class UserService extends BaseService<ModelType> {
// ...
}
ディスト
ソースはここで、私は最終的に何をしたいのですビルド後プロジェクトを掘り起こす。必ずしもそのままではありませんが、一般的に私のルートモジュールmy-module
にはmodels
のサブモジュールとservices
のサブモジュールが含まれている必要があります。あるいは、モデル/サービスが同じ「コンテナ」の下にバンドルされていないように、 (例えば、モデル/サービス間の名前の競合を避けるため)。
DIST/index.d.ts
declare module "my-module/models" {
export interface User { ... }
// ... other models here ...
}
declare module "my-module/services" {
export class UserService { ... }
// ... other models here ...
}
私はnpm
を経由して、このパッケージをインストールして、このような別のプロジェクトでそれを使用できるように:
import {User} from "my-module/models";
import {UserService} from "my-module/services";
- ありますモデル/サービスがたくさんあるので、私は手作業で維持/構築して、
index.ts
をビルドする必要はありません。 - Typescriptプロジェクトをどのように構造化すればよいですか?