Within my current project, I have defined the following interfaces:
interface foo {
fooProperty: number;
fooFunction(): void;
}
interface bar extends foo {
barProperty: string;
barFunction(): void;
}
Now, I am interested in creating a class like this:
class myBar implements bar {
public barProperty: string = "bar";
public barFunction() {
// perform some action
}
}
However, I want to avoid implementing the properties and functions of foo as they are already specified in an existing JS class that is described by the interfaces.
Essentially, I aim to develop a TypeScript class that extends a third-party JS library for which I have ".d.ts" files outlining the implementation details but is not originally written in TypeScript.
In order to utilize a specific function within the third-party library, I need to create a customized class that inherits from a provided JS class using "prototype", but I must accomplish this task using TypeScript.
Update 1
It appears that there may be some confusion regarding my objective, so let me provide further clarification.
Within our project, we make use of a third-party JS library, referred to as "thirdLib.js".
Inside "thirdLib.js", there is functionality that necessitates extending a JS-style class included in "thirdLib.js" in the following manner:
function myClass(){
thirdlib.thirdclass.call(this);
}
thirdLib.utilities.extendclass(myClass, thirdLib.thirdClass);
myClass.prototype.overriddenFunc = function(){
// Implement custom function here
}
The "extendClass" method in "thirdlib" copies the constructor of the base class into my constructor, or at least that is my understanding.
Later on, within "thirdlib.js", this extended class is employed somewhere else like so:
var myStuff = new thirdLib();
var theClass = new myClass();
myStuff.registerSomething(theClass);
myStuff.doAThing();
Upon calling "doAThing", the newly registered JS class in "thirdLib.js" possesses all the original functionalities from "thirdClass" along with my customizations.
I only have access to the minified JavaScript code of "thirdLib.js" and a set of self-authored TypeScript definition files. My goal is to construct "myClass()" using standard TypeScript features while inheriting and utilizing the entirety of the original JS class and integrating my additional functionalities into the TS class to override those in the underlying JS class when needed.
Update April 2022
To address any inquiries, approximately six months after my previous comment, I departed from the company associated with this project. Consequently, I do not possess the code or accessibility to it anymore, thus I doubt the matter will reach a resolution. For those intrigued, the "Custom Drawing Handler" I attempted to implement was a personalized drawing class for a previously commercial (now open-source) third-party JS library known as "MXGraph".