Skip to content

How to get output with safeParse without checking for success #282

Discussion options

You must be logged in to vote

I think TypeScript needs to see the throw statement. So you could change your code like this:

private _rethrow() {
  return new Error('Invalid');
}

async guarder() {
  // ...
  if (!parseResult.success) {
    throw this._rethrow()
  }
  const data = parseResult.output;
}

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@fabian-hiller
Comment options

@fabian-hiller
Comment options

@ericmartinezr
Comment options

@fabian-hiller
Comment options

Answer selected by ericmartinezr
@ericmartinezr
Comment options

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