I am currently in the process of transforming .NET entities into an npm module. However, I am encountering difficulties when trying to utilize it within my Angular2 component.
Here is the overall structure of the module: enter image description here
In order to satisfy the referenced types, we have decided to create a module and import from index.d.ts (within 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,
}
}
I attempted to import by using:
import { Address, ... } from 'npm_module_name/index';
And then created an object like this:
let testAddress : Address = new Address();
Error:(31, 16) TS2304:Cannot find name 'Address'.
I also tried importing in this manner:
import { cio } from 'npm_module_name/index/';
And created an object like this:
let testAddress : cio.Address = new cio.Address();
Error:(31, 20) TS2694:Namespace ''*'' has no exported member 'Address'.
I experimented with replacing "module" with "namespace," but that did not resolve the issue.
What would be the best approach for importing into my component? Thank you.