no-wrapper-object-types
不允许使用令人困惑的内置原始类封装器.
在 ESLint 配置 中扩展"plugin:@typescript-eslint/recommended"
可启用此规则。
此规则报告的一些问题可通过 --fix
ESLint 命令行选项自动修复。
TypeScript 定义了几对令人困惑的类型,它们看起来非常相似,但实际上意味着不同的东西:boolean
/Boolean
, number
/Number
, string
/String
, bigint
/BigInt
, symbol
/Symbol
, object
/Object
.一般来说,只有小写变体才适合使用。因此,此规则强制你仅使用小写变体。
¥TypeScript defines several confusing pairs of types that look very similar to each other, but actually mean different things: boolean
/Boolean
, number
/Number
, string
/String
, bigint
/BigInt
, symbol
/Symbol
, object
/Object
.
In general, only the lowercase variant is appropriate to use.
Therefore, this rule enforces that you only use the lowercase variant.
JavaScript 在运行时具有 8 种数据类型,这些在 TypeScript 中由小写类型 undefined
、null
、boolean
、number
、string
、bigint
、symbol
和 object
描述。
¥JavaScript has 8 data types at runtime, and these are described in TypeScript by the lowercase types undefined
, null
, boolean
, number
, string
, bigint
, symbol
, and object
.
至于大写类型,这些是描述每种数据类型的 JavaScript "wrapper" 对象的结构类型,例如 Boolean
和 Number
。此外,由于结构类型的怪癖,相应的原语也可以分配给这些大写类型,因为它们具有相同的 "shape"。