尝试使用Typescript生成生产版本的Express。

3
当我运行以下命令时,出现以下错误:npm run clear && tsc -P ./tsconfig.app.json && npm run post:buildtsc -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.

你最近更新了Catalina的Mac吗? - coreDeviOS
1个回答

3

尝试在 package.json 的 devDependencies 中添加

"@types/node": "^12.12.7"

然后,

npm install 

这对我起作用了。干杯!


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接