开发者

Why typeof number|null is 'object'?

开发者 https://www.devze.com 2022-12-07 17:16 出处:网络
Reproducible code: class MyObject{ id: number|null = null } const a = new MyObject() console.log(typeof a.id)

Reproducible code:

class MyObject{
    id: number|null = null
}

const a = new MyObject()
console.log(typeof a.id)

'object'

Is there a way to get the 'number' type from that property?

Edit:

I understand why typeof 开发者_运维技巧null is object. But my question is: is there a way (maybe reflection or something) to get that number|null complete type.

0

精彩评论

暂无评论...
验证码 换一张
取 消