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
Post a Comment