Closed ultimateshadsform closed 2 months ago
I've been sitting all day trying to add my own types to the SessionDataT object. I don't like using any type. Is there a way to do this in TypeScript?
any
My session.d.ts:
import { type Session } from 'h3'; import { IUser } from '@/types/user.ts'; interface Data { user: IUser; } declare module 'h3' { export interface Session { Data: Data; } }
But it doesn't seem to work. I also don't want to do (session.data as Usertype) etc I just want to do a d.ts like you can with express.
I'm also using Nuxt 3 using h3.
Nvm. Should add this to the docs. But you do it like this:
useSession<your type>
Describe the change
I've been sitting all day trying to add my own types to the SessionDataT object. I don't like using
any
type. Is there a way to do this in TypeScript?My session.d.ts:
But it doesn't seem to work. I also don't want to do (session.data as Usertype) etc I just want to do a d.ts like you can with express.
I'm also using Nuxt 3 using h3.