You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The currentUser type in the api seems all good, however type from useAuth() in the web is not the same as the ThenArg<ReturnType<typeof getCurrentUser>>.
My tsconfig from the web.
note: I changed strict to true
// This file was generated by RedwoodJS
import '@redwoodjs/api'
import '@redwoodjs/auth'
import { getCurrentUser } from '../../../api/src/lib/auth'
type ThenArg<T> = T extends PromiseLike<infer U> ? U : T
export type InferredCurrentUser = ThenArg<ReturnType<typeof getCurrentUser>>
type UndefinedRoles = {
/**
* ⚠️ Heads-Up: This is undefined unless roles key is returned from {@link getCurrentUser()}
*
* You may take a look at https://redwoodjs.com/docs/tutorial/chapter7/rbac for a tutorial on
* how to add fully-fledged RBAC (Role-based Access Control) to your database model.
*/
roles?: unknown | unknown[]
}
type Overwrite<T, U> = Omit<T, keyof U> & U
declare module '@redwoodjs/graphql-server' {
interface GlobalContext {
currentUser?: Overwrite<UndefinedRoles, InferredCurrentUser>
}
}
declare module '@redwoodjs/auth' {
interface CurrentUser extends InferredCurrentUser {}
}
If I hover over InferredCurrentUser i see the following information:
You can clone this repo here. Im using docker to run the postgres db so in order to run the project you have to add these keys to your .env file:
DATABASE_URL="postgresql://rowin:password@localhost:5432/teamstasts_development?connection_limit=1"
TEST_DATABASE_URL="postgresql://rowin:password@localhost:5432/teamstasts_test?connection_limit=1"
# Used to encrypt/decrypt session cookies. Change this value and re-deploy to log out all users of your app at once.
SESSION_SECRET=<YOUR SECRET>
API_URL="/.redwood/functions"
SENDINBLUE_SMTP_KEYS=<TOKEN> # -> Should not be required
Now run yarn rw dev and if you visit for example Homepage.tsx line 10 you will see the currentUser object and the type which isn't correct.
@rowin1125 thanks for raising this. I don't believe we've shipped strict mode support just yet, where we've solved some of these issues.
You are welcome to try it in canary however, by running yarn rw upgrade -t canary - but please note there may be breaking changes that will affect you in Canary.
What's not working?
The currentUser type in the
api
seems all good, however type fromuseAuth()
in theweb
is not the same as theThenArg<ReturnType<typeof getCurrentUser>>
.My tsconfig from the web.
note: I changed
strict
totrue
The `all-currentUser.d.ts
If I hover over
InferredCurrentUser
i see the following information:When looking at the
AuthProvider.d.ts
I can see that the currentUser type is defined in this file:How do we reproduce the bug?
You can clone this repo here. Im using docker to run the postgres db so in order to run the project you have to add these keys to your
.env
file:Now run
yarn rw dev
and if you visit for exampleHomepage.tsx
line 10 you will see thecurrentUser
object and the type which isn't correct.What's your environment? (If it applies)
System: OS: Linux 5.13 Ubuntu 21.10 21.10 (Impish Indri) Shell: 5.8 - /usr/bin/zsh Binaries: Node: 16.14.2 - /tmp/xfs-4f764c8e/node Yarn: 3.2.1 - /tmp/xfs-4f764c8e/yarn Databases: SQLite: 3.38.2 - /home/linuxbrew/.linuxbrew/bin/sqlite3 npmPackages: @redwoodjs/core: 2.1.0 => 2.1.0
Are you interested in working on this?
The text was updated successfully, but these errors were encountered: