Questions tagged [ecmascript-2017]

Use this tag for questions about features finalized in ECMAScript 2017. Do *not* use this tag if the code in question merely *uses* one of the features, *unless* the feature is cause of the problem.

Proposals finalized in 2017 include:

387 questions
15
votes
1 answer

Difference in the 'lib' property in tsconfig.json between es6 and es2017?

I've been researching what the possible values of the lib property mean in the compilerOptions found within the tsconfig.json file. I found on the Typescript GitHub page the relevant d.ts files corresponding to those values and apparently by using…
15
votes
3 answers

Catching errors from nested async/await functions

I have a function chain in a node 4.3 script that looks something like, callback -> promise -> async/await -> async/await -> async/await like so: const topLevel = (resolve, reject) => { const foo = doThing(data) .then(results => { …
Brandon
  • 7,736
  • 9
  • 47
  • 72
14
votes
2 answers

Console.log doesn't work in async function

I'm trying to log a statement in an async function as follows: async generateCharts (insights) { const { url } = await this.reportsClient.createReport(insights) console.log('url from reports', url) return this.parse(url) } Log statement…
SamAko
  • 3,485
  • 7
  • 41
  • 77
13
votes
3 answers

async function with the class in javascript

I have create a class in nodejs class ApnService { sendNotification(deviceType, deviceToken, msg, type, id) { try { const note = await apnProvider.send(note, deviceToken) console.log(note) } catch (err) { …
13
votes
2 answers

ES2017 Async/await functions - do they work only with promises?

I started using async/await ES7 functions in my js applications (transpiled by Babel). Correct me if wrong, but do they work only with Promises? If yes, this means that I need to wrap regular callback functions into Promises (what I'm currently…
Kosmetika
  • 20,774
  • 37
  • 108
  • 172
12
votes
4 answers

Get firebase.auth().currentUser with async/await

I successfully check user's authentication state with onAuthStateChange observer and redirect user to the Dashboard page (react-native project). However, on the dashboard I already want to show some user specific data, e.g. enrolled…
12
votes
2 answers

Compile typescript without transpiling async functions

Is there a way to use the TypeScript compiler only to remove type annotations, but not transpiling async functions? Something like a { target: 'esInfinite' } option? The reason is: There are browsers that already support async functions, so I wish…
Tamas Hegedus
  • 28,755
  • 12
  • 63
  • 97
10
votes
2 answers

Can I detect async/await available in browser?

As title, how can I detect async/await es7 support in browser? Is that possible?
3142 maple
  • 865
  • 2
  • 11
  • 27
10
votes
4 answers

How is async/await working in serial and parallel?

I have two async functions. Both of them are waiting for two 3 seconds function calls. But the second one is faster than the first. I think the faster one is running in parallel and other in serial. Is my assumption correct? If yes, why is this…
Vadakkumpadath
  • 1,445
  • 13
  • 21
9
votes
2 answers

JS: Handle with find() property undefined

I have a method which returns a value from an element in the array. Not all the elements have the property I want to return. I would like to do this function with one line using the method find(). I've tried this way to solve it:…
Joan
  • 233
  • 1
  • 5
  • 17
9
votes
1 answer

Babel ESLint: TypeError: Cannot read property 'range' of null

I use babel-eslint to lint/fix my code. Worked great until I wanted to adopt some ES2017 async await found overhere. I changed my React app accordingly, allbeit slightly different: The relevant part of my index.js: async function renderApp() { …
Dani
  • 2,448
  • 8
  • 27
  • 44
8
votes
1 answer

karma-typescript: import JS file with Async keyword

I'm using karma-typescript, with this karma config file : karmaTypescriptConfig: { compilerOptions: { target: "es5", lib: ["dom", "es2015", "es2017"] }, bundlerOptions: { transforms: [require("karma-typescript-es6-transform")()] …
Menencia
  • 1,289
  • 1
  • 12
  • 23
8
votes
3 answers

Why `async/await` doesn't work in my case?

I read about async/await, but I've a critical question. At first I explain an old example to show base of my question and then I ask my exact question. Everybody know it: console.log('1'); console.log('2'); console.log('3'); // Ex: 123 It is simple…
user9289032
8
votes
1 answer

Getting an undefined "this" when using Classes/Async Await

I've just started to experiment with classes and async await. I'm using Node version 8.9.0 (LTS). When I console.log(this), I get undefined instead of the reference to the object. subhandler.js class Handler { constructor(props) { …
cusejuice
  • 10,285
  • 26
  • 90
  • 145
8
votes
2 answers

Recursively calling an asynchronous API call

I'm trying to fetch data from an API that only returns 1000 items per call, and I want to do this recursively until I have all the data. I don't know beforehand how many items there are in total, so after every call I have to check If the call was…
Stephan Muller
  • 27,018
  • 16
  • 85
  • 126