【发布时间】:2021-09-18 01:16:47
【问题描述】:
我想知道是否可以在打字稿中确定对象的类型。请考虑以下示例:
type T = [number, boolean];
class B {
foo: T = [3, true];
bar(): boolean {
return this.foo instanceof T;
}
}
typeof 运算符似乎不是一个解决方案,instanceof 也不是。
【问题讨论】:
标签: typescript