【发布时间】:2019-01-23 20:20:43
【问题描述】:
我查看了所有互联网,但无法为我的新项目找到解决方案。我正在使用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 运行构建
src/index.ts:6:10 - 错误 TS2304:找不到名称“ReadableStream”。
6 const s: ReadableStream= null;
【问题讨论】:
标签: javascript node.js typescript typescript-typings