【发布时间】:2020-04-27 03:54:57
【问题描述】:
我已经定义了这个类型
export interface Hostel {
id: String;
}
我想检查一个对象是否属于该类型,但没有办法。我试过了
console.log ('************ ', (typeof result === 'Hostel'));
console.log ('************ ', (typeof result === Hostel));
console.log ('************ ', result instanceof Hostel);
我有这个错误:
'Hostel' only refers to a type, but is being used as a value here.
【问题讨论】:
-
你得到的输出是什么
-
这能回答你的问题吗? Interface type check with Typescript
标签: javascript node.js typescript