可以声明通用的getter类型保护方法吗?

时间:2018-10-31 01:33:44

标签: typescript generics

接口Guard具有通用的类型保护方法isExecutable

interface Guard {
  isExecutable<
    U extends States<this> | X,
  >(): this is Query<U> & Execute<U>
}

它被这样称呼:

declare let b: Guard;
if (b.isExecutable()) {}

我想使isExecutable成为一种吸气剂,所以它被称为:

if (b.isExecutable) {}

有可能吗?

Source Code

0 个答案:

没有答案