Giter VIP home page Giter VIP logo

Comments (53)

 avatar commented on May 27, 2024 588

Thanks!!
By adding:

"compilerOptions": {
  "lib": [
     "esnext.asynciterable"
   ],
. . .

to tsconfig.json file fixed the issue for good.

from graphql-subscriptions.

comonadd avatar comonadd commented on May 27, 2024 88

@Parziphal, agree.

I think this problem is there because of the fact that TypeScript has the default "lib" option defined somewhere in the code.

So, in order to fix that problem, you need to include all of the libraries that "lib" option contains by default.
Those are:

"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 "lib" TypeScript compiler option to the array of default libraries concatenaed with the "esnext.asynciterable" library, like this:

{
  "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"
    ]
  },
  // ...
}

from graphql-subscriptions.

legacy-account avatar legacy-account commented on May 27, 2024 81

I also faced with the same issue:

adding "esnext" to the "lib" fixed my problem.
"lib": ["es6", "dom", "esnext"],

https://github.com/graphcool-examples/angular-graphql/pull/8/files

from graphql-subscriptions.

veeramarni avatar veeramarni commented on May 27, 2024 56

I think we can use esnext lib to fix this issue. See below link

#77

from graphql-subscriptions.

Parziphal avatar Parziphal commented on May 27, 2024 27

If I add the lib array to compilerOptions, I get hundreds of errors because everything breaks (even Date becomes unavailable). Adding the interface to the files where the error occurs fixed the problem.

from graphql-subscriptions.

flosky avatar flosky commented on May 27, 2024 23

+1 for major annoyance!

from graphql-subscriptions.

schmidsi avatar schmidsi commented on May 27, 2024 15

I had the same problem and the following change to tsconfig.json did the trick:

  • Add skipLibCheck: true to compilerOptions

Example tsconfig.json:

{
  "compilerOptions": {
    "outDir": "./dist/",
    "sourceMap": true,
    "noImplicitAny": true,
    "module": "commonjs",
    "target": "es5",
    "skipLibCheck": true,
    "jsx": "react"
  },
  "include": [
    "./src/**/*"
  ],
  "lib": [
    "esnext",
  ],
}

from graphql-subscriptions.

mpicard avatar mpicard commented on May 27, 2024 10

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

from graphql-subscriptions.

eajitesh avatar eajitesh commented on May 27, 2024 5

There are two tsconfig.json (one in root folder and another in src/ folder) files when working with an Angular app installed with CLI. The problem gets fixed when I put "esnext" within src/tsconfig.json:

"lib": [ "es2015", "dom", "esnext" ]

from graphql-subscriptions.

comonadd avatar comonadd commented on May 27, 2024 4

I should also note that the default library list changes when compilerOptions.target gets changed.

So, you should probably go here, find --lib option, and look at the defaults which fit your needs.

from graphql-subscriptions.

leebenson avatar leebenson commented on May 27, 2024 4

FWIW, the only fix that worked for me was this exact tsconfig.json:

TL;DR: the only thing in lib is esnext -- esnext.asynciterable alone yielded the following error:

error TS2318: Cannot find global type 'Boolean'.
error TS2318: Cannot find global type 'Function'.
error TS2318: Cannot find global type 'Number'.
error TS2318: Cannot find global type 'Object'.
error TS2318: Cannot find global type 'RegExp'.

