I am working on an application written in JavaScript and considering incorporating TypeScript for a new feature. Currently, I have a base class defined in JavaScript as shown below:
// base.js
module.exports = function BaseClass () {
// ... ...
};
My goal is to create a class in TypeScript that extends this base class like so:
// sub.ts
import Base from "./base.js";
class Sub extends Base {
// ... ...
}
However, upon implementing this, I encountered an error in sub.ts
stating:
Type "Base" is not a constructor function type.
I am curious as to why this error is occurring. Could it be due to the absence of a .d.ts
file for my base.js
? If that's the case, how can I generate the necessary declaration file for base.js
and where should I place it?