graphql-zeus
graphql-zeus copied to clipboard
Compiler error TS7030 on generated schema
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[]) => {
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.
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.