Adding new properties to session publicData causes type error in blitz-server.ts
- Dominant language
- TypeScript
- Stars
- 14.1k
- Forks
- 803
- PR merge metrics
- No merged PRs in 30d
Description
### What is the problem?
Adding new properties seems to be causing type error or changing the type of userId to string (uuid)
### Paste all your error logs here:
```ts
Argument of type 'PrismaClient & EnhancedPrismaClientAddedMethods' is not assignable to parameter of type 'PrismaClientWithSession'.
The types of 'session.update' are incompatible between these types.
Type '(args: SelectSubset) => CheckSelect, Prisma__SessionClient<...>>' is not assignable to type '(args: { data: Partial; where: { handle?: string | undefined; }; }) => Promise'.
Types of parameters 'args' and 'args' are incompatible.
Type '{ data: Partial; where: { handle?: string | undefined; }; }' is not assignable to type '{ select?: SessionSelect | null | undefined; include?: SessionInclude | null | undefined; data: (Without & SessionUncheckedUpdateInput) | (Without<...> & SessionUpdateInput); where: SessionWhereUniqueInput; }'.
Types of property 'data' are incompatible.
Type 'Partial' is not assignable to type '(Without & SessionUncheckedUpdateInput) | (Without<...> & SessionUpdateInput)'.
Type 'Partial' is not assignable to type 'Without & SessionUpdateInput'.
Type 'Partial' is not assignable to type 'Without'.
Types of property 'userId' are incompatible.
Type 'string | null | undefined' is not assignable to type 'undefined'.
Type 'null' is not assignable to type 'undefined'.
```
### Paste all relevant code snippets here:
```ts
import {SimpleRolesIsAuthorized} from '@blitzjs/auth'
import {GlobalRole, MembershipRole} from 'db'
export type Role = MembershipRole | GlobalRole
declare module "@blitzjs/auth" {
export interface Session {
isAuthorized: SimpleRolesIsAuthorized
PublicData: {
userId: string
isAdmin: boolean
role?: GlobalRole
orgRole?: MembershipRole
orgId?: string
}
}
}
```
### What are detailed steps to reproduce this?
1. i believe this happens when adding properties to the session data.
2. i could reproduce this twice but reverting it to original doesnt seem to fix it so i am not certain.
### Run `blitz -v` and paste the output here:
```sh
Blitz version: 2.0.0-beta.4 (global)
Blitz version: 2.0.0-beta.4 (local)
Windows 11 | win32-x64 | Node: v16.15.1
Package manager: npm
System:
OS: Windows 10 10.0.22000
CPU: (16) x64 AMD Ryzen 7 2700X Eight-Core Processor
Memory: 23.18 GB / 31.93 GB
Binaries:
Node: 16.15.1 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.18 - ~\.yarn\bin\yarn.CMD
npm: 8.11.0 - C:\Program Files\nodejs\npm.CMD
npmPackages:
@blitzjs/auth: 2.0.0-beta.4 => 2.0.0-beta.4
@blitzjs/next: 2.0.0-beta.4 => 2.0.0-beta.4
@blitzjs/rpc: 2.0.0-beta.4 => 2.0.0-beta.4
@prisma/client: 4.0.0 => 4.0.0
blitz: 2.0.0-beta.4 => 2.0.0-beta.4
next: 12.2.5 => 12.2.5
prisma: 4.0.0 => 4.0.0
react: 18.2.0 => 18.2.0
react-dom: 18.2.0 => 18.2.0
typescript: ^4.5.3 => 4.8.3
```
### Please include below any other applicable logs and screenshots that show your problem:
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.