@@ -182,6 +182,11 @@ describe('http-proxy-middleware TypeScript Types', () => {
182182 error ( error , req , res , target ) {
183183 req . params ;
184184
185+ // @ts -expect-error: should error when request is typed as `any`
186+ req . unknownProperty ;
187+ // @ts -expect-error: should error when response is typed as `any`
188+ res . unknownProperty ;
189+
185190 // https://www.typescriptlang.org/docs/handbook/2/narrowing.html
186191 if ( res instanceof http . ServerResponse ) {
187192 res . status ( 200 ) . send ( 'OK' ) ;
@@ -345,6 +350,11 @@ describe('http-proxy-middleware TypeScript Types', () => {
345350 proxyRes : responseInterceptor ( async ( buffer , proxyRes , req , res ) => {
346351 req . myRequestParams ;
347352 res . myResponseParams ;
353+
354+ // @ts -expect-error: should error when request is typed as `any`
355+ req . unknownProperty ;
356+ // @ts -expect-error: should error when response is typed as `any`
357+ res . unknownProperty ;
348358 return buffer ;
349359 } ) ,
350360 } ,
@@ -371,6 +381,12 @@ describe('http-proxy-middleware TypeScript Types', () => {
371381 ( proxyServer , options ) => {
372382 proxyServer . on ( 'proxyReq' , ( proxyReq , req , res , options ) => {
373383 req . params ;
384+
385+ // @ts -expect-error: should error when request is typed as `any`
386+ req . unknownProperty ;
387+ // @ts -expect-error: should error when response is typed as `any`
388+ res . unknownProperty ;
389+
374390 res . status ( 200 ) . send ( 'OK' ) ;
375391 } ) ;
376392 } ,
@@ -396,6 +412,12 @@ describe('http-proxy-middleware TypeScript Types', () => {
396412 responseInterceptor ( async ( buffer , proxyRes , req , res ) => {
397413 req . params ;
398414 res . status ( 200 ) . send ( 'OK' ) ;
415+
416+ // @ts -expect-error: should error when request is typed as `any`
417+ req . unknownProperty ;
418+ // @ts -expect-error: should error when response is typed as `any`
419+ res . unknownProperty ;
420+
399421 return buffer ;
400422 } ) ,
401423 ) ;
0 commit comments