In my Angular library, which I have packaged and published to my company's internal npm repository, I have created models that are used within the library's components. An example of one of these models is shown below:
export class AdsToolbarMenuItem {
iconName: string;
label: string;
enabled: boolean = true;
menuAction: () => void;
constructor(init?: Partial<AdsToolbarMenuItem>) {
Object.assign(this, init);
}
}
To export these models, I have included them in the index.ts
file as follows:
export * from './lib/angular-components.module';
export * from './lib/models/AdsToolbarMenuItem';
export * from './lib/models/AdsToolbarMainActionItem';
export * from './lib/models/ContactBox';
The issue arises when trying to use these models in a regular project where this package has been installed. Visual Studio Code suggests two different import paths for the model, causing confusion. If the longer path is selected, the angular compiler fails despite the correctness of the path. To resolve this problem and ensure smooth usage of the package, only the correct import path should be displayed.
My query is how can I modify the index.ts
file so that only the correct import path appears in Visual Studio code for users of my package?