-
-
Notifications
You must be signed in to change notification settings - Fork 346
Add type definitions. #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Found it, needed to add the |
All functions defined in the |
Note on the failing integration tests - this can be ignored. We will have to roll the GoAuth middleware into a new docker image so that it can be run locally. We will solve that separately. @thorwebdev i'll trust your lead here - it's a non-breaking change so I am happy for you to merge this whenever you're happy. Once it's merged it will be much easier for the community to contribute patches (like the one I'm happy to merge if you want too |
@malobre the Auth methods don't return the error, but rather throws it which is something you have to handle with a try catch. However this is a good point that this has to be documented here: https://supabase.io/docs/library/user-management |
@kiwicopple IIRC @awalias wanted to first change the chaining hierarchy in the docs and the dashboard to follow the chaining hierarchy that the types use, e.g. From my pov this is peaceful to merge 👍 |
Nice to know, I wasn't sure how typescript handles thrown errors. Anyway, the type definition is working fine in my personal projects :) |
@thorwebdev IIRC it was because some postgrest-js methods are missing in supabase-js ( I personally prefer doing |
@soedirgo while it seems desirable to be able to call any of the methods at any time, I was worried about the cognitive load (Working memory can generally hold between five and nine items (or chunks) of information at any one time.), and therefore tried to model the major decision tree:
This way you can work with the supabase client without needing to consult documentation. The order is only enforced in TypeScript, so any existing JavaScript code will continue working, but I personally think that having a chaining order is generally a good idea, at least for people who don't have all of the available methods memorized. Wdyt? |
You're right, I didn't think of it from a text completion PoV. That way of doing it is more in line with the intended usage. But say we convert supabase-js to TS. Is it possible to allow arbitrary order of chaining without the compiler yelling? Otherwise I prefer to enforce this order even in JS, since there should at least be method completion even w/o types. This is the best time to do it since I'm working on converting postgrest-js to TS. This will break some code though... I still think these methods should only be in postgrest-js ( |
@soedirgo I had a look at how knex.js does this, and it's a bit of a mess IMO: I personally would be in favor of being opinionated about the chaining order across both JS and TS as it allows us to be coherent across docs and samples, and I think it's a better DX, but also understand that this might be a very subjective opinion. So would need @awalias and @kiwicopple to chime in on this.
Yes, absolutely on board with that 👍 |
We'll have to take a utilitarian approach to developer happiness here. Looks like we're trading flexibility for better/easier docs. I think the latter gives a better developer experience, so I'm happy to accept Thor's changes & force opinionated chaining.
Also we will have to update some of our docs. @soedirgo if you're on board & so is Ant, let's do it. If you think it needs to wait until I'm back to coding, then I can jump into this in ~2 weeks |
This is a WIP draft. Feedback and contributions are very welcome! This relates to supabase/supabase#122
createClient
supabase.auth
AuthResponse
andUser
paramsSupabaseClient
functionse.g. this could look like