-
Notifications
You must be signed in to change notification settings - Fork 132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot find name 'AsyncIterator' error in Typescript compilation process. #83
Comments
Thanks for the workaround, I was having the same issue and adding the missing types have fixed the problem. But this is just a workaround, and it seems like those interfaces need to be in this project. |
I think we can use |
Thanks!! "compilerOptions": {
"lib": [
"esnext.asynciterable"
],
. . . to tsconfig.json file fixed the issue for good. |
If I add the |
@Parziphal, agree. I think this problem is there because of the fact that TypeScript has the default So, in order to fix that problem, you need to include all of the libraries that "es5",
"es6",
"dom",
"es2015.core",
"es2015.collection",
"es2015.generator",
"es2015.iterable",
"es2015.promise",
"es2015.proxy",
"es2015.reflect",
"es2015.symbol",
"es2015.symbol.wellknown",
"esnext.asynciterable" So, this solves the problem, - you just need to set the {
"compilerOptions": {
// ...
"lib": [
"es5",
"es6",
"dom",
"es2015.core",
"es2015.collection",
"es2015.generator",
"es2015.iterable",
"es2015.promise",
"es2015.proxy",
"es2015.reflect",
"es2015.symbol",
"es2015.symbol.wellknown",
"esnext.asynciterable"
]
},
// ...
} |
But the problem is, you have to make that change after every |
That works! 👍 |
Hrm, adding the big list of options to lib didn't work for me. I got a bunch of other errors
|
I should also note that the default library list changes when So, you should probably go here, find |
Hi guys I'm having the same problem: I tried to add |
I also faced with the same issue: adding "esnext" to the "lib" fixed my problem. https://github.com/graphcool-examples/angular-graphql/pull/8/files |
I also hit this issue twice. The first time adding the extra libs worked. The second time it didn't. I'm trying to run this example https://github.com/scaphold-io/angular4-apollo-client-starter-kit but no luck with the workaround. Is this going to be fixed in some way? |
This has become a major annoyance for me as well, having 'fixed' it a while ago but now it seems to be an issue again and no combination of "lib": [...] seems to work now |
+1 for major annoyance! |
This is becoming a real blocker now! I have added the So each projects compiles without errors, but when I import the other project then the build fails. What is going on here? Is there a fix on the way? It's been a couple of months now |
@flosky: could you be more specific with some code snippets maybe I can help.. |
Sure, thanks for the help. My main project uses the serverless package, which also includes the graphql types. I am not actually using them, thats why this is even more frustrating. I was running into the error when trying to transpile my code. I then followed the workaround suggestions and it worked. Here is the tsconfig.json
I also have another project (a logger module) that I would like to include into my main project. It is not affected by the bug here. I add the dependency to my my main projects package.json as a git link, like this:
the logger module runs tsc on postinstall. Now when I run
When I transpile the logger module directly, in its own repo then it works without problems. I only get this error when I reference the dependency in my main project. |
@flosky did you add "esnext.asynciterable" to the "lib" attribute in ts.config file of logger module? |
@ibraback Yes, I have. At first I removed it and it also worked as it is not using any types from graphql. But I have also added it again (the tsconfig.json is the same as I posted above), pushed the tag again, referenced the new tag in my main project, ran |
@flosky try to add |
@ibraback thanks it sort of worked. I had to add some more libs to make it work. This is my code: But what is the timeline to have this fixed? |
@flosky since adding |
FWIW, the only fix that worked for me was this exact TL;DR: the only thing in
|
I had the same problem and the following change to
Example tsconfig.json: {
"compilerOptions": {
"outDir": "./dist/",
"sourceMap": true,
"noImplicitAny": true,
"module": "commonjs",
"target": "es5",
"skipLibCheck": true,
"jsx": "react"
},
"include": [
"./src/**/*"
],
"lib": [
"esnext",
],
} |
I'm just getting started with typescript and I got this issue. Only I was missing AsyncIterable as well. Adding that interface gets rid of the compilation error but there has to be a more elegant fix. |
@schmidsi your config file has the error,
Probably after this fix you don't need to set the |
Fixes #127. I'm not exactly sure why this is necessary, but seeing reports of a similar issue in another lib apollographql/graphql-subscriptions#83
None of the solutions work :) |
Can you post your |
same issue as Morphexe heres my file |
Try |
@grantwwu thanks for the quick response. Tried that did not work https://github.com/brianalois/node_graphql_apollo_template |
I believe that if you try to compile a particular file, it does not use your |
Holy crap ... @grantwwu that was the fix for me too; just don't specify a |
// Polyfill Symbol.asyncIterator
(Symbol as any).asyncIterator = Symbol.asyncIterator || Symbol("Symbol.asyncIterator"); https://stackoverflow.com/questions/43258568/for-await-of-simple-example-typescript |
Installing Graphql types solved my case:
|
The only sane reply here. The question is, whether the |
@akomm Looking back on my earlier comment, I'm not sure why I was thinking about browsers at the time, since this library is primarily used in node.js (although I did find one client-side library, |
Yes. Since 10.3.0 it seems. |
Possibly related leebyron/iterall#49 |
This thread seems to be filled mostly with different ways to disable or get around TypeScript's type safety checking. Why anyone would want to do that is beyond me. Type safety checking is there for a reason, you guys. It tells you when you're making a mistake. Or when there's an unexpected compatibility issue. In my case, it told me that graphql-subscriptions v3 doesn't support |
I have found a difficulty compiling my Typescript code and it turns out that inside many files in graphql-subscriptions and subscriptions-transport-ws, the AsyncIterator iterator type interface is treated as defined, but the Typescript compiler doesn't agree with that. here is the list of errors:
I had found a temporary solution to bypass the errors by defining AsyncIterator type interface in every file involved in node_modules, here is the definition:
The text was updated successfully, but these errors were encountered: