我只想在typescript接口中声明一个静态属性?关于这个,我没有找到任何地方.
interface myInterface {
static Name:string;
}
Run Code Online (Sandbox Code Playgroud)
可能吗?
如何将方法添加到基类型,比如Array?在全球模块中,这将得到认可
interface Array {
remove(o): Array;
}
Run Code Online (Sandbox Code Playgroud)
但在哪里放实际实施?
我扩展了函数原型但是typescript无法识别它.
Function.prototype.proc = function() {
var args, target, v;
var __slice = [].slice;
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
target = this;
while (v = args.shift()) {
target = target(v);
}
return target;
};
// generated by coffee-script
var foo: (number) => (string) => number
= (a) => (b) => a * b.length;
console.log(foo.proc("first", "second"))
Run Code Online (Sandbox Code Playgroud)
结果:tsc -e
The property 'proc' does not exist on value of type 'Function'
Run Code Online (Sandbox Code Playgroud)
我该如何扩展这个对象?