javascript - Print method parameter names where last parameter is a spread parameter in ES5 -
how print console signature of method last parameter rest parameter in typescript (es5) ?
for example following method:
public execute(params1: number, params2: number, ...allotherparams:number[]){ // dosomething... }
should print out:
execute(params1, params2, ...allotherparams)
i stuck @ rest parameter following solution not show rest parameter:
let funcsignature = this.execute.tostring(); console.log(funcsignature);
i getting this:
function (params1, params2) { var allotherparams = []; (var _i = 2; _i < arguments.length; _i++) { allotherparams[_i - 2] = arguments[_i]; } // dosomething... }
function execute(params1, params2, ...allotherparams) { //dosomething } // third parameter not shown in console.log ? console.log(execute.tostring());
this possible if typescript compiled es6 (and higher) javascript standard.
for instance following typescript code:
function execute(params1: number, params2: number, ...allotherparams:number[]){ // dosomething... }
when target set es5 code compiled into:
function execute(params1, params2) { var allotherparams = []; (var _i = 2; _i < arguments.length; _i++) { allotherparams[_i - 2] = arguments[_i]; } // dosomething... }
and when target set es6 code compiled into:
function execute(params1, params2, ...allotherparams) { // dosomething... }
Comments
Post a Comment