I'm using a javascript library (pixi.js to be specific) and I'm trying to extend one of their classes in typescript. However, trying to extend the class like below will yield an error.
module tilesystem {
declare var PIXI;
// Class
export class Tilegrid PIXI.DisplayObjectContainer
{
public layers : number= layers;
public rows : number= rows;
public columns : number = columns;
public tilesize : number = tilesize;
// Constructor
constructor(layers, columns, rows, tilesize, stage, texture)
{
super( );
//implementation
}
}
//Tilegrid.constructor = Tilegrid;
Tilegrid.prototype = Object.create(PIXI.DisplayObjectContainer.prototype);
}
error :
Base type 'any' lacks an implementation.
I would be fine with just extending it the ugly javascript way, but that then it will still complain about not know it's super methods.
module tilesystem {
declare var PIXI;
// Class
export class Tilegrid
{
public layers : number= layers;
public rows : number= rows;
public columns : number = columns;
public tilesize : number = tilesize;
// Constructor
constructor(layers, columns, rows, tilesize, stage, texture)
{
**PIXI.DisplayObjectContainer.call(this);**
*this.addChild( new Tile() );* //throws an error, because addChild is not known
}
}
**Tilegrid.prototype = Object.create(PIXI.DisplayObjectContainer.prototype);**
}
How to extend native JavaScript array in TypeScript I know that this anwser suggest using an interface, but I would really like to prevent writing wrappers. I would much rather find a way to either supress the error when using super methods, or somehow get the type info from the javascript class.