{
  "compilerOptions": {
    /* Basic Options */
    "target": "ES2017",                       /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */
    "module": "commonjs",                     /* Specify module code generation: 'none', commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
    "lib": [                                  /* Specify library files to be included in the compilation:  */
      "esnext"
    ],                             
    // "allowJs": true,                       /* Allow javascript files to be compiled. */
    // "checkJs": true,                       /* Report errors in .js files. */
    // "jsx": "preserve",                     /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
    // "declaration": true,                   /* Generates corresponding '.d.ts' file. */
    // "sourceMap": true,                     /* Generates corresponding '.map' file. */
    // "outFile": "./",                       /* Concatenate and emit output to single file. */
    "outDir": "./dist",                        /* Redirect output structure to the directory. */
    // "rootDir": "./",                       /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
    "removeComments": true,                /* Do not emit comments to output. */
    // "noEmit": true,                        /* Do not emit outputs. */
    // "importHelpers": true,                 /* Import emit helpers from 'tslib'. */
    // "downlevelIteration": true,            /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
    // "isolatedModules": true,               /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */

    /* Strict Type-Checking Options */
    "strict": true,                            /* Enable all strict type-checking options. */
    // "noImplicitAny": true,                 /* Raise error on expressions and declarations with an implied 'any' type. */
    // "strictNullChecks": true,              /* Enable strict null checks. */
    // "noImplicitThis": true,                /* Raise error on 'this' expressions with an implied 'any' type. */
    // "alwaysStrict": true,                  /* Parse in strict mode and emit "use strict" for each source file. */

    /* Additional Checks */
    "noUnusedLocals": true,                /* Report errors on unused locals. */
    "noUnusedParameters": true            /* Report errors on unused parameters. */
    // "noImplicitReturns": true,             /* Report error when not all code paths in function return a value. */
    // "noFallthroughCasesInSwitch": true,    /* Report errors for fallthrough cases in switch statement. */

    /* Module Resolution Options */
    // "moduleResolution": "node",            /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
    // "baseUrl": "./",                       /* Base directory to resolve non-absolute module names. */
    // "paths": {},                           /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
    // "rootDirs": [],                        /* List of root folders whose combined content represents the structure of the project at runtime. */
    // "typeRoots": [],                       /* List of folders to include type definitions from. */
    // "types": [],                           /* Type declaration files to be included in compilation. */
    // "allowSyntheticDefaultImports": true,  /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
    // "preserveSymlinks": true,              /* Do not resolve the real path of symlinks. */

    /* Source Map Options */
    // "sourceRoot": "./",                    /* Specify the location where debugger should locate TypeScript files instead of source locations. */
    // "mapRoot": "./",                       /* Specify the location where debugger should locate map files instead of generated locations. */
    // "inlineSourceMap": true,               /* Emit a single file with source maps instead of having a separate file. */
    // "inlineSources": true,                 /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */

    /* Experimental Options */
    // "experimentalDecorators": true,        /* Enables experimental support for ES7 decorators. */
    // "emitDecoratorMetadata": true,         /* Enables experimental support for emitting type metadata for decorators. */
  }
}

from graphql-subscriptions.

Morphexe avatar Morphexe commented on May 27, 2024 4

None of the solutions work :)
Adding EsNext does nothing for me, throws the error on browser.

from graphql-subscriptions.

flosky avatar flosky commented on May 27, 2024 3

This is becoming a real blocker now!

I have added the lib stuff to the tsconfig.json and it compiles without error. But now I am loading another module via package.json that we have written ourselves (which compiles itself without errors) and it breaks the npm install with the same AsyncIterator Error.

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

from graphql-subscriptions.

mbrowne avatar mbrowne commented on May 27, 2024 3

Just adding esnext.asynciterable worked for me:

"lib": ["es6", "esnext.asynciterable", "dom"],

from graphql-subscriptions.

dsebastien avatar dsebastien commented on May 27, 2024 3

I stumbled upon this issue while trying the hello world tutorial for Apollo with TypeScript.
Indeed just adding esnext.asynciterable fixed the issue

from graphql-subscriptions.

tal avatar tal commented on May 27, 2024 2

Hrm, adding the big list of options to lib didn't work for me. I got a bunch of other errors

node_modules/apollo-client/transport/afterware.d.ts(4,15): error TS2304: Cannot find name 'Response'.
node_modules/apollo-client/transport/afterware.d.ts(5,14): error TS2304: Cannot find name 'RequestInit'.
node_modules/apollo-client/transport/afterware.d.ts(11,16): error TS2304: Cannot find name 'Response'.
node_modules/apollo-client/transport/afterware.d.ts(12,14): error TS2304: Cannot find name 'RequestInit'.
node_modules/apollo-client/transport/batchedNetworkInterface.d.ts(8,14): error TS2304: Cannot find name 'RequestInit'.
node_modules/apollo-client/transport/batchedNetworkInterface.d.ts(11,16): error TS2304: Cannot find name 'Response'.
node_modules/apollo-client/transport/batchedNetworkInterface.d.ts(12,14): error TS2304: Cannot find name 'RequestInit'.
node_modules/apollo-client/transport/batchedNetworkInterface.d.ts(22,20): error TS2304: Cannot find name 'RequestInit'.
node_modules/apollo-client/transport/batchedNetworkInterface.d.ts(36,12): error TS2304: Cannot find name 'RequestInit'.
node_modules/apollo-client/transport/middleware.d.ts(5,14): error TS2304: Cannot find name 'RequestInit'.
node_modules/apollo-client/transport/middleware.d.ts(12,14): error TS2304: Cannot find name 'RequestInit'.
node_modules/apollo-client/transport/networkInterface.d.ts(35,12): error TS2304: Cannot find name 'RequestInit'.
node_modules/apollo-client/transport/networkInterface.d.ts(43,14): error TS2304: Cannot find name 'RequestInit'.
node_modules/apollo-client/transport/networkInterface.d.ts(46,15): error TS2304: Cannot find name 'Response'.
node_modules/apollo-client/transport/networkInterface.d.ts(47,14): error TS2304: Cannot find name 'RequestInit'.
node_modules/apollo-client/transport/networkInterface.d.ts(54,12): error TS2304: Cannot find name 'RequestInit'.
node_modules/apollo-client/transport/networkInterface.d.ts(55,49): error TS2304: Cannot find name 'RequestInit'.
node_modules/apollo-client/transport/networkInterface.d.ts(63,77): error TS2304: Cannot find name 'Response'.
node_modules/apollo-client/transport/networkInterface.d.ts(70,12): error TS2304: Cannot find name 'RequestInit'.

