Is there any way to inherit a class from JS native function?
For example, I have a JS function like this:
function Xarray()
{
Array.apply(this, arguments);
//some stuff for insert, add and remove notification
}
Xarray.prototype = new Array();
I tried to convert it to Typescript but i failed!!
export class Xarray implements Array {
}
The compiler asks me to define all Array interface properties. I know if I need this Xarray.prototype = new Array();, I have to extend Array in TS.
How to extend the JS native object in TS?
I don’t think there is a way to inherit existing interfaces like Array,
You should create a function and inherit it with its prototype. Typescript also will accept it which is similar to javascript.
UPDATE: This one is discussed well and provided the best solution for this at jqfaq.com.
Hope, this might help you!!!