feathers icon indicating copy to clipboard operation
feathers copied to clipboard

Wrong type inference for request handlers

Open jfamousket opened this issue 4 years ago • 0 comments

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch @feathersjs/[email protected] for the project I'm working on.

The request, response, and next function type of my request handlers had any type. After fiddling around I found that the changes made by this pull request were the cause of the issue.

Here is the diff that solved my problem:

diff --git a/node_modules/@feathersjs/express/index.d.ts b/node_modules/@feathersjs/express/index.d.ts
index 05d329d..f40abfa 100644
--- a/node_modules/@feathersjs/express/index.d.ts
+++ b/node_modules/@feathersjs/express/index.d.ts
@@ -48,13 +48,13 @@ declare module 'express-serve-static-core' {
         hook?: HookContext;
     }
 
-    type FeathersService = Partial<ServiceMethods<any> & SetupMethod>;
-
-    interface IRouterMatcher<T> {
-        // tslint:disable-next-line callable-types (Required for declaration merging)
-        <P extends Params = ParamsDictionary, ResBody = any, ReqBody = any>(
-            path: PathParams,
-            ...handlers: (RequestHandler<P, ResBody, ReqBody> | FeathersService | Application)[]
-        ): T;
-    }
+    // type FeathersService = Partial<ServiceMethods<any> & SetupMethod>;
+
+    // interface IRouterMatcher<T> {
+    //     // tslint:disable-next-line callable-types (Required for declaration merging)
+    //     <P extends Params = ParamsDictionary, ResBody = any, ReqBody = any>(
+    //         path: PathParams,
+    //         ...handlers: (RequestHandler<P, ResBody, ReqBody> | FeathersService | Application)[]
+    //     ): T;
+    // }
 }

This issue body was partially generated by patch-package.

jfamousket avatar Jul 05 '21 11:07 jfamousket