This rule suggests using a function type instead of an interface or object type literal with a single call signature.
Examples of incorrect code for this rule:
interface Foo {
(): string;
}
function foo(bar: { (): number }): number {
return bar();
}
interface Foo extends Function {
(): void;
}
Examples of correct code for this rule:
interface Foo {
(): void;
bar: number;
}
function foo(bar: { (): string; baz: number }): string {
return bar();
}
interface Foo {
bar: string;
}
interface Bar extends Foo {
(): void;
}
If you specifically want to use an interface or type literal with a single call signature for stylistic reasons, you can disable this rule.
- TSLint:
callable-types