Skip to content

"This accepts type of undefined, but is required at runtime" #2646

Answered by flybayer
medihack asked this question in Q&A
Discussion options

You must be logged in to vote

Good question.

On the frontend, result of useParam type is number | undefined. So somehow we need to get the number | undefined type to work with the query input. One way is by marking the zod schema as optional. The other way, is keep zod schema as just z.number() and on the frontend have the query input as {id: userId!}. The ! character will override the TS type to remove | undefined

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@dbachrach
Comment options

@dbachrach
Comment options

@flybayer
Comment options

@dbachrach
Comment options

@flybayer
Comment options

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