instanceof 类型保护问题
来源:4-7 编写基础请求代码 - demo 编写

Mesry
2020-12-04
The right side of the instanceof needs to be a constructor function, and TypeScript will narrow down to:
the type of the function’s prototype property if its type is not any
the union of types returned by that type’s construct signatures
请问老师,在用instanceof类型保护时,上面两句话是什么意思,官网给出的,没有看懂
写回答
1回答
-
ustbhuangyi
2020-12-04
instanceof类型保护是使用类型的构造函数缩小类型的一种方法,你可以简单地理解 instanceof 的右侧需要是一个构造函数。
032020-12-06
相似问题