{"record":{"id":"6be28bbae96beb63","repo":"oxc-project/oxc","slug":"unsafe-declaration-merging-between-classes-and-int","errorCode":null,"errorMessage":"Unsafe declaration merging between classes and interfaces.","messagePattern":"Unsafe declaration merging between classes and interfaces\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/typescript/no_unsafe_declaration_merging.rs","lineNumber":14,"sourceCode":"use oxc_ast::{AstKind, ast::BindingIdentifier};\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_semantic::SymbolId;\nuse oxc_span::Span;\n\nuse crate::{\n    AstNode,\n    context::{ContextHost, LintContext},\n    rule::Rule,\n};\n\nfn no_unsafe_declaration_merging_diagnostic(span: Span, span1: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Unsafe declaration merging between classes and interfaces.\")\n        .with_help(\"The TypeScript compiler doesn't check whether properties are initialized, which can lead to TypeScript not detecting code that will cause runtime errors.\")\n        .with_labels(if span < span1 { [span, span1]} else { [span1, span] })\n}\n\n#[derive(Debug, Default, Clone)]\npub struct NoUnsafeDeclarationMerging;\n\ndeclare_oxc_lint!(\n    /// ### What it does\n    ///\n    /// Disallow unsafe declaration merging.\n    ///\n    /// ### Why is this bad?\n    ///\n    /// Declaration merging between classes and interfaces is unsafe.\n    /// The TypeScript compiler doesn't check whether properties are initialized, which can lead to TypeScript not detecting code that will cause runtime errors.\n    ///\n    /// ### Examples","sourceCodeStart":1,"sourceCodeEnd":32,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/typescript/no_unsafe_declaration_merging.rs#L1-L32","documentation":"Lint diagnostic from typescript/no-unsafe-declaration-merging: a class and an interface share the same name in the same scope. Declaration merging makes the class claim the interface's (uninitialized) properties, and since tsc does not check property initialization for merged interfaces, this can hide runtime errors.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/typescript/no_unsafe_declaration_merging.rs:14 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Rename the interface (e.g. Foo -> FooInterface) or the class so they no longer merge","Fold the interface members into the class declaration","Delete the interface if it is redundant"],"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"}