@@ -150,11 +150,15 @@ appWithRotationSecret.register(cookie, {
150150appWithRotationSecret . after ( ( ) => {
151151 server . get ( '/' , ( request , reply ) => {
152152 reply . unsignCookie ( request . cookies . test ! ) ;
153- const { valid , renew , value } = reply . unsignCookie ( 'test' ) ;
153+ const unsigned = reply . unsignCookie ( 'test' ) ;
154154
155- expectType < boolean > ( valid ) ;
156- expectType < boolean > ( renew ) ;
157- expectType < string | null > ( value ) ;
155+ expectType < boolean > ( unsigned . valid ) ;
156+ if ( unsigned . valid ) {
157+ expectType < string > ( unsigned . value ) ;
158+ } else {
159+ expectType < null > ( unsigned . value ) ;
160+ }
161+ expectType < boolean > ( unsigned . renew ) ;
158162
159163 reply . send ( { hello : 'world' } ) ;
160164 } ) ;
@@ -182,11 +186,15 @@ appWithParseOptions.register(cookie, {
182186} ) ;
183187appWithParseOptions . after ( ( ) => {
184188 server . get ( '/' , ( request , reply ) => {
185- const { valid , renew , value } = reply . unsignCookie ( request . cookies . test ! ) ;
189+ const unsigned = reply . unsignCookie ( request . cookies . test ! ) ;
186190
187- expectType < boolean > ( valid ) ;
188- expectType < boolean > ( renew ) ;
189- expectType < string | null > ( value ) ;
191+ expectType < boolean > ( unsigned . valid ) ;
192+ if ( unsigned . valid ) {
193+ expectType < string > ( unsigned . value ) ;
194+ } else {
195+ expectType < null > ( unsigned . value ) ;
196+ }
197+ expectType < boolean > ( unsigned . renew ) ;
190198 } ) ;
191199} ) ;
192200
@@ -204,11 +212,15 @@ appWithCustomSigner.register(cookie, {
204212appWithCustomSigner . after ( ( ) => {
205213 server . get ( '/' , ( request , reply ) => {
206214 reply . unsignCookie ( request . cookies . test ! )
207- const { valid , renew , value } = reply . unsignCookie ( 'test' )
215+ const unsigned = reply . unsignCookie ( 'test' )
208216
209- expectType < boolean > ( valid )
210- expectType < boolean > ( renew )
211- expectType < string | null > ( value )
217+ expectType < boolean > ( unsigned . valid ) ;
218+ if ( unsigned . valid ) {
219+ expectType < string > ( unsigned . value ) ;
220+ } else {
221+ expectType < null > ( unsigned . value ) ;
222+ }
223+ expectType < boolean > ( unsigned . renew ) ;
212224
213225 reply . send ( { hello : 'world' } )
214226 } )
0 commit comments