Interface固定属性
来源:2-12 复杂函数类型补充学习

慕哥7464810
2023-05-31
interface FunctionWithAttributes {
attr: string,
// ???如果我想写一个固定的函数, 怎么写
// func:()=>{ };
(str:string):void; //这是一个函数声明
}
const test: FunctionWithAttributes = (str:string) => {
console.log("attributes");
}
test.attr = "12";
如果我想通过FunctionWithAttributes 定义的object都有一个固定的func函数应该怎么写
写回答
1回答
-
Dell
2023-06-09
这个你没法定义,函数只能约定入参和出参,不能直接写死实现
00
相似问题