我的功能如下所示:
function calc(a, b){
return a + b
}
我可以得到它的名字
calc.name
并获得名称 'calc' 。
我也有创建功能
interface ICreateResult {
[???]: string;
'key': string;
}
function create(func): ICreateResult{
return {
[func.name]: 'some value',
'key': 'some value'
}
}
我怎样才能使typescript验证
const obj = create(calc);
obj.calc // intellisense by typescript
obj.abc() // error