【问题标题】:Cannot find name 'ReadableStream'找不到名称“ReadableStream”
【发布时间】:2018-03-27 17:56:50
【问题描述】:

我有一个使用 @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'.

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

我想它正在发生是因为某些东西正在缓存某些东西。我想是的,因为当项目从另一台计算机中删除并从存储库中重新克隆时,此错误消失了,但过一段时间又出现了。

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

【问题讨论】:

标签: javascript typescript webpack


【解决方案1】:

我认为您根本不需要引用 @types/whatwg-fetch,因为 whatwg-fetch 在全局范围内并实现了标准库定义文件中已经定义的标准。我的项目没有为 whatwg-fetch 使用任何 @types,并且我毫无问题地引用了 ReadableStream。这是另一个讨论这个问题的链接: whatwg-fetch new typescript 2.5.3.

【讨论】:

    猜你喜欢
    • 2019-01-23
    • 1970-01-01
    • 2021-05-22
    • 2016-01-24
    • 1970-01-01
    • 2021-10-29
    • 2019-11-17
    • 2017-08-01
    相关资源
    最近更新 更多