method-signature-style
Configuration
rslint.config.ts
Rule Details
Enforces using a particular method signature syntax in interfaces and type literals.
There are two styles for declaring method signatures in TypeScript:
- Method shorthand:
func(arg: string): number; - Property:
func: (arg: string) => number;
The key difference: with strictFunctionTypes enabled, method parameters are checked less strictly, while function property parameters are checked more strictly. This makes function properties more type-safe.
Options
"property"(default): Enforces function property signature syntax."method": Enforces method shorthand signature syntax.
"property" (default)
Examples of incorrect code:
Examples of correct code:
"method"
Examples of incorrect code:
Examples of correct code: