Questions tagged [ecmascript-next]

For questions about upcoming ECMAScript features that are not scheduled to be part of a specific version yet (anything that is a stage 3 or lower proposal).

Proposals for new ECMAScript features follow a specific process, where they go through the following stages:

  • Stage 0 (Strawman)
  • Stage 1 (Proposal): The committee expects to devote time to examining the problem space, solutions and cross-cutting concerns
  • Stage 2 (Draft): The committee expects the feature to be developed and eventually included in the standard
  • Stage 3 (Candidate): The solution is complete and no further work is possible without implementation experience, significant usage and external feedback.
  • Stage 4 (Finished): The addition will be included in the soonest practical standard revision

Proposals in stage 4 are definitely added to one of the next releases of the language specification. This tag is for questions about proposals in stage 0 - stage 3.

Important Links:

379 questions
54
votes
3 answers

Decorators on functions

I see that babel.js decorators (available in "stage 1") implement the spec at https://github.com/wycats/javascript-decorators. It appears that decorators are limited to (1) classes, (2) accessors, and (3) methods. In my case, I want to use…
user663031
53
votes
9 answers

Is there a way to short circuit async/await flow?

async function update() { var urls = await getCdnUrls(); var metadata = await fetchMetaData(urls); var content = await fetchContent(metadata); await render(content); return; } //All the four functions return a promise. (getCdnUrls,…
sbr
  • 4,212
  • 5
  • 39
  • 45
53
votes
1 answer

Error using async/await in React Native

When trying to use async/await in react-native, I am getting the following error: uncaught error Error: SyntaxError: /Users/senthilsivanath/Documents/MusicTulip/index.ios.js: Unexpected token (50:23) 48 | renderScene: function(route,nav) { …
MusicMan
  • 866
  • 1
  • 6
  • 16
52
votes
5 answers

Correct use of arrow functions in React

I am using ReactJS with Babel and Webpack and using ES6 as well as the proposed class fields for arrow functions. I understand that arrow functions make things more efficient by not recreating the functions each render similar to how binding in the…
kojow7
  • 7,165
  • 11
  • 60
  • 109
41
votes
4 answers

Is it OK to put propTypes and defaultProps as static props inside React class?

This is the way I've been doing it for quite some time now: export default class AttachmentCreator extends Component { render() { return
} } AttachmentCreator.propTypes…
ffxsam
  • 20,847
  • 29
  • 72
  • 128
40
votes
2 answers

How do I await a list of Promises in JavaScript/TypeScript?

I have following code, fileStatsPromises is of Promise[], both foo and bar are Promise[]. What is the correct way to await them? I want to get []. const files = await readDir(currentDir); const fileStatsPromises =…
Zen
  • 4,187
  • 6
  • 24
  • 43
32
votes
2 answers

How to convert BigInt to Number in JavaScript?

I found myself in the situation where I wanted to convert a BigInt value to a Number value. Knowing that my value is a safe integer, how can I convert it?
Lucio Paiva
  • 13,507
  • 6
  • 71
  • 90
32
votes
4 answers

Alternative of Object.assign(...array)

Assume we have array of objects. Calling Object.assign(...array) makes an inheritance among those objects where object with index i override existing properties in object with index i-1 For example: var…
Abdennour TOUMI
  • 64,884
  • 28
  • 201
  • 207
32
votes
4 answers

Destructuring object and ignore one of the results

I have: const section = cloneElement(this.props.children, { className: this.props.styles.section, ...this.props, }); Inside this.props, I have a styles property that I don't want to pass to the cloned element. How can I do?
Fez Vrasta
  • 11,462
  • 19
  • 73
  • 135
28
votes
4 answers

While loops using Await Async.

This Javascript function seems to use the while loop in an asynchronous way. Is it the correct way to use while loops with asynchronous conditions? var Boo; var Foo = await getBar(i) while(Foo) { Boo = await getBar3(i) if (Boo) { …
28
votes
5 answers

Node.js assert.throws with async functions (Promises)

I want to check if an async function throws using assert.throws from the native assert module. I tried with const test = async () => await aPromise(); assert.throws(test); // AssertionError: Missing expected exception.. It (obviously?) doesn't work…
mattecapu
  • 857
  • 2
  • 8
  • 20
27
votes
6 answers

What is the shortest way to modify immutable objects using spread and destructuring operators

I'm looking for a pure function, to modify my immutable state object. The original state given as parameter must stay untouched. This is especially useful when working with frameworks like Redux and makes working with immutable object in javascript…
Tarion
  • 14,013
  • 11
  • 61
  • 98
27
votes
4 answers

Can async/await be used in constructors?

As the question stated. Will I be allowed to do this: class MyClass { async constructor(){ return new Promise() } }
wintercounter
  • 7,021
  • 5
  • 28
  • 42
26
votes
1 answer

using the ... spread syntax in javascript es6 named exports

I am attempting to import everything from a library as a hash, modify it, and re-export the modified hash, without knowing all of the named exports in a library. For example: import * as reactBootstrap from 'react-bootstrap'; wrappedReactBootstrap…
25
votes
7 answers

Destructure array to object property keys

I have an array of values like: const arr = [1,2,3]; Is there any way I can use destructuring to create the following output? If not, what is the easiest way I can do this in ES6 (or later)? const obj = { one: 1, two: 2, three: 3 }; I…
CodingIntrigue
  • 65,670
  • 26
  • 159
  • 166
1
2
3
25 26