refactor(typing): override "#auth" module from nuxt-auth
make it so that we're absolutely sure that the type of `useAuth().data` is interpreted by typescript to be OUR version of `SessionData`
This commit is contained in:
		
							parent
							
								
									dabebc6747
								
							
						
					
					
						commit
						3415f41044
					
				
							
								
								
									
										56
									
								
								typings/auth.d.ts
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										56
									
								
								typings/auth.d.ts
									
									
									
									
										vendored
									
									
								
							| @ -1,10 +1,60 @@ | ||||
| import { IUser } from "@models/user"; | ||||
| import { SessionData as SDI } from "#auth"; | ||||
| import { | ||||
| 	GetSessionFunc, | ||||
| 	SecondarySignInOptions, | ||||
| 	SessionLastRefreshedAt, | ||||
| 	SessionStatus, | ||||
| 	SignInFunc, | ||||
| 	SignOutFunc, | ||||
| } from "@sidebase/nuxt-auth/dist/runtime/types"; | ||||
| import { ComputedRef, Ref } from "vue"; | ||||
| 
 | ||||
| declare module "#auth" { | ||||
| 	export interface SessionData extends SDI { | ||||
| 	interface SessionData { | ||||
| 		token?: string; | ||||
| 		user?: IUser; | ||||
| 	} | ||||
| 	export type WrappedSessionData = SessionData; | ||||
| } | ||||
| 
 | ||||
| declare module "@sidebase/nuxt-auth/dist/runtime/types" { | ||||
| 	interface SessionData { | ||||
| 		token?: string; | ||||
| 		user?: IUser; | ||||
| 	} | ||||
| 	declare const signIn: SignInFunc<Credentials, any>; | ||||
| 	declare const signOut: SignOutFunc; | ||||
| 	declare const getSession: GetSessionFunc<SessionData | null | void>; | ||||
| 	declare const signUp: ( | ||||
| 		credentials: Credentials, | ||||
| 		signInOptions?: SecondarySignInOptions, | ||||
| 	) => Promise<any>; | ||||
| 
 | ||||
| 	type WrappedSessionData<SessionData> = Ref<SessionData | null | undefined>; | ||||
| 	export interface CommonUseAuthReturn< | ||||
| 		SignIn, | ||||
| 		SignOut, | ||||
| 		GetSession, | ||||
| 		SessionData, | ||||
| 	> { | ||||
| 		data: Readonly<WrappedSessionData<SessionData>>; | ||||
| 		lastRefreshedAt: Readonly<Ref<SessionLastRefreshedAt>>; | ||||
| 		status: ComputedRef<SessionStatus>; | ||||
| 		signIn: SignIn; | ||||
| 		signOut: SignOut; | ||||
| 		getSession: GetSession; | ||||
| 	} | ||||
| 	interface UseAuthReturn | ||||
| 		extends CommonUseAuthReturn< | ||||
| 			typeof signIn, | ||||
| 			typeof signOut, | ||||
| 			typeof getSession, | ||||
| 			SessionData | ||||
| 		> { | ||||
| 		signUp: typeof signUp; | ||||
| 		token: Readonly<Ref<string | null>>; | ||||
| 	} | ||||
| 
 | ||||
| 	export declare const useAuth: () => UseAuthReturn; | ||||
| } | ||||
| 
 | ||||
| export {}; | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user