【发布时间】:2020-09-08 20:23:32
【问题描述】:
我正在使用 node/typescript 为 Discord 开发一个机器人。当我在我的源代码上运行 typescript 编译器时,我收到了这个错误:
node_modules/@types/readable-stream/index.d.ts(13,15): error TS2417: Class static side 'typeof _Readable' incorrectly extends base class static side 'typeof Readable'.
The types of 'Stream.Readable.Writable' are incompatible between these types.
Type 'typeof _Readable.Writable' is not assignable to type 'typeof import("stream").Writable'.
Types of parameters 'options' and 'opts' are incompatible.
Type 'import("stream").WritableOptions' is not assignable to type '_Readable.WritableOptions'.
Type 'WritableOptions' is not assignable to type 'WritableStateOptions'.
Types of property 'defaultEncoding' are incompatible.
Type 'string' is not assignable to type 'BufferEncoding'.
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! Shattered-Star@1.0.0 tsc: `tsc`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the Shattered-Star@1.0.0 tsc script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
我尝试重新安装@types/node,因为这似乎是它来自的模块,但这并没有引起任何变化。据我所知,我的源代码都没有使用readable-streams 子模块。事实上,删除它解决了我的问题——我只想知道到底发生了什么。这是我的tsconfig.json,以防我在那里遗漏了什么:
{
"compilerOptions": {
"target": "es6",
"outDir": "built/",
"moduleResolution": "Node"
},
"include": [
"./bot/**/*"
]
}
我将不胜感激这方面的任何帮助。希望我不是唯一遇到这种情况的人。谢谢!
【问题讨论】:
-
我只是忘了'yarn',所以我把这个评论留给像我这样的其他白痴
标签: node.js typescript npm types