Skip to content

Commit 8672601

Browse files
committed
fix(ts): make Profile/User interfaces overridable (nextauthjs#1801)
* fix(ts): create DefaultUser interface * fix(ts): fix TypeORMUserModel * fix(ts): create DefaultProfile
1 parent 604a47f commit 8672601

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

types/adapters.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ declare class TypeORMUserModel implements User {
204204
image?: string,
205205
emailVerified?: Date
206206
)
207+
[x: string]: unknown
207208
}
208209

209210
declare class TypeORMSessionModel implements Session {

types/index.d.ts

+11-7
Original file line numberDiff line numberDiff line change
@@ -251,14 +251,16 @@ export interface Account extends TokenSet, Record<string, unknown> {
251251
type: string
252252
}
253253

254-
/** The OAuth profile returned from your provider */
255-
export interface Profile extends Record<string, unknown> {
254+
export interface DefaultProfile {
256255
sub?: string
257256
name?: string
258257
email?: string
259258
image?: string
260259
}
261260

261+
/** The OAuth profile returned from your provider */
262+
export interface Profile extends Record<string, unknown>, DefaultProfile {}
263+
262264
/** [Documentation](https://next-auth.js.org/configuration/callbacks) */
263265
export interface CallbacksOptions<
264266
P extends Record<string, unknown> = Profile,
@@ -391,6 +393,12 @@ export interface SessionOptions {
391393
updateAge?: number
392394
}
393395

396+
export interface DefaultUser {
397+
name?: string | null
398+
email?: string | null
399+
image?: string | null
400+
}
401+
394402
/**
395403
* The shape of the returned object in the OAuth providers' `profile` callback,
396404
* available in the `jwt` and `session` callbacks,
@@ -401,11 +409,7 @@ export interface SessionOptions {
401409
* [`jwt` callback](https://next-auth.js.org/configuration/callbacks#jwt-callback) |
402410
* [`profile` OAuth provider callback](https://next-auth.js.org/configuration/providers#using-a-custom-provider)
403411
*/
404-
export interface User {
405-
name?: string | null
406-
email?: string | null
407-
image?: string | null
408-
}
412+
export interface User extends Record<string, unknown>, DefaultUser {}
409413

410414
declare function NextAuth(
411415
req: NextApiRequest,

0 commit comments

Comments
 (0)