How to annotate function, which returns queryOptions object.
Hello everyone,
I have @typescript-eslint/explicit-module-boundary-types function enabled on my project.
I want to create something like this:
But I am getting typescript error, because I need to define return type of groupOptions. I was unable to do it, as I get lots of errors from using
groupOptions(): QueryOptions<ResponseData, etc, etc, etc>
I cannot configure this rule to ignore those functions either.
The only option, which I see right now is to declare my own interface for queryOptions:
Would you have any suggestions? Maybe I am missing something. It would be nice to use queryOptions helper, because it has better type safety.3 Replies
wise-whiteOP•10mo ago
Yes, I found the option:
This approach works well:
other-emerald•10mo ago
But I am getting typescript error, because I need to define return type of groupOptionsthat's not a typescript error, it's a lint error probably; using inference and not defining a return type is the better approach
wise-whiteOP•10mo ago
You're right, it's eslint error.
will keep inference. (I know it's redundant code in this case just to satisfy eslint rule, but I don't see better option)
It didn't work either. I agree, that in this case inference is better. Will try to figure out another approach