diff --git a/packages/express/src/declarations.ts b/packages/express/src/declarations.ts index 676e983153..1537455219 100644 --- a/packages/express/src/declarations.ts +++ b/packages/express/src/declarations.ts @@ -6,13 +6,14 @@ import { } from '@feathersjs/feathers'; interface ExpressUseHandler { - ( - path: ServiceTypes[L] extends never ? string|RegExp : L, + ( + path: L, ...middlewareOrService: ( Express|express.RequestHandler| - (ServiceTypes[L] extends never ? ServiceInterface : ServiceTypes[L]) + (keyof any extends keyof ServiceTypes ? ServiceInterface : ServiceTypes[L]) )[] ): T; + (path: RegExp, ...expressHandlers: express.RequestHandler[]): T; (...expressHandlers: express.RequestHandler[]): T; (handler: Express|express.ErrorRequestHandler): T; } diff --git a/packages/express/src/index.ts b/packages/express/src/index.ts index 9698dc679b..efd8545374 100644 --- a/packages/express/src/index.ts +++ b/packages/express/src/index.ts @@ -21,7 +21,7 @@ export * from './declarations'; const debug = Debug('@feathersjs/express'); -export default function feathersExpress (feathersApp?: FeathersApplication, expressApp: Express = express()): Application { +export default function feathersExpress (feathersApp?: FeathersApplication, expressApp: Express = express()): Application { if (!feathersApp) { return expressApp as any; } @@ -62,7 +62,7 @@ export default function feathersExpress (feathersApp?: Feather debug('Registering service with middleware', middleware); // Since this is a service, call Feathers `.use` - feathersApp.use.call(this, location, service, { middleware }); + (feathersApp as FeathersApplication).use.call(this, location, service, { middleware }); return this; }, diff --git a/packages/feathers/src/application.ts b/packages/feathers/src/application.ts index 19b80c14cd..a32bc6d8e2 100644 --- a/packages/feathers/src/application.ts +++ b/packages/feathers/src/application.ts @@ -75,7 +75,7 @@ export class Feathers extends EventEmitter implements use ( path: L, - service: (keyof any extends keyof ServiceTypes ? ServiceInterface : ServiceTypes[L]) | Application, + service: keyof any extends keyof ServiceTypes ? ServiceInterface | Application : ServiceTypes[L], options?: ServiceOptions ): this { if (typeof path !== 'string') { @@ -83,7 +83,7 @@ export class Feathers extends EventEmitter implements } const location = (stripSlashes(path) || '/') as L; - const subApp = service as FeathersApplication; + const subApp = service as Application; const isSubApp = typeof subApp.service === 'function' && subApp.services; if (isSubApp) { @@ -113,7 +113,7 @@ export class Feathers extends EventEmitter implements return this; } - hooks (hookMap: HookOptions, any>) { + hooks (hookMap: HookOptions) { const legacyMap = hookMap as LegacyHookMap; if (legacyMap.before || legacyMap.after || legacyMap.error) { @@ -121,7 +121,7 @@ export class Feathers extends EventEmitter implements } if (Array.isArray(hookMap)) { - this.appHooks[HOOKS].push(...hookMap); + this.appHooks[HOOKS].push(...hookMap as any); } else { const methodHookMap = hookMap as HookMap, any>; diff --git a/packages/feathers/src/declarations.ts b/packages/feathers/src/declarations.ts index b827c0cbed..581144335b 100644 --- a/packages/feathers/src/declarations.ts +++ b/packages/feathers/src/declarations.ts @@ -183,7 +183,7 @@ export interface FeathersApplication { */ use ( path: L, - service: (keyof any extends keyof ServiceTypes ? ServiceInterface : ServiceTypes[L]) | Application, + service: keyof any extends keyof ServiceTypes ? ServiceInterface | Application : ServiceTypes[L], options?: ServiceOptions ): this; @@ -205,7 +205,7 @@ export interface FeathersApplication { * * @param map The application hook settings. */ - hooks (map: HookOptions, any>): this; + hooks (map: HookOptions): this; } // This needs to be an interface instead of a type @@ -309,7 +309,7 @@ export interface HookContext extends BaseHookContext> = - (this: S, context: HookContext) => (Promise | void> | HookContext | void); + (this: S, context: HookContext) => (Promise | void> | HookContext | void); type LegacyHookMethodMap = { [L in keyof S]?: SelfOrArray>; } &