I have an Angular application in TypeScript that is built with webpack. I also have an npm package (hosted in Sinopia, not on npm) structured as follows:
my-custom-npm-package
- index.ts
- studentStorage.ts
- student.d.ts
student.d.ts
interface IStudent
{
name: string;
id: number;
}
index.ts
import { StudentStorage } from './studentStorage';
export { StudentStorage }
studentStorage.ts
export class StudentStorage{
private students: IStudent[] = [];
public get(): IStudent[]{
return this.students.slice(0);
}
}
Within my Angular component, I include the following line of code:
import { StudentStorage } from 'my-custom-npm-package';
However, when using webpack, I encounter the following error:
ERROR in D:\Sandbox\MultiLanguage\node_modules\my-custom-npm-package\studentStorage.ts
(2,23): error TS2304: Cannot find name 'IStudent'.
To address this issue, I created a workaround by creating a typings.d.ts file with the following content:
/// <reference path="node_modules/my-custom-npm-package/student.d.ts" />
Despite this fix, I aim to utilize my custom npm package without relying on referencing .d.ts files during installation.
How can I accomplish this goal?