oxc-project/oxc · warning · OxcDiagnostic

Use a method signature instead of a property signature.

Error message

Use a method signature instead of a property signature.

What it means

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.

Source

Thrown at crates/oxc_linter/src/rules/typescript/method_signature_style.rs:34

};

fn method_signature_style_diagnostic(
    config: MethodSignatureStyleConfig,
    span: Span,
) -> OxcDiagnostic {
    match config {
        MethodSignatureStyleConfig::Property => method_signature_style_property_diagnostic(span),
        MethodSignatureStyleConfig::Method => method_signature_style_method_diagnostic(span),
    }
}

fn method_signature_style_property_diagnostic(span: Span) -> OxcDiagnostic {
    OxcDiagnostic::warn("Use a property signature instead of a method signature.")
        .with_help("Replace the method signature with a property whose type is a function type.")
        .with_label(span)
}
fn method_signature_style_method_diagnostic(span: Span) -> OxcDiagnostic {
    OxcDiagnostic::warn("Use a method signature instead of a property signature.")
        .with_help("Replace the property signature with method shorthand syntax.")
        .with_label(span)
}

#[derive(Debug, Default, Clone, Copy, Eq, PartialEq, JsonSchema, Deserialize, Serialize)]
#[serde(rename_all = "kebab-case")]
enum MethodSignatureStyleConfig {
    #[default]
    /// Enforce using property signature for functions. Use this to enforce maximum correctness together with TypeScript's strict mode.
    Property,
    /// Enforce using method signature for functions. Use this if you aren't using TypeScript's strict mode and prefer this style.
    Method,
}

#[derive(Debug, Default, Clone, Deserialize, Serialize)]
pub struct MethodSignatureStyle(MethodSignatureStyleConfig);

impl MethodSignatureStyle {

View on GitHub (pinned to e1e7af627c)

Solutions

  1. Rewrite `interface I { foo: () => void; }` as `interface I { foo(): void; }`
  2. 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
  3. Reconsider the option: the default "property" style is required for strict-mode variance checking

Example fix

// before
interface Store {
  load: (key: string) => Promise<Data>;
}

// after
interface Store {
  load(key: string): Promise<Data>;
}
Defensive patterns

Strategy: validation

Validate before calling

// .oxlintrc.json — opt into shorthand style deliberately
{
  "rules": {
    "typescript/method-signature-style": ["warn", "method"]
  }
}

Prevention

When it happens

Trigger: `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.

Common situations: 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.

Related errors


AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20). Data as JSON: /api/errors/af9a6df79212b9b7. Report an issue: GitHub.