from graphql-subscriptions.

yuhr avatar yuhr commented on May 27, 2024 2

Thanks to @leebenson. All I had to have was only "esnext".

from graphql-subscriptions.

ooade avatar ooade commented on May 27, 2024 2

@danielpa9708 just esnext alone saves the day. But don't know if there's any performance loss by doing that.

from graphql-subscriptions.

daniele-zurico avatar daniele-zurico commented on May 27, 2024 1

Hi guys I'm having the same problem:
ERROR in /Users/danielezurico/Downloads/angular-graphql-master/quickstart-with-apollo/node_modules/@types/graphql/subscription/subscribe.d.ts (17,4): Cannot find name 'AsyncIterator'. ERROR in /Users/danielezurico/Downloads/angular-graphql-master/quickstart-with-apollo/node_modules/@types/graphql/subscription/subscribe.d.ts (29,4): Cannot find name 'AsyncIterable'.

I tried to add
"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" ]
my package.json is:
https://github.com/graphcool-examples/angular-graphql/blob/master/quickstart-with-apollo/package.json

from graphql-subscriptions.

jspri avatar jspri commented on May 27, 2024 1

My local environment (node 6) doesn't yet support AsyncIterables so I believe putting it in tsconfig:lib is incorrect and could lead to other parts of the project compiling when they shouldn't.

This project should define AsyncIterator with a compatible definition instead of relying on the definition from the library. This will also make less peoples projects break when they use your project.

from graphql-subscriptions.

mbrowne avatar mbrowne commented on May 27, 2024 1

Note that there is a small risk with using "esnext" instead of "esnext.asynciterable" specifically: "esnext" will allow you to use any new JS features supported by TypeScript regardless of whether or not you have a polyfill for them. So be mindful of which ES2016+ features you're using and use something like https://polyfill.io if you want broad browser support.

from graphql-subscriptions.

vksgautam1 avatar vksgautam1 commented on May 27, 2024 1
 "esnext.asynciterable"

including it giving me error

" let wopt: WatchQueryOptions;
wopt = {
fetchPolicy: 'network-only',//FetchPolicy,//'cache-and-network',
query: type,
variables: params
}
this.apollo.
watchQuery(wopt)
.valueChanges
.subscribe((val) => {
}

(in promise): TypeError: Object(...) is not a function
TypeError: Object(...) is not a function"

from graphql-subscriptions.

ilyaskarim avatar ilyaskarim commented on May 27, 2024 1

Installing Graphql types solved my case:

npm install --save-dev @types/graphql

from graphql-subscriptions.

akomm avatar akomm commented on May 27, 2024 1

Note that there is a small risk with using "esnext" instead of "esnext.asynciterable" specifically: "esnext" will allow you to use any new JS features supported by TypeScript regardless of whether or not you have a polyfill for them. So be mindful of which ES2016+ features you're using and use something like https://polyfill.io if you want broad browser support.

The only sane reply here. The question is, whether the graphql library uses the feature or just produces a polyfilled fake of the interface. If the later is the case, adding es2018.asynciterable or esnext.asynciterable to lib in tsconfig.json is okay. If the former is the case, you need to polyfill the feature.

from graphql-subscriptions.

veeramarni avatar veeramarni commented on May 27, 2024

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.

from graphql-subscriptions.

 avatar commented on May 27, 2024

But the problem is, you have to make that change after every npm install...

from graphql-subscriptions.

joseluisq avatar joseluisq commented on May 27, 2024

That works! πŸ‘

from graphql-subscriptions.

adrianmoya avatar adrianmoya commented on May 27, 2024

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?

from graphql-subscriptions.

 avatar commented on May 27, 2024

@flosky: could you be more specific with some code snippets maybe I can help..

from graphql-subscriptions.

flosky avatar flosky commented on May 27, 2024

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

{
  "compilerOptions": {
    "module": "commonjs",
    "noImplicitAny": false,
    "removeComments": true,
    "preserveConstEnums": true,
    "outDir": "build",
    "allowJs": true,
    "target": "es2015",
    "sourceMap": true,
    "baseUrl": "./",
    "paths": {
      "*": [ "node_modules/@types/*", "*"]
    },
    "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"
    ]
  },
  "exclude": [
    "node_modules",
    "coverage",
    "build",
    ".git"
  ]
}

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:

"logger": "git+https://<secret>[email protected]/xyz/logger.git#1.1.1"

the logger module runs tsc on postinstall. Now when I run npm install on my main project, I get this error message:

> [email protected] postinstall /Users/flo/Workspace/stockLoader/node_modules/spawn-sync
> node postinstall


> [email protected] postinstall /Users/flo/Workspace/stockLoader/node_modules/logger
> tsc lib/index.ts --outDir build/lib -d --pretty


17 ): AsyncIterator<ExecutionResult>;
      ~~~~~~~~~~~~~

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

/Users/flo/Workspace/stockLoader/node_modules/typescript/lib/tsc.js:2062
            throw e;
            ^

Error: Debug Failure. False expression.
    at computePositionOfLineAndCharacter (/Users/flo/Workspace/stockLoader/node_modules/typescript/lib/tsc.js:3752:22)
    at Object.getPositionOfLineAndCharacter (/Users/flo/Workspace/stockLoader/node_modules/typescript/lib/tsc.js:3742:16)
    at Object.formatDiagnosticsWithColorAndContext (/Users/flo/Workspace/stockLoader/node_modules/typescript/lib/tsc.js:55575:59)
    at reportDiagnosticWithColorAndContext (/Users/flo/Workspace/stockLoader/node_modules/typescript/lib/tsc.js:58771:25)
    at reportDiagnostic (/Users/flo/Workspace/stockLoader/node_modules/typescript/lib/tsc.js:58733:9)
    at reportDiagnostics (/Users/flo/Workspace/stockLoader/node_modules/typescript/lib/tsc.js:58738:13)
    at compileProgram (/Users/flo/Workspace/stockLoader/node_modules/typescript/lib/tsc.js:59099:13)
    at compile (/Users/flo/Workspace/stockLoader/node_modules/typescript/lib/tsc.js:59051:26)
    at performCompilation (/Users/flo/Workspace/stockLoader/node_modules/typescript/lib/tsc.js:58940:33)
    at Object.executeCommandLine (/Users/flo/Workspace/stockLoader/node_modules/typescript/lib/tsc.js:58883:9)
    at Object.<anonymous> (/Users/flo/Workspace/stockLoader/node_modules/typescript/lib/tsc.js:59241:4)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/flo/Workspace/stockLoader/node_modules/typescript/bin/tsc:2:1)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.runMain (module.js:604:10)
    at run (bootstrap_node.js:389:7)
    at startup (bootstrap_node.js:149:9)
    at bootstrap_node.js:504:3

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.

from graphql-subscriptions.

 avatar commented on May 27, 2024

@flosky did you add "esnext.asynciterable" to the "lib" attribute in ts.config file of logger module?

from graphql-subscriptions.

flosky avatar flosky commented on May 27, 2024

@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 npm install again but same error

from graphql-subscriptions.

 avatar commented on May 27, 2024

@flosky try to add --lib esnext.asynciterable parameter to the tsc lib/index.ts --outDir build/lib -d --pretty command.

from graphql-subscriptions.

flosky avatar flosky commented on May 27, 2024

@ibraback thanks it sort of worked. I had to add some more libs to make it work. This is my code: "postinstall": "tsc lib/index.ts --outDir build/lib -d --pretty --lib es2015,dom,esnext.asynciterable",.

But what is the timeline to have this fixed?

from graphql-subscriptions.

 avatar commented on May 27, 2024

@flosky since adding esnext.asynciterable to tsconfig file fixed the problem for the majority I don't think there is something to add/fix, but always upgrade your dependencies just in case...

from graphql-subscriptions.

motss avatar motss commented on May 27, 2024

This works for me: tsc index.ts --lib esnext,esnext.asynciterable

from graphql-subscriptions.

jspri avatar jspri commented on May 27, 2024

Is this a problem with the original definition file? Do asynciterables need to exist in the runtime? Is there a polyfill somewhere? Is there a way this could be changed so that it just works?

from graphql-subscriptions.

mbrowne avatar mbrowne commented on May 27, 2024

The AsyncIterator type is used in the code for this repo, so my guess is that this would need to be updated on the TypeScript end. Async iterators are already a stage 3 proposal for ECMAScript, which hopefully means TypeScript will add support for them by default soon, but since they require in-browser support as well I'm not sure; maybe it will take much longer. Perhaps someone here can point you to more info on this, or you could search discussions in the TypeScript repo.

from graphql-subscriptions.

mbrowne avatar mbrowne commented on May 27, 2024

I am not a contributor to this library so this is not official advice, but if I were you I would create a new issue about this (with a link to this one) rather than waiting for this issue to be reopened.

from graphql-subscriptions.

 avatar commented on May 27, 2024

I had a similar issue. I was trying to integrate Apollo in typescript project using awesome typescript loader which turned out to be the source of the problem. After switching back to ts-lint loader all worked nice.
However, using the (a bit optimised) solution from mbrowne did the trick also with awesome typescript loader, but I don't like extra configs just to please an issue :)

from graphql-subscriptions.

danielpza avatar danielpza commented on May 27, 2024

tsconfig.json

"lib": [
  // "esnext"
  "esnext.asynciterable"
],
$ tsc -p .
error TS2318: Cannot find global type 'Boolean'.
error TS2318: Cannot find global type 'Function'.
error TS2318: Cannot find global type 'Number'.
error TS2318: Cannot find global type 'Object'.
error TS2318: Cannot find global type 'RegExp'.

from graphql-subscriptions.

charlieg-nuco avatar charlieg-nuco commented on May 27, 2024

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.

from graphql-subscriptions.

niba avatar niba commented on May 27, 2024

@schmidsi your config file has the error, lib should be inside compilerOptions. The correct configuration is

{
  "compilerOptions": {
    "outDir": "./dist/",
    "sourceMap": true,
    "noImplicitAny": true,
    "module": "commonjs",
    "target": "es5",
    "skipLibCheck": true,
    "jsx": "react",
    "lib": [
       "esnext",
     ],
  },
  "include": [
    "./src/**/*"
  ],
 
}

Probably after this fix you don't need to set the skipLibCheck to true anymore

from graphql-subscriptions.

grantwwu avatar grantwwu commented on May 27, 2024

Can you post your tsconfig.json?

from graphql-subscriptions.

brianschardt avatar brianschardt commented on May 27, 2024

same issue as Morphexe heres my file
{
"compilerOptions": {
"target": "es6",
"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"
],
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"declaration": false,
"outDir": "dist",
"typeRoots": ["node_modules/@types"]
},
"files": ["src/app.ts"],
"exclude": ["node_modules"]
}

from graphql-subscriptions.

grantwwu avatar grantwwu commented on May 27, 2024

Try
"esModuleInterop": true as an entry in compilerOptions

from graphql-subscriptions.

brianschardt avatar brianschardt commented on May 27, 2024

@grantwwu thanks for the quick response. Tried that did not work
Here is the repo I want to run
tsc src/app.ts

https://github.com/brianalois/node_graphql_apollo_template

from graphql-subscriptions.

grantwwu avatar grantwwu commented on May 27, 2024

I believe that if you try to compile a particular file, it does not use your tsconfig.json. Try just running tsc at the root of your project. I was able to compile it fine there, after npm install --save-dev @graphql/types

from graphql-subscriptions.

switch120 avatar switch120 commented on May 27, 2024

Holy crap ... @grantwwu that was the fix for me too; just don't specify a .ts file. I would never have just tried that. Ugh!

from graphql-subscriptions.

zgldh avatar zgldh commented on May 27, 2024
// Polyfill Symbol.asyncIterator
(Symbol as any).asyncIterator = Symbol.asyncIterator || Symbol("Symbol.asyncIterator");

https://stackoverflow.com/questions/43258568/for-await-of-simple-example-typescript

from graphql-subscriptions.

mbrowne avatar mbrowne commented on May 27, 2024

@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, graphql-genie-client, for which graphql-subscriptions is a dependency, but I don't think it's very widely used). But as far as I can tell, full support of async iterators isn't needed (probably thanks to this library's use of the iterall library)β€”it's only a TypeScript issue. If I recall correctly, I successfully ran graphql-subscriptions on node 8 in the past (and the @types/node version seems to indicate it's compatible with node 8). BTW, async iterators are supported natively in node 10+.

from graphql-subscriptions.

akomm avatar akomm commented on May 27, 2024

Yes. Since 10.3.0 it seems.

from graphql-subscriptions.

OmgImAlexis avatar OmgImAlexis commented on May 27, 2024

Possibly related leebyron/iterall#49

from graphql-subscriptions.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.