-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Export SignupHandlerOptions interface and update its userAttributes type #9049
Conversation
Thanks for this @c-ciobanu! @cannikin Any chance you can take a look? |
My knee jerk reaction is But actually I thought of a slightly different solution. What if we make |
@Tobbe With this change now I can do this basically: const signupOptions: DbAuthHandlerOptions<
undefined,
{ age: numbers; items: number[] }
>['signup'] = {
...
handler: ({ username, hashedPassword, salt, userAttributes }) => {
...
|
…ype (#9049) Co-authored-by: Tobbe Lundberg <[email protected]>
This sparkled from a discussion in the community forum here https://community.redwoodjs.com/t/signuphandleroptions-userattributes-type/5231/2
Problem:
Since the type of
userAttributes
isRecord<string, string>
and if you pass something that is not a string to yoursignupHandler
you are forced to convert types to stop TS complaing.e.g.
Solution:
SignupHandlerOptions
so you can do something like this:userAttributes
toRecord<string, any>
so you could just writeconst relatedItems = userAttributes.items.map((item) => ({ id: item }))
without TS complaining or you could write this too without having to convert to unknown firstThere was an idea about having
userAttributes
asRecord<string, unknown>
but I personally think that by doing that the second point of the solution would not to possible anymore and you would be forced to use the first solution. Any comments about that?