Skip to main content


Enforce using function types instead of interfaces with call signatures.


ESLint 配置 中扩展"plugin:@typescript-eslint/stylistic" 可启用此规则。


此规则报告的一些问题可通过 --fix ESLint 命令行选项自动修复

TypeScript 允许使用两种常见的方法来声明函数的类型:

英:TypeScript allows for two common ways to declare a type for a function:

  • 功能类型: () => string
  • 带有签名的对象类型: { (): string }


英:The function type form is generally preferred when possible for being more succinct.


英:This rule suggests using a function type instead of an interface or object type literal with a single call signature.

module.exports = {
"rules": {
"@typescript-eslint/prefer-function-type": "error"
在线运行试试这个规则 ↗


interface Example {
(): string;
Open in Playground
function foo(example: { (): number }): number {
return example();
Open in Playground
interface ReturnsSelf {
// returns the function itself, not the `this` argument.
(arg: string): this;
Open in Playground



英:If you specifically want to use an interface or type literal with a single call signature for stylistic reasons, you can avoid this rule.

该规则有一个已知的边缘情况,有时会触发全局增强,例如 interface Function。 这些边缘情况很少见,并且通常是奇怪代码的症状。 我们建议你使用 内联 ESLint 禁用注释。 详情请参见 #454

英:This rule has a known edge case of sometimes triggering on global augmentations such as interface Function. These edge cases are rare and often symptomatic of odd code. We recommend you use an inline ESLint disable comment. See #454 for details.