[koa-session] types were overwriting a Class with an interface FIX (#36206)

* koa-session was overwriting a Class with an interface

* forgot semicolons
This commit is contained in:
Valerio Coltrè
2019-06-27 14:22:14 -07:00
committed by Benjamin Lichtman
parent c4686d3e82
commit 3d4db2e667
2 changed files with 8 additions and 5 deletions
-5
View File
@@ -205,11 +205,6 @@ declare module "koa" {
session: session.Session | null;
readonly sessionOptions: session.opts | undefined;
}
interface Application {
on(name: "session:missed" | "session:expired" | "session:invalid", data: { key?: string, value?: Partial<session.Session>, ctx: Context }): void;
once(name: "session:missed" | "session:expired" | "session:invalid", data: { key?: string, value?: Partial<session.Session>, ctx: Context }): void;
}
}
export = session;
+8
View File
@@ -40,10 +40,18 @@ app.use(session({
path: "/",
}, app));
// can still use koa-session events, although without autocomplete
app.on('session:missed', () => {});
app.on('session:expired', () => {});
app.on('session:invalid', () => {});
app.use((ctx, next) => {
// reset the session
ctx.session = null;
// does not interfere with Application->EventEmitter #32389
ctx.app.emit('error', new Error('this is an user-generated Error'));
return next();
});