socketio / socket.io-website

Socket.IO website and blog
https://socket.io
319 stars 696 forks source link

Express Sesssion Middleware with Typescript Build Error #396

Open daedalus-hephaestus opened 1 year ago

daedalus-hephaestus commented 1 year ago

Following this tutorial leads to a compilation error.

A user named Goldjee wrote a fix and posted it in a comment.

All you need to do is change:

declare module "http" {
    interface IncomingMessage {
        session: Session & {
            authenticated: boolean
        }
    }
}

to

declare module 'http' {
    interface IncomingMessage {
        cookieHolder?: string;
        session: Session & Partial<session.SessionData>;
    }
}