From efb8e4eebd433875a88aec8916cdf5955546e7dc Mon Sep 17 00:00:00 2001 From: Raku Zeta Date: Wed, 3 Jul 2024 15:34:41 +0800 Subject: [PATCH] improve type test readability (#259) --- types/types.test-d.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/types/types.test-d.ts b/types/types.test-d.ts index e848020..b209f8c 100644 --- a/types/types.test-d.ts +++ b/types/types.test-d.ts @@ -7,7 +7,7 @@ import fastify, { Session } from 'fastify'; import Redis from 'ioredis'; -import { expectAssignable, expectDocCommentIncludes, expectError, expectType } from 'tsd'; +import { expectAssignable, expectNotAssignable, expectDocCommentIncludes, expectError, expectType } from 'tsd'; import { CookieOptions, MemoryStore, SessionStore, default as fastifySession, default as plugin } from '..'; class EmptyStore { @@ -144,11 +144,11 @@ const app2 = fastify() app2.register(fastifySession) app2.get('/', async function(request) { - let num: number | undefined, str: string | undefined; - expectError(num = request.session.get('foo')); - expectAssignable(str = request.session.get('foo')); + expectAssignable(request.session.get('foo')); + expectNotAssignable(request.session.get('foo')); + + expectType(request.session.set('foo', 'bar')); expectError(request.session.set('foo', 2)); - expectAssignable(request.session.set('foo', 'bar')); expectType(request.session.get('user')) expectAssignable(request.session.set('user', { id: 2 })) @@ -158,4 +158,4 @@ app2.get('/', async function(request) { expectType(request.session.get('not exist')) expectAssignable(request.session.set('not exist', 'abc')) -}) \ No newline at end of file +})