{"record":{"id":"d1af2e7908e16002","repo":"oxc-project/oxc","slug":"do-not-use-type-name-as-a-type","errorCode":null,"errorMessage":"Do not use `{type_name}` as a type","messagePattern":"Do not use `(.+?)` as a type","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/typescript/no_restricted_types.rs","lineNumber":28,"sourceCode":"};\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::{GetSpan, Span};\n\nuse crate::{\n    AstNode,\n    context::{ContextHost, LintContext},\n    rule::{DefaultRuleConfig, Rule},\n};\n\nfn no_restricted_types_diagnostic(\n    type_name: &str,\n    message: Option<&str>,\n    span: Span,\n) -> OxcDiagnostic {\n    let msg = message.unwrap_or_default();\n    if msg.is_empty() {\n        OxcDiagnostic::warn(format!(\"Do not use `{type_name}` as a type\"))\n            .with_help(\"This type is restricted from being used.\")\n            .with_label(span)\n    } else {\n        OxcDiagnostic::warn(format!(\"Do not use `{type_name}` as a type\"))\n            .with_help(msg.to_string())\n            .with_label(span)\n    }\n}\n\n/// Built from config once: O(1) lookups by normalized name + keyword fast flags.\n#[derive(Debug, Clone, Default)]\nstruct RestrictedTypesIndex {\n    /// Key = type name with all whitespace removed (matches TS-ESLint `removeSpaces`).\n    /// Value = (display name for diagnostics, ban config).\n    by_name: FxHashMap<Box<str>, (Box<str>, BanConfigValue)>,\n    /// True if any banned name needs a full source span (e.g. `Banned<any>`, not `[]`/`{}`).\n    has_generic_or_complex_keys: bool,\n    /// True if any banned name can match a qualified type name (e.g. `NS.Banned`).","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/typescript/no_restricted_types.rs#L10-L46","documentation":"Raised by typescript/no-restricted-types when a type annotation uses a type name listed in the rule's restricted list (default: String, Number, Boolean, Symbol, Object), with no custom message configured.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/typescript/no_restricted_types.rs:28 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use the primitive lowercase form: string, number, boolean, symbol.","Use a specific object/interface type instead of Object.","Remove the type from the rule configuration if it should be allowed."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e1e7af627c8843ab64044ed466b128fcc21a035b","analyzedAt":"2026-08-20T07:01:07.079Z","contentChangedAt":"2026-08-20T07:01:07.079Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}