{"record":{"id":"3ea930d7b2054b4b","repo":"oxc-project/oxc","slug":"unexpected-super-because-super-is-not-a-cons","errorCode":null,"errorMessage":"Unexpected `super()` because `super` is not a constructor.","messagePattern":"Unexpected `super\\(\\)` because `super` is not a constructor\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/eslint/constructor_super.rs","lineNumber":53,"sourceCode":"        .with_labels([\n            span.primary_label(\"This path may call `super()` after it was already called.\"),\n            first_super_span.label(\"`super()` was first called here.\"),\n        ])\n}\n\n#[derive(Clone, Copy)]\nstruct SuperClassContext {\n    span: Span,\n    label: &'static str,\n}\n\nfn bad_super(span: Span, super_class_context: Option<SuperClassContext>) -> OxcDiagnostic {\n    let mut labels = vec![span.primary_label(\"This `super()` call is invalid here.\")];\n    if let Some(context) = super_class_context {\n        labels.push(context.span.label(context.label));\n    }\n\n    OxcDiagnostic::warn(\"Unexpected `super()` because `super` is not a constructor.\")\n        .with_help(\n            \"Remove the `super()` call or change the `extends` clause to a constructable superclass.\",\n        )\n        .with_note(\n            \"`super()` calls the constructor of the superclass, but this class does not extend a constructable value.\",\n        )\n        .with_labels(labels)\n}\n\n#[derive(Debug, Default, Clone)]\npub struct ConstructorSuper;\n\ndeclare_oxc_lint!(\n    /// ### What it does\n    ///\n    /// Requires `super()` calls in constructors of derived classes and disallows `super()` calls\n    /// in constructors of non-derived classes.\n    ///","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/eslint/constructor_super.rs#L35-L71","documentation":"The bad_super variant of constructor-super (crates/oxc_linter/src/rules/eslint/constructor_super.rs:54). It fires when super() is called but the `extends` target is not a constructable value — e.g. `extends null`, a variable holding a non-function, or an arrow function. Such a call throws 'Super constructor is not a constructor' (a TypeError) at runtime. The diagnostic attaches a secondary label built from SuperClassContext, which holds the superclass span and a static label string.","triggerScenarios":"`class A extends null { constructor() { super(); } }`; `class B extends getBase() { constructor() { super(); } }` where getBase() may return null or an arrow function; extending a mistyped import that resolves to a non-constructor value.","commonSituations":"Dependency-injected base classes that can be null; 'abstract base' patterns written as extends null; broken or circular imports where the base binding is undefined.","solutions":["Point `extends` at a real class or constructable function.","For extends-null designs, drop the super() call and initialize `this` explicitly (Object.create / Reflect.construct), or drop extends null entirely.","Fix the import or value that resolves to a non-constructor."],"exampleFix":"// before\nclass A extends null {\n  constructor() { super(); } // TypeError at runtime\n}\n\n// after\nclass A {\n  constructor() { this.x = 1; }\n}","handlingStrategy":"validation","validationCode":"// .oxlintrc.json\n{\n  \"rules\": {\n    \"constructor-super\": \"error\"\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Verify the extends target is a class or constructable function before calling super().","Avoid `extends null` unless you handle `this` initialization manually.","Check that base-class imports resolve — circular or broken imports make the binding non-constructable."],"tags":["eslint","oxlint","class","super","extends","typeerror"],"backgroundTag":"super-not-a-constructor","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"}