Почему я не могу подключить файл typescript?

Вот я подключаю обработчик ошибок

import errorrHandler from './errors/ApiError';

и потом использую его в middlewares

app.use(errorrHandler);

вот код самого errorHandler

class ApiError extends Error{
         constructor(status, message) {
             super();
             this.status = status
             this.message = message
         }
     
         static badRequest(message) {
             return new ApiError(404, message)
         }
     
         static internal(message) {
             return new ApiError(500, message)
         }
     
         static forbidden(message) {
             return new ApiError(403, message)
         }
     }
     


export default new ApiError();

а вот ошибка:

/home/ihor/Test Task by Komah Ihor/node_modules/ts-node/src/index.ts:587
   return new TSError(diagnosticText, diagnosticCodes);
          ^
TSError: ⨯ Unable to compile TypeScript:
src/app.ts:22:9 - error TS2769: No overload matches this call.
 The last overload gave the following error.
   Argument of type 'ApiError' is not assignable to parameter of type 'PathParams'.
     Type 'ApiError' is missing the following properties from type '(string | RegExp)[]': length, pop, push, concat, and 26 more.

22 app.use(errorrHandler);
          ~~~~~~~~~~~~~

 node_modules/@types/express-serve-static-core/index.d.ts:160:5
   160     <
           ~
   161         P = ParamsDictionary,
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   ... 
   169         ...handlers: Array<RequestHandlerParams<P, ResBody, ReqBody, ReqQuery, Locals>>
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   170     ): T;
       ~~~~~~~~~
   The last overload is declared here.

   at createTSError (/home/ihor/Test Task by Komah Ihor/node_modules/ts-node/src/index.ts:587:12)
   at reportTSError (/home/ihor/Test Task by Komah Ihor/node_modules/ts-node/src/index.ts:591:19)
   at getOutput (/home/ihor/Test Task by Komah Ihor/node_modules/ts-node/src/index.ts:921:36)
   at Object.compile (/home/ihor/Test Task by Komah Ihor/node_modules/ts-node/src/index.ts:1189:32)
   at Module.m._compile (/home/ihor/Test Task by Komah Ihor/node_modules/ts-node/src/index.ts:1295:42)
   at Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
   at Object.require.extensions.<computed> [as .ts] (/home/ihor/Test Task by Komah Ihor/node_modules/ts-node/src/index.ts:1298:12)
   at Module.load (internal/modules/cjs/loader.js:933:32)
   at Function.Module._load (internal/modules/cjs/loader.js:774:14)
   at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
[nodemon] app crashed - waiting for file changes before starting...

Почему так происходит? Я не понимаю.


Ответы (0 шт):