Open michaelpumo opened 10 months ago
I'm also facing same issue
Hey there, what version of TypeScript are you on? Also, can you put up an example project that demonstrates the issue so I can replicate it?
I did a little more digging and I think it may be an issue in combination with Vue's reactivity and not directly Supabase afterall. You may see something similar with React?
If I try to a assign to a simple variable with let
for example it's okay but using ref()
in Vue causes the warning, possibly due to Vue / TS not knowing how deep it would have to watch the reactive object.
If I use shallowRef()
instead, it's fine: https://vuejs.org/api/reactivity-advanced.html#shallowref
Bump
The Json type does reference itself. Could it be that? I've also been having the same problem with the Json type columns.
Edit: changed my generated Json type to this and it all went away:
export type Json =
| string
| number
| boolean
| null
| { [key: string]: any | undefined }
| any[]
The error is complaining in my opinion that the line | { [key: string]: Json | undefined }
has no end to type instantiation, which when you think about it, is true.
Same issue here does anyone find a good and secure workaround?
I did a little more digging and I think it may be an issue in combination with Vue's reactivity and not directly Supabase afterall. You may see something similar with React?
If I try to a assign to a simple variable with
let
for example it's okay but usingref()
in Vue causes the warning, possibly due to Vue / TS not knowing how deep it would have to watch the reactive object.If I use
shallowRef()
instead, it's fine: vuejs.org/api/reactivity-advanced.html#shallowref
Any way to manage this in pinia store without using composition ?
Just wanted to confirm this is still an issue at time of writing with the latest version of Vue and supabase-js and makes it impossible to work with supabase-js in any serious capacity when using Typescript and Vue.
Fix I'm using is to update your supabase generated types to have Json
as below:
export type Json = Record<string, any>
Bringing the comments from the related issue made for the CLI here.
Summary of suggestions:
Json
types as unknown
and allow the developer to decideJson
type as Record
with a string
key and any
valueMergeDeep
from the typefest libraryJson
type to any
Bug report
Describe the bug
I have a Vue/Nuxt project with TypeScript which is throwing me an error with the profile table when I try to assign it to a variable based on the types generated from the DB. "Type instantiation is excessively deep and possibly infinite."
The problematic column in question is one called "links" which stores JSONB data. The type that is generated from the Supabase Cli using the command
npx supabase gen types typescript
creates a self referencing type calledJson
.With my (generated) profile row types looking like:
In my Pinia Vue store I get the following error when trying to assign it against these types.
I'm guessing this error happens because the generated type is self referencing and TS does not know how deep it would be?
To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:
Expected behavior
There should be no TS error.
Screenshots
System information
Additional context
I have not been able to see similar issues with other Supabase users but perhaps the use of JSONB is quite rare?