You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

为何TypeScript中keyof never的结果为string | number | symbol联合类型?

关于TypeScript中keyof never的类型解析

当对never类型使用keyof操作符时,它会解析为所有可能的属性键的联合类型,这和keyof any的结果完全一致。

示例代码:

type t = keyof never // 等同于 keyof any,结果为 string | number | symbol

将鼠标悬停在类型t上时,TypeScript会显示其具体类型为:

string | number | symbol

内容的提问来源于stack exchange,提问作者D1g1taL

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.01 19:59:48