oxc-project/oxc · error · OxcDiagnostic
Do not use wrapper object types.
Error message
Do not use wrapper object types.
What it means
Raised by typescript/no-wrapper-object-types when a boxed wrapper type (Number, String, Boolean, Object, Symbol, BigInt) is used where a primitive type is expected. Boxed types have object semantics that cause surprising truthiness and identity behavior.
Source
Thrown at crates/oxc_linter/src/rules/typescript/no_wrapper_object_types.rs:10
use cow_utils::CowUtils;
use oxc_ast::{AstKind, ast::TSTypeName};
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_span::Span;
use crate::{AstNode, context::LintContext, rule::Rule};
fn no_wrapper_object_types(ident_name: &str, span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Do not use wrapper object types.")
.with_note(format!(
"`{ident_name}` is a boxed object type, not a primitive. Boxed types have object semantics (identity/truthiness) that can be surprising. Use `{}` for values, and in `extends`/`implements` use an interface/object shape instead.",
ident_name.cow_to_ascii_lowercase()
))
.with_label(span)
}
#[derive(Debug, Default, Clone)]
pub struct NoWrapperObjectTypes;
declare_oxc_lint!(
/// ### 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.View on GitHub (pinned to e1e7af627c)
Solutions
- Use the lowercase primitive type (number, string, boolean).
- In extends/implements positions, use an interface or object type as suggested in the note.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/oxc_linter/src/rules/typescript/no_wrapper_object_types.rs:10 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20).
Data as JSON: /api/errors/cce87083f21d33d3.
Report an issue: GitHub.