diff --git a/types/types.d.ts b/types/types.d.ts index 8e22f1e..1c504f7 100644 --- a/types/types.d.ts +++ b/types/types.d.ts @@ -174,7 +174,10 @@ declare namespace fastifySession { cookiePrefix?: string; } - export interface CookieOptions extends Omit {} + export interface CookieOptions extends Omit { + /** A `number` in milliseconds that specifies the `Expires` attribute by adding the specified milliseconds to the current date. If both `expires` and `maxAge` are set, then `expires` is used. */ + maxAge?: number; + } export class MemoryStore implements fastifySession.SessionStore { constructor(map?: Map); diff --git a/types/types.test-d.ts b/types/types.test-d.ts index dd17422..a37e32f 100644 --- a/types/types.test-d.ts +++ b/types/types.test-d.ts @@ -7,8 +7,8 @@ import fastify, { Session } from 'fastify'; import Redis from 'ioredis'; -import { expectAssignable, expectError, expectType } from 'tsd'; -import { MemoryStore, SessionStore, default as fastifySession, default as plugin } from '..'; +import { expectAssignable, expectDocCommentIncludes, expectError, expectType } from 'tsd'; +import { CookieOptions, MemoryStore, SessionStore, default as fastifySession, default as plugin } from '..'; class EmptyStore { set(_sessionId: string, _session: any, _callback: Function) {} @@ -46,9 +46,14 @@ app.register(plugin, { app.register(plugin, { secret, cookie: { + maxAge: 1000, secure: 'auto' } }); + +const cookieMaxAge: CookieOptions = {}; +expectDocCommentIncludes<"millisecond">(cookieMaxAge.maxAge); + app.register(plugin, { secret, store: new EmptyStore()