Skip to content
Discussion options

You must be logged in to vote

Hello @andremw ,

the purpose of ResultHandler is responding consistently for every Endpoint produced on EndpointsFactory having that ResultHandler attached to. Therefore, output can not have certain type, except the fact that we know that it is an object, because every output schema of Endpoint is required to be based on z.object().

However, you can still narrow it down to whatever you want by implementing Typescript conditions like this:

new ResultHandler({
  handler: ({ output }) => {
    if ("_type" in output && typeof output._type === "string") {
       // inside this block `output` has type { _type: string }
    }
  }
});

I must also say, that you should not return errors as a valid …

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@andremw
Comment options

Answer selected by RobinTail
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants