graphql-zeus icon indicating copy to clipboard operation
graphql-zeus copied to clipboard

Compiler error TS7030 on generated schema

Open RoryO opened this issue 3 years ago • 2 comments

There are two generated functions in a generated schema where the if cases are not exhaustive, causing a compiler error. For now I worked around the error by adding throw new Error() at the end of the functions. I'm not sure what you want to happen if the passed in parts do not match a condition.

error TS7030: Not all code paths return a value.
const ResolvePropsType = (mappedParts: Part[]) => {
error TS7030: Not all code paths return a value.
const ResolveReturnType = (mappedParts: Part[]) => {

RoryO avatar Jul 14 '22 17:07 RoryO

Right, throwing an error at the end of these functions does actually cause an error at run time. It looks like the return value must be some sort of string and not void. I don't know what the answer here is, so for now I'm reverting back to 4.0.4.

RoryO avatar Jul 14 '22 22:07 RoryO

It seems like the return value actually gets checked for truthiness, so our solution, when we realized throw new Error() doesn't work at runtime, was to just add an explicit return undefined; to the end of the functions. That seems to have resolved the issue without generating runtime errors.

cbh66 avatar Feb 24 '23 19:02 cbh66