{"record":{"id":"80d4be9c79d3fd0a","repo":"oxc-project/oxc","slug":"enforce-using-function-types-instead-of-interfaces","errorCode":null,"errorMessage":"Enforce using function types instead of interfaces with call signatures.","messagePattern":"Enforce using function types instead of interfaces with call signatures\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/typescript/prefer_function_type.rs","lineNumber":18,"sourceCode":"use oxc_ast::{\n    AstKind,\n    ast::{ExportDefaultDeclarationKind, TSInterfaceDeclaration, TSSignature, TSType, TSTypeName},\n};\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::Span;\n\nuse crate::{\n    AstNode,\n    context::{ContextHost, LintContext},\n    fixer::Fix,\n    rule::Rule,\n};\n\nfn prefer_function_type_diagnostic(suggestion: &str, span: Span) -> OxcDiagnostic {\n    // FIXME: use imperative message phrasing\n    OxcDiagnostic::warn(\"Enforce using function types instead of interfaces with call signatures.\")\n        .with_help(format!(\"The function type form `{suggestion}` is generally preferred when possible for being more succinct.\"))\n        .with_label(span)\n}\n\nconst CONVERT_TO_FUNCTION_TYPE: &str = \"Convert to function type\";\n\n#[derive(Debug, Default, Clone)]\npub struct PreferFunctionType;\n\ndeclare_oxc_lint!(\n    /// ### What it does\n    ///\n    /// Enforce using function types instead of interfaces with call signatures.\n    ///\n    /// ### Why is this bad?\n    ///\n    /// TypeScript allows for two common ways to declare a type for a function:\n    /// - Function type: `() => string`","sourceCodeStart":1,"sourceCodeEnd":36,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/typescript/prefer_function_type.rs#L1-L36","documentation":"Lint diagnostic from typescript/prefer-function-type: an interface containing only a call signature was found. A type alias with a function type is the idiomatic, more concise equivalent and the rule's fixer can usually rewrite it automatically.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/typescript/prefer_function_type.rs:18 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Replace the interface with a type alias, e.g. interface Foo { (x: number): string } -> type Foo = (x: number) => string","Apply the rule's autofix"],"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-14T00:17:10.932Z"}