What does this typescript code mean?

the following typescript code:

function rule(name?: string, options?: IRuleOptions)(func: IRuleFunction): Rule

export type IRuleFunction = (
  parent?: any,
  args?: any,
  context?: any,
  info?: GraphQLResolveInfo,
) => IRuleResult | Promise<IRuleResult>

interface IRuleOptions {
  cache?: ICacheOptions
  fragment?: IFragment
}

question:
the first line of code is as follows:

function rule(name?: string, options?: IRuleOptions)(func: IRuleFunction): Rule
              -------------------------------------  -------------------   ----
                                1                        2          3
                                
                            

(1) is an argument to the function and can be understood. What do
(2) and (3) mean?

Please give me some guidance, thank you

Update:
Code Source: https://github.com/maticzav/g.

Jul.14,2021

are you sure your code is normal?


is amazing, it is written in graphql-shield 's README.md, but I think it may be a Markdown parsing error that makes = > disappear. Look at its source code , which is defined as:

add: after looking through the source code of README.md, it is found that = > is not included in the source code of MD, so I don't understand why the author wrote it this way, but there is always nothing wrong with the definition of rule in the code
.

232

function rule(name?: string, options?: IRuleOptions){
    return function(func: IRuleFunction): Rule {
         // ...some
    }
}
Menu