Q)如何在下面的服务中使用以下接口模块?
如果我已经从c#生成了以下模型:
declare module App.Core.Model {
interface Address extends App.Core.Model.BaseEntity {
addressLine1: string;
addressLine2: string;
addressLine3: string;
area: string;
countryCode: string;
name: string;
postcode: string;
town: string;
}
}服务:
// these don't work, get "model.ts error is not a module"
import {Client} from '../interfaces/model';
import {AdminUser} from '../interfaces/model';
import {Building} from '../interfaces/model';
@Injectable()
export class AppService {
...
}这些档案的网址是:
发布于 2016-04-14 16:00:31
您可以执行以下操作(点已被下划线所取代):
declare module App_Core_Model {
export interface Address extends App.Core.Model.BaseEntity {
addressLine1: string;
addressLine2: string;
addressLine3: string;
area: string;
countryCode: string;
name: string;
postcode: string;
town: string;
}
}
declare module "app_core_model" {
export = App_Core_Model;
}然后当导入"app_core_model“模块时,接口应该是可用的,例如:
import {Address} from 'app_core_model';此外,模块名似乎不能包含点,因为它破坏了导入。
https://stackoverflow.com/questions/36619917
复制相似问题