Skip to content

typescript/no-wrapper-object-types Correctness

This rule is turned on by default.
🛠️ An auto-fix is available for this rule.

What it does

Disallow the use of wrapper object types.

Why is this bad?

Wrapper object types are types that are defined in the global scope and are not primitive types. These types are not recommended to be used in TypeScript code.

Examples

Examples of incorrect code for this rule:

ts
let myBigInt: BigInt;
let myBoolean: Boolean;
let myNumber: Number;
let myString: String;
let mySymbol: Symbol;

let myObject: Object = "allowed by TypeScript";

Examples of correct code for this rule:

ts
let myBigint: bigint;
let myBoolean: boolean;
let myNumber: number;
let myString: string;
let mySymbol: symbol;

let myObject: object = "Type 'string' is not assignable to type 'object'.";

References

Released under the MIT License.