gpt4 book ai didi

node.js - 尝试使用 Typescript 生成 Express 的生产版本

转载 作者:行者123 更新时间:2023-12-04 10:22:41 26 4
gpt4 key购买 nike

我在运行时遇到以下错误:npm run clear && tsc -P ./tsconfig.app.json && npm run post:buildtsc -p .

Node 版本:v12.13.0npm: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.

最佳答案

尝试添加

"@types/node": "^12.12.7"

到 package.json 中的 devDependencies。然后,

npm install 

它对我有用。干杯!!

关于node.js - 尝试使用 Typescript 生成 Express 的生产版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60773927/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com