gpt4 book ai didi

javascript - 找不到名称 'ReadableStream'(简单 git, Node )

转载 作者:行者123 更新时间:2023-11-30 11:15:13 27 4
gpt4 key购买 nike

我查看了所有互联网,但无法为我的新项目找到解决方案。我正在使用 simple-git 包,类型定义包括对 ReadableStream 的几个引用。 Typescript 在转译过程中出现错误(“找不到名称‘ReadableStream’”)。我进一步缩小了问题的范围,如下所示。

package.json

{
"name": "my-project",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"build": "./node_modules/.bin/tsc",
"watch": "./node_modules/.bin/tsc --watch"
},
"devDependencies": {
"@types/node": "^10.7.1",
"@types/yargs": "^11.1.1",
"typescript": "^3.0.1"
},
"dependencies": {
"fs": "0.0.1-security",
"simple-git": "^1.96.0",
"yargs": "^12.0.1"
}
}

tsconfig.json

{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"lib": [
"esnext"
],
"outDir": "./dist",
"rootDir": "./src",
"strict": true,
"noImplicitAny": true,
"strictNullChecks": false,
}
}

./src/index.ts

const s: ReadableStream = null;

...导致此错误:

> npm run build

src/index.ts:6:10 - error TS2304: Cannot find name 'ReadableStream'.

6 const s: ReadableStream= null;

最佳答案

estus 是对的。从最初的观点来看,它看起来像是 simple-git 类型定义中的一个错误。您可以提交错误。同时,在全局声明文件中编写 import ReadableStream = NodeJS.ReadableStream; 应该可以解决这个问题。

关于javascript - 找不到名称 'ReadableStream'(简单 git, Node ),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51884399/

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