合作咨询
我们的专家服务团队将竭诚为您提供专业的合作咨询服务
强制使用函数类型而不是带有签名的对象类型。
- // 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;
- }
合作咨询
我们的专家服务团队将竭诚为您提供专业的合作咨询服务
解决方案
精准高效的一站式服务支持,助力开发者商业成功