The type ReturnTypeFunc is used in the Query decorator:
export declare function Query(returnTypeFunc: ReturnTypeFunc, options?: AdvancedOptions): MethodDecorator;
This is how Query decorator is usually used:
@Query(returns => [SampleObject])
As far as I remember, the parameter returns is added to help with the readability: This query returns an array of SampleObject. If you remove the returns argument in type ReturnTypeFunc, you cannot do this anymore, and you have to write @Query(() => [SampleObject]) instead.
Some other decorators that have an optional void argument are:
@Resolver(of => Recipe) // This is a resolver for Recipe. See type ClassTypeResolver
@Field(type => [Rate]) // This field is of type Rate. See type ClassTypeResolver.
Edit:
- As mentioned in the comments, you can only assign
null (if strictNullChecks is not specified) or undefined to a variable of type void.
- The mentioned decorators annotate classes. The graphql schema is generated by using the provided metadata to the decorators. To the best of my knowledge, you are not supposed to define a function that is of type
ReturnTypeFunc. The only reason those parameters are of type void, is to improve readability of code.
voidcan only beundefined, ornullifstrictNullChecksis not specified. As for the intent of it, you'd have to ask the project authors. If it's not documented explicitly already, then it probably isn't relevant to consumers of the project.