{"record":{"id":"af9a6df79212b9b7","repo":"oxc-project/oxc","slug":"use-a-method-signature-instead-of-a-property-signa","errorCode":null,"errorMessage":"Use a method signature instead of a property signature.","messagePattern":"Use a method signature instead of a property signature\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"warning","filePath":"crates/oxc_linter/src/rules/typescript/method_signature_style.rs","lineNumber":34,"sourceCode":"};\n\nfn method_signature_style_diagnostic(\n    config: MethodSignatureStyleConfig,\n    span: Span,\n) -> OxcDiagnostic {\n    match config {\n        MethodSignatureStyleConfig::Property => method_signature_style_property_diagnostic(span),\n        MethodSignatureStyleConfig::Method => method_signature_style_method_diagnostic(span),\n    }\n}\n\nfn method_signature_style_property_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Use a property signature instead of a method signature.\")\n        .with_help(\"Replace the method signature with a property whose type is a function type.\")\n        .with_label(span)\n}\nfn method_signature_style_method_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Use a method signature instead of a property signature.\")\n        .with_help(\"Replace the property signature with method shorthand syntax.\")\n        .with_label(span)\n}\n\n#[derive(Debug, Default, Clone, Copy, Eq, PartialEq, JsonSchema, Deserialize, Serialize)]\n#[serde(rename_all = \"kebab-case\")]\nenum MethodSignatureStyleConfig {\n    #[default]\n    /// Enforce using property signature for functions. Use this to enforce maximum correctness together with TypeScript's strict mode.\n    Property,\n    /// Enforce using method signature for functions. Use this if you aren't using TypeScript's strict mode and prefer this style.\n    Method,\n}\n\n#[derive(Debug, Default, Clone, Deserialize, Serialize)]\npub struct MethodSignatureStyle(MethodSignatureStyleConfig);\n\nimpl MethodSignatureStyle {","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/typescript/method_signature_style.rs#L16-L52","documentation":"typescript/method-signature-style with the \"method\" option reports property signatures whose type is a function type: `foo: () => void`. The configured convention prefers method shorthand `foo(): void`, typically in codebases not relying on strictFunctionTypes variance behavior. This is the inverse direction of the rule's default.","triggerScenarios":"`interface I { foo: () => void; }` (a TSPropertySignature annotated with a function type) while the rule option is set to \"method\". The diagnostic fires on each such member.","commonSituations":"Teams standardizing on shorthand for readability after deciding variance nuances are irrelevant to them; flipping the option in a shared config and re-linting the whole repo; style alignment with existing hand-written interfaces.","solutions":["Rewrite `interface I { foo: () => void; }` as `interface I { foo(): void; }`","If only some members should stay as properties (e.g. unions of function types), those cannot be shorthand, so keep them and consider reverting the option","Reconsider the option: the default \"property\" style is required for strict-mode variance checking"],"exampleFix":"// before\ninterface Store {\n  load: (key: string) => Promise<Data>;\n}\n\n// after\ninterface Store {\n  load(key: string): Promise<Data>;\n}","handlingStrategy":"validation","validationCode":"// .oxlintrc.json — opt into shorthand style deliberately\n{\n  \"rules\": {\n    \"typescript/method-signature-style\": [\"warn\", \"method\"]\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pick one style repo-wide and encode it in the rule config so both humans and --fix agree","Keep function-typed properties where unions or overloads make shorthand impossible","Revisit the choice if the codebase later enables strictFunctionTypes-dependent variance checks"],"tags":["typescript","lint","interface","style","oxlint"],"backgroundTag":"method-signature-style","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"}