{"record":{"id":"aad13c232679e126","repo":"oxc-project/oxc","slug":"use-a-property-signature-instead-of-a-method-signa","errorCode":null,"errorMessage":"Use a property signature instead of a method signature.","messagePattern":"Use a property signature instead of a method signature\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"warning","filePath":"crates/oxc_linter/src/rules/typescript/method_signature_style.rs","lineNumber":29,"sourceCode":"\nuse crate::{\n    AstNode,\n    context::{ContextHost, LintContext},\n    rule::{DefaultRuleConfig, Rule},\n};\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}","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/typescript/method_signature_style.rs#L11-L47","documentation":"typescript/method-signature-style with the default \"property\" style reports TSMethodSignature nodes: interface or object-type members written as method shorthand `foo(): T`. Property style `foo: () => T` is preferred because function-typed properties are checked contravariantly under strictFunctionTypes, while method shorthand is bivariant and weaker.","triggerScenarios":"`interface I { foo(): void; }` or a method signature inside a type literal while the config is Property (the default); every method signature in interfaces and type literals is reported.","commonSituations":"Enabling strict-style presets in codebases that wrote interfaces with shorthand; porting options-object types where shorthand was idiomatic; teams aligning with the typescript-eslint default of this rule.","solutions":["Rewrite `interface I { foo(): void; }` as `interface I { foo: () => void; }`","Run `oxlint --fix` to convert signatures mechanically","If your team prefers shorthand (e.g. not using strict mode), configure the rule option to \"method\""],"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 — default property style, autofix converts shorthand\n{\n  \"rules\": {\n    \"typescript/method-signature-style\": \"warn\"\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Write interface members for functions in property form from the start: `foo: () => void`","Run `oxlint --fix` when enabling the rule to convert existing shorthand","Remember the variance rationale: property signatures are what makes strictFunctionTypes meaningful on interfaces"],"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"}