I have a JavaScript class written in ES6:
// MyClass.js
export default class MyClass {
myfunction() {
console.log('myfunction called');
}
}
I'd like to extend this class with a TypeScript class:
// MyTSClass.ts
import MyClass from './MyClass';
class MyTSClass extends MyClass {
public initialize() {
this.myfunction();
}
}
This produces a TypeScript compiler error:
TS2339: Property 'myfunction' does not exist on type 'MyTSClass'
I have esModuleInterop set to true in my tsconfig.
I attempted to make a declaration file, thinking this might help:
// MyClass.d.ts
export = MyClass;
declare class MyClass {
myfunction: void;
}
This makes the compiler happy, but in the generated code in the browser I see something unexpected, and the console log does not print:
class MyTSClass extends WEBPACK_IMPORTED_MODULE_1__["MyClass"]...
What am I doing wrong?
console.login the original function that is not printed. I haven't included webpack config, tsconfig, etc. since I'm not sure which parts are relevant. I was hoping I was doing something wrong that was easily identifiable to one with experience, but can take the time to spin up a more complete example soon.