{"record":{"id":"35043aed2c73ddb6","repo":"oxc-project/oxc","slug":"do-not-use-the-empty-object-type-literal","errorCode":null,"errorMessage":"Do not use the empty object type literal.","messagePattern":"Do not use the empty object type literal\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"warning","filePath":"crates/oxc_linter/src/rules/typescript/no_empty_object_type.rs","lineNumber":27,"sourceCode":"use oxc_macros::declare_oxc_lint;\nuse oxc_semantic::NodeId;\nuse oxc_span::Span;\nuse schemars::JsonSchema;\nuse serde::{Deserialize, Serialize};\n\nuse crate::{\n    AstNode,\n    context::LintContext,\n    fixer::RuleFixer,\n    rule::{DefaultRuleConfig, Rule},\n    utils::deserialize_regex_option,\n};\n\nfn no_empty_object_type_diagnostic<S: Into<Cow<'static, str>>>(\n    span: Span,\n    message: S,\n) -> OxcDiagnostic {\n    OxcDiagnostic::warn(message)\n        .with_help(\"To avoid confusion around the {} type allowing any non-nullish value, this rule bans usage of the {} type.\")\n        .with_label(span)\n}\n\n#[derive(Debug, Default, Clone)]\npub struct NoEmptyObjectType(Box<NoEmptyObjectTypeConfig>);\n\n#[expect(clippy::struct_field_names)]\n#[derive(Debug, Default, Clone, Deserialize, JsonSchema)]\n#[serde(rename_all = \"camelCase\", default, deny_unknown_fields)]\npub struct NoEmptyObjectTypeConfig {\n    /// Whether to allow empty interfaces.\n    allow_interfaces: AllowInterfaces,\n    /// Whether to allow empty object type literals.\n    allow_object_types: AllowObjectTypes,\n    /// A stringified regular expression to allow interfaces and object type aliases with the configured name.\n    ///\n    /// This can be useful if your existing code style includes a pattern of declaring empty types with `{}` instead of `object`.","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/typescript/no_empty_object_type.rs#L9-L45","documentation":"The second message of oxlint's no-empty-object-type rule, reported for the empty object type literal {} used outside interface declarations (type aliases, annotations, generic arguments). The type {} means 'any non-nullish value': `let x: {} = 42` type-checks, which is almost never what the author intends, so the rule flags it per the shared help text at no_empty_object_type.rs:19.","triggerScenarios":"`let x: {} = f();`, `function log(v: {}) {}`, `type T = {};`, `Foo<{}>` - any object type annotation or alias with zero members that the rule's allowances do not cover.","commonSituations":"Developers coming from languages where {} reads as 'empty record'; refactors that strip members but leave the {} behind; strict lint presets enabling the restriction rule by default.","solutions":["Use `Record<string, never>` when you mean exactly the empty object","Use `object` or `Record<string, unknown>` when you mean 'some object'","Model the real members in an interface or type literal","Allow intentional uses via the rule config (allowWithName regex or interface/object allowances)","Inline disable comment for a one-off"],"exampleFix":"// before\nfunction log(value: {}) {\n  console.log(value);\n}\n\n// after\nfunction log(value: Record<string, unknown>) {\n  console.log(value);\n}","handlingStrategy":"validation","validationCode":"npx oxlint --deny-warnings .","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Forbid `{}` annotations in the house style guide and point at Record<string, never> and Record<string, unknown>","Let the editor surface the rule live via the oxc language server so `{}` is fixed while typing","Review generated .d.ts and refactored types for orphan `{}` leftovers"],"tags":["typescript","lint","type-safety","object-type"],"backgroundTag":"empty-object-type","analyzedSha":"e1e7af627c8843ab64044ed466b128fcc21a035b","analyzedAt":"2026-08-20T07:01:07.079Z","contentChangedAt":"2026-08-20T07:01:07.079Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}