class WorkFlow {
add() {
console.log('git add')
return this
}
commit() {
console.log('git commit')
return this
}
}
let workFlow = new WorkFlow()
// 方法的链式调用
console.log(workFlow.add().commit(), 'workFlow.add().commit()')
class MyFlow extends WorkFlow{
next() {
console.log('class MyFlow extends WorkFlow next')
return this
}
}
let myFlow = new MyFlow()
console.log(myFlow.next(), 'workFlow.add().commit()')
console.log(new MyFlow.next(), 'workFlow.add().commit()')
最后一行编辑器报错Property 'next' does not exist on type 'typeof MyFlow,为什么,少了什么吗