From 34f334a71d9693ed177168dbc4bf706b2734f8ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20Orb=C3=A1n?= Date: Thu, 22 Apr 2021 01:04:23 +0200 Subject: [PATCH] fix(ts): make Profile/User interfaces overridable (#1801) * fix(ts): create DefaultUser interface * fix(ts): fix TypeORMUserModel * fix(ts): create DefaultProfile --- types/adapters.d.ts | 1 + types/index.d.ts | 18 +++++++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/types/adapters.d.ts b/types/adapters.d.ts index 0e6e86cc68..0f486fc9a6 100644 --- a/types/adapters.d.ts +++ b/types/adapters.d.ts @@ -204,6 +204,7 @@ declare class TypeORMUserModel implements User { image?: string, emailVerified?: Date ) + [x: string]: unknown } declare class TypeORMSessionModel implements Session { diff --git a/types/index.d.ts b/types/index.d.ts index 44a0cee397..1e54fe84f9 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -251,14 +251,16 @@ export interface Account extends TokenSet, Record { type: string } -/** The OAuth profile returned from your provider */ -export interface Profile extends Record { +export interface DefaultProfile { sub?: string name?: string email?: string image?: string } +/** The OAuth profile returned from your provider */ +export interface Profile extends Record, DefaultProfile {} + /** [Documentation](https://next-auth.js.org/configuration/callbacks) */ export interface CallbacksOptions< P extends Record = Profile, @@ -391,6 +393,12 @@ export interface SessionOptions { updateAge?: number } +export interface DefaultUser { + name?: string | null + email?: string | null + image?: string | null +} + /** * The shape of the returned object in the OAuth providers' `profile` callback, * available in the `jwt` and `session` callbacks, @@ -401,11 +409,7 @@ export interface SessionOptions { * [`jwt` callback](https://next-auth.js.org/configuration/callbacks#jwt-callback) | * [`profile` OAuth provider callback](https://next-auth.js.org/configuration/providers#using-a-custom-provider) */ -export interface User { - name?: string | null - email?: string | null - image?: string | null -} +export interface User extends Record, DefaultUser {} declare function NextAuth( req: NextApiRequest,