I'm trying to import a JavaScript class into TypeScript, but I keep getting the error message
This expression is not constructable.
. The TypeScript compiler also indicates that A does not have a constructor signature. Can anyone help me figure out how to solve this issue?
index.ts
import A from "aaa";
const a = new A(); //error: this expression is not constructable.
/*
and result of console.log(A); is [Function: A].
result of console.log(A.toString()); is below
class A {
constructor(name) { this.name = name; }
}
*/
index.js in the aaa module.
class A {
constructor(name) { this.name = name; }
}
module.exports = A;
index.d.ts in the aaa module.
export declare class A {
constructor(name:string);
name:string;
}
Currently, I'm able to construct A in JavaScript using the following code snippet, however, it doesn't work in TypeScript.
const A = require("aaa");
const a = new A();