How would you write a typescript definition file for a JS prototype


#1

I’m writing a TypesScript definition file for a THREE JS utility and I’m not sure how to write the definition for a prototype function.

This is the javascript

THREE.ColladaLoader = function () {
   
   var colladaUnit = 1.0;
   
   function Skin() {
      this.source = "";
      this.bindShapeMatrix = null;
   }
   
   Skin.prototype.parse = function( element ) {
      ...STUFF...
      return this;
   }
}

These are my TS definitions so far

export class ColladaLoader {
   colladaUnit: number;

   Skin(): void;
   Skin.parse( element: any ): ????????
}

The prototype returns this.

This is my first attempt at writing a TS definitions file btw