0
给定下面的接口。我如何实际执行它?我很难为函数调用提供正确的语法。实现带有状态接口的Typescript函数
export interface IFoo<T> {
(newValue?: T): T;
state: any;
}
给定下面的接口。我如何实际执行它?我很难为函数调用提供正确的语法。实现带有状态接口的Typescript函数
export interface IFoo<T> {
(newValue?: T): T;
state: any;
}
例如:
var tmp: any = function(newValue = 'Hello!') {
return newValue;
}
tmp.state = 123;
var foo: IFoo<string> = tmp;
console.log(foo.state);
console.log(foo());