TypeScript allows declaring the type of a function in two different ways:
() ⇒ number { (): number } The function type syntax is generally preferred for being more concise.
Use a function type instead of an interface or object type literal with a single call signature.
function apply(f: { (): string }): string {
return f();
}
function apply(f: () => string): string {
return f();
}
interface Foo {
(): number;
}
type Foo = () => number;