如何将方法添加到分配给变量c的对象常量中,以便满足类型检查?

时间:2019-05-27 15:22:09

标签: javascript typescript

如何满足下面代码片段中的类型检查?

interface Counter {
    getCount: () => number
    increment: (n: number) => void
}
let c: Counter = {}

1 个答案:

答案 0 :(得分:1)

let c: Counter = {
    getCount: () => 1,
    increment: (n: number) => {}
}