node.js - How to write a typescript corresponding to following javascript ? -


var _ =require('lodash'); var controller=function(){};  controller.prototype.index=function(req,res){    res.ok();  };  controller.extend=function(object){       return _.extend({},controller.prototype,object);  }; 

i have tried following typescript adds extend controller.prototype.extend instead of controller.extend()

var _ = require('lodash'); class controller {     index(){         console.log("hi");     }     extends(object) {      return _.extend({}, controller.prototype, object);     } } 

how can change typescript obtain above javascript?

you defining instance method, part of object's prototype, should using static method (part of class).

all need change declaration of extends(object) to:

static extends(object) {   ... } 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -