【问题标题】:typescript error TS2304: Cannot find name AsyncIterator even with esnext打字稿错误 TS2304:即使使用 esnext 也找不到名称 AsyncIterator
【发布时间】:2019-02-13 13:57:49
【问题描述】:

我收到以下错误:

node_modules/@types/graphql/subscription/subscribe.d.ts(36,13): error TS2304: Cannot find name 'AsyncIterator'.
node_modules/@types/graphql/subscription/subscribe.d.ts(47,12): error TS2304: Cannot find name 'AsyncIterator'.
node_modules/@types/graphql/subscription/subscribe.d.ts(75,12): error TS2304: Cannot find name 'AsyncIterable'.
3:01:18 PM - Compilation complete. Watching for file changes.

即使将 esnext 添加到 tsconfig 文件:

{
    "compilerOptions": {
        "outDir": "./dist/",
        "lib": [
            "esnext",
            "esnext.asynciterable"
        ]
    },
    "include": [
        "./src/**/*"
    ]
}

有办法解决这个问题吗?

【问题讨论】:

  • 它对我有用。你怎么建?只是tsc -w?您确定您的tsconfig.json 文件正在被使用吗?如果您添加了无效的lib 值,例如"esnext.invalid",您会收到错误吗?
  • 是的,tsc -w。我刚刚重新启动了我的笔记本电脑,现在它正在工作!这很奇怪,在它不起作用之前我不明白为什么......

标签: typescript graphql


【解决方案1】:

我遇到了同样的错误。我已将项目依赖项更新到最新版本:

npm install -g npm-check-updates
ncu -u

以前的版本是:

 body-parser        ^1.18.1  →   ^1.19.0 
 express            ^4.15.4  →   ^4.17.1 
 reflect-metadata   ^0.1.10  →   ^0.1.13 
 @types/node       ^8.10.61  →  ^14.0.23 
 ts-node              3.3.0  →    8.10.2 
 typescript        3.3.3333  →     3.9.6 

【讨论】:

    猜你喜欢
    • 2017-12-01
    • 1970-01-01
    • 2021-12-05
    • 1970-01-01
    • 1970-01-01
    • 2020-07-15
    • 2020-01-29
    • 1970-01-01
    • 2017-06-18
    相关资源
    最近更新 更多