Typescript with Graphql error: cannot find name 'AsyncIterator'

Problem:

With @types/graphql installed on express server project, Typescript compilation throw error:

node_modules/@types/graphql/subscription/subscribe.d.ts(17,12): 
error TS2304: Cannot find name 'AsyncIterator'

Cause:

No lib for esnext.AsyncIterator

Solution:

add lib config to tsconfig.json

Notice: conflict between es6 and es2015.core
{
    "compilerOptions": {
        ......
        "lib": [
            "es5",
            "dom",
            "es2015.core",
            "es2015.collection",
            "es2015.generator",
            "es2015.iterable",
            "es2015.proxy",
            "es2015.reflect",
            "es2015.symbol",
            "es2015.symbol.wellknown",
            "esnext.asynciterable"
        ]
    },
}

https://github.com/apollographql/graphql-subscriptions/issues/83

你可能感兴趣的:(Typescript with Graphql error: cannot find name 'AsyncIterator')