I have an angular2 package library (name it A) that I am importing from another angular2 project (name it B) using the npm installation.
All services, components from A, seem to be working on project B, they are well imported and introduced and used.
But only simple class definitions do not work. ie I have a class defined as follows:
export class JustAClass{ public Title:string; constructor(title:string){ this.Title = title; } getTitleLong():string{ return 'Long '+this.Title; } }
and export to index.d.ts.
export {JustAClass} from './components/test/just';
In project B, I can see the just.d.ts file as follows:
export declare class JustAClass { Title: string; constructor(title: string); getTitleLong(): any; }
I work with webswtorm, when I use this class inside the project B file, it gives me intelligence and knows to point me to the file definition:
import { JustAClass } from 'my-project-lib-A'; @Component({ templateUrl: 'orders.html' }) export class SomePage { constructor() { var d = new JustAClass('aaaa');
I get it "JustAClass" undefined, and webpack throws an error:
WEBPACK_IMPORTED_MODULE_2_my-project-lib-A .JustAClass is not a constructor
I use ionic2 as project B, if that matters.
source share