Looking for a way to utilize an existing JavaScript "class" within an Angular2 component written in TypeScript? The class is currently defined as follows:
function Person(name, age) {
this.name = name;
this.age = age;
}
Despite the fact that JavaScript doesn't have traditional classes before ES6, the challenge arises when attempting to instantiate this class in TypeScript:
var john = new Person('John Doe', 22);
Upon compiling the TypeScript code to JavaScript, the error message Cannot find name 'Person'
is encountered as Person is not a recognized TypeScript class.
Are there any alternatives available to effectively utilize the existing JavaScript class within TypeScript without having to rewrite it entirely in TypeScript?