saurabh vats
saurabh vats

Reputation: 369

cannot find name __values

I am trying to run an example built in using typescript(using version 2.6) of async iterator through browser.

`

function* countAppleSales () {
  var saleList = [3, 7, 5];
  for (var i = 0; i < saleList.length; i++) {
    yield saleList[i];
  }
}
for(let val of countAppleSales())
    console.log(val);

async function* asyncRandomNumbers() {
    // This is a web service that returns a random number
    const url = 'https://www.random.org/decimal-fractions/?num=1&dec=10&col=1&format=plain&rnd=new';

    while (true) {
      const response = await fetch(url);
      const text = await response.text();
      yield Number(text);
    }
  }

  async function example() {
    for await (const number of asyncRandomNumbers()) {
      console.log(number);
      if (number > 0.95) break;
    }
  }

  example();

  console.log('we are after await')

;`

above code is running fine in browser but am getting error cannot find name __values logged in console.log.

below is the type script configuration file am using:

   {
  "compilerOptions": {
      "module": "es2015",
      "types": [
        "node"
       ],
     // typeRoots option has been previously configured
     "typeRoots": [
        // add path to @types
        "node_modules/@types"
     ],
      "target": "es6",
      "noImplicitAny": false,
      "downlevelIteration": false,
      "sourceMap": true,
      "moduleResolution": "node",
      "watch": true,
      "experimentalDecorators": true,
      "emitDecoratorMetadata": true,
      //"noEmitHelpers": true,
      "skipDefaultLibCheck": true,
      "strictNullChecks": false,
      "outDir": "tmp",
      //"lib":["es2017","es2015","es2016","es2015.generator","esnext","dom","esnext.asynciterable"]
      "lib": [ "es2017","dom","es2015.generator","es2015","es2015.iterable","esnext.asynciterable","esnext"]
  },
  "allowSyntheticDefaultImports":true,
  "baseUrl": ".",

  "paths": {
    "lodash/*": [
      "node_modules/@types/lodash-es/*"
    ]},

    "awesomeTypescriptLoaderOptions": {
      "useBabel": true,
      "useCache": true
    },
  "include": [
    "src",
    "test"
],
"exclude": [
    "node_modules",
    "typings"
]
}

please can anybody help with this issue

Upvotes: 1

Views: 162

Answers (1)

saurabh vats
saurabh vats

Reputation: 369

this issue is resolved now, Issue is due to copy pasting typescript loader rules configuration twice in webpack configuration file. webpack error needs to be more specific though.

Upvotes: 1

Related Questions