Enforce using function types instead of interfaces with call signatures.
// code-linter.json5
{
"rules": {
"@typescript-eslint/prefer-function-type": "error"
}
} export function foo(example: () => number): number {
return example();
}
// returns the function itself, not the `this` argument.
export type ReturnsSelf = (arg: string) => ReturnsSelf;
export interface Foo {
bar: string;
} interface GeneratedTypeLiteralInterface {
(): number;
}
export function foo(example: GeneratedTypeLiteralInterface): number {
return example();
}
export interface Foo {
(bar: string): this;
} plugin:@typescript-eslint/all
For details about how to configure Code Linter check rules, see Code Linter.