Here is an example showcasing the test.js file:
function test() { console.log('Test is working!'); };
Next to it, we have the test.d.ts file:
declare module 'test' {
export function test(): void;
};
However, when attempting to utilize this module in app.component.ts like so:
import {Component, OnInit} from '@angular/core';
import * as Test from 'test';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit{
title = 'app';
a = Test;
ngOnInit() {
this.a.test();
}
}
This results in an error message stating Module not found: Error: Can't resolve 'test'. Here is the StackBlitz project link for reference: Link of above project