找不到名称'ReadableStream'

时间:2017-10-16 08:57:41

标签: javascript typescript webpack

我有一个使用@ types / whatwg-fetch版本0.0.32的项目。

运行我的项目时出现以下错误。

ERROR in <project-root>/node_modules/@types/whatwg-fetch/index.d.ts
(97,11): error TS2304: Cannot find name 'ReadableStream'.

我添加了@ types / whatwg-streams版本0.0.4,但它仍然失败并出现相同的错误。将whatwg-fetch压缩到最新的0.0.33,只是再犯了一行错误:

ERROR in /home/vojda/workspace/honeybee/acquisition/node_modules/@types/whatwg-fetch/index.d.ts
(32,44): error TS2304: Cannot find name 'ReadableStream'.

ERROR in /home/vojda/workspace/honeybee/acquisition/node_modules/@types/whatwg-fetch/index.d.ts
(102,20): error TS2304: Cannot find name 'ReadableStream'.

有人知道为什么会这样吗?

我认为它正在发生,因为某些东西正在缓存某些东西。我是这么认为的,因为当项目从另一台计算机上删除并从存储库重新克隆时,这个错误就消失了,但是在一段时间内再次显示出来。

如果需要,我会上传更多文件。

1 个答案:

答案 0 :(得分:0)

我认为你根本不需要引用@ types / whatwg-fetch,因为whatwg-fetch在全局范围内并且实现了已经在标准lib定义文件中定义的标准。我的项目没有使用任何@types来获取whatwg-fetch,而且我没有问题地引用ReadableStream。以下是另一个涉及此问题的问题的链接: whatwg-fetch new typescript 2.5.3