#How to define locals typings?

5 messages · Page 1 of 1 (latest)

tender knot
#

Hi folks!
How can I define the locals typings in my app?

In the middleware, I'm trying to set a "session" in the locals object, but I get this error:

Property 'session' does not exist on type 'Locals'

Looking at Astro's typings, "Locals" is defined in the App.Locals as we can see in the code bellow:

    /**
     * Object accessed via Astro middleware
     */
    locals: App.Locals;

How do I overwrite this type?

grand kayak
#
declare namespace App {
    interface Locals {
        session: 
    }
}
#

In any .d.ts file in your project

tender knot
#

Thanks for the quick response! thanks

I tried that and it didn't work, including inside env.d.ts, and now again in another file.
Could it be some configuration of my typescript (tsconfig)?

#

Forget it, I got it to work, my mistake.
Thank you anyway! rs