Попытка создать рабочую версию Express с Typescript - PullRequest
1 голос
/ 20 марта 2020

Я получаю эту ошибку ниже при запуске: npm run clear && tsc -P ./tsconfig.app.json && npm run post:build или tsc -p .

версия узла: v12.13.0 npm: v6.14.2 Express: 4

У кого-то уже есть такая же проблема?

> tsc -p .

node_modules/@types/readable-stream/index.d.ts:14:15 - error TS2417: Class static side 'typeof _Readable' incorrectly extends base class static side 'typeof Readable'.
  The types of '(new Stream.Readable.Duplex(...))._destroy' are incompatible between these types.
    Type '(err: Error | null, callback: (error: Error | null) => void) => void' is not assignable to type '(error: Error | null, callback: (error?: Error | undefined) => void) => void'.
      Types of parameters 'callback' and 'callback' are incompatible.
        Types of parameters 'error' and 'error' are incompatible.
          Type 'Error | null' is not assignable to type 'Error | undefined'.
            Type 'null' is not assignable to type 'Error | undefined'.

14 declare class _Readable extends stream.Readable {
                 ~~~~~~~~~

node_modules/@types/readable-stream/index.d.ts:88:9 - error TS2416: Property '_destroy' in type 'Duplex' is not assignable to the same property in base type 'Duplex'.
  Type '(err: Error | null, callback: (error: Error | null) => void) => void' is not assignable to type '(error: Error | null, callback: (error?: Error | undefined) => void) => void'.
    Types of parameters 'callback' and 'callback' are incompatible.
      Types of parameters 'error' and 'error' are incompatible.
        Type 'Error | null' is not assignable to type 'Error | undefined'.
          Type 'null' is not assignable to type 'Error | undefined'.

88         _destroy(err: Error | null, callback: (error: Error | null) => void): void;
           ~~~~~~~~

node_modules/@types/readable-stream/index.d.ts:88:9 - error TS2416: Property '_destroy' in type 'Duplex' is not assignable to the same property in base type 'Writable'.
  Type '(err: Error | null, callback: (error: Error | null) => void) => void' is not assignable to type '(error: Error | null, callback: (error?: Error | undefined) => void) => void'.
    Types of parameters 'callback' and 'callback' are incompatible.
      Types of parameters 'error' and 'error' are incompatible.
        Type 'Error | null' is not assignable to type 'Error | undefined'.
          Type 'null' is not assignable to type 'Error | undefined'.

88         _destroy(err: Error | null, callback: (error: Error | null) => void): void;
           ~~~~~~~~

node_modules/@types/readable-stream/index.d.ts:88:9 - error TS2416: Property '_destroy' in type 'Duplex' is not assignable to the same property in base type '_Readable'.
  Type '(err: Error | null, callback: (error: Error | null) => void) => void' is not assignable to type '(error: Error | null, callback: (error?: Error | undefined) => void) => void'.
    Types of parameters 'callback' and 'callback' are incompatible.
      Types of parameters 'error' and 'error' are incompatible.
        Type 'Error | null' is not assignable to type 'Error | undefined'.
          Type 'null' is not assignable to type 'Error | undefined'.

88         _destroy(err: Error | null, callback: (error: Error | null) => void): void;
           ~~~~~~~~

node_modules/@types/readable-stream/index.d.ts:102:11 - error TS2720: Class '_Readable.PassThrough' incorrectly implements class 'import("stream").PassThrough'. Did you mean to extend 'import("stream").PassThrough' and inherit its members as a subclass?
  Types of property '_destroy' are incompatible.
    Type '(err: Error | null, callback: (error: Error | null) => void) => void' is not assignable to type '(error: Error | null, callback: (error?: Error | undefined) => void) => void'.
      Types of parameters 'callback' and 'callback' are incompatible.
        Types of parameters 'error' and 'error' are incompatible.
          Type 'Error | null' is not assignable to type 'Error | undefined'.
            Type 'null' is not assignable to type 'Error | undefined'.

102     class PassThrough extends Transform implements stream.PassThrough {
              ~~~~~~~~~~~

node_modules/@types/readable-stream/index.d.ts:138:18 - error TS2749: 'StringDecoder' refers to a value, but is being used as a type here.

138         decoder: StringDecoder | null;
                     ~~~~~~~~~~~~~

node_modules/@types/readable-stream/index.d.ts:164:11 - error TS2720: Class '_Readable.Transform' incorrectly implements class 'import("stream").Transform'. Did you mean to extend 'import("stream").Transform' and inherit its members as a subclass?
  Types of property '_destroy' are incompatible.
    Type '(err: Error | null, callback: (error: Error | null) => void) => void' is not assignable to type '(error: Error | null, callback: (error?: Error | undefined) => void) => void'.
      Types of parameters 'callback' and 'callback' are incompatible.
        Types of parameters 'error' and 'error' are incompatible.
          Type 'Error | null' is not assignable to type 'Error | undefined'.
            Type 'null' is not assignable to type 'Error | undefined'.

164     class Transform extends Duplex implements stream.Transform {
              ~~~~~~~~~


Found 7 errors.

1 Ответ

1 голос
/ 09 апреля 2020

Попробуйте добавить

"@ types / node": "^ 12.12.7"

к devDependencies в пакете. json. затем,

npm install 

Это сработало для меня. Ура !!

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...