Skip to content

How should JSONB values be passed for typescript support #364

Answered by Minigugus
RyanHirsch asked this question in Q&A
Discussion options

You must be logged in to vote

Is this a known limitation of the current types or am I doing something wrong?

Sorry but yes it is: since parameters types are inferred at runtime, static types have to allow all possible parameters types, but if we add JSON parameters types, we lost almost all advantages ({ [k: string]: any } may allow objects into number columns for instance). Maybe this can change in the future, if it's too constraining for instance.

The workaround is to use a helper: sql.json(config), but I don't know if it works with JSONB thought. Another possible workaround is to use customs types, especially since typings now adds custom types types to parameters types. The last possible workaround is to simply …

Replies: 2 comments 1 reply

Comment options

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

Comment options

You must be logged in to vote
0 replies
Answer selected by RyanHirsch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants