我们从.net实体创建一个npm模块。但是我无法在我的angular2组件上使用它。如何从Typescript上的外部模块导入类
这就是结构模块: enter image description here
我想从index.d.ts导入(进入NPM),我们决定,以满足引用
declare module cio {
export class Address {
addressLine1: string;
addressLine2: string;
city: string;
state: string;
country: string;
postalCode: string;
}
的类型来创建一个模块。 。 。
declare module cio {
export class Business {
id: string;
typeName: string;
createdDate: Date;
lastModifiedDate: Date;
createdBy: string;
lastModifiedBy: string;
isTest: boolean;
isDeleted: boolean;
taxId: string;
businessType: BusinessType;
businessName: string;
address: Address;
phone: string;
mobile: string;
fax: string;
email: string;
}
enum BusinessType {
Individual = 1,
Company = 2,
}
}
我尝试使用
import { Address, ... } from 'npm_module_name/index';
导入并创建一个对象像
let testAddress : Address = new Address();
错误:(31 16)TS2304:找不到名称“地址”。
我尝试使用
import { cio } from 'npm_module_name/index/';
导入并创建一个对象像
let testAddress : cio.Address = new cio.Address();
错误:(31,20)TS2694:命名空间 '' * '' 没有出口构件 '地址' 。
我试图通过命名空间来替代模块,但没有奏效
如何导入我的组件的最佳方式?谢谢
你能更具体地说明你试过的东西和你得到的错误吗?这会帮助我们帮助你。谢谢。 – DeborahK
带有类的模块必须对包含要导入它的组件的模块可见。它是应用程序模块中的进口数组的一部分吗? –
@DeborahK我向我的帖子添加更多信息,谢谢。 – nailujpeloz