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
12
votes
3 answers

Is the constructor still needed in React with autobinding and property initializers

I am refactoring an es6 class based React component that uses the normal constructor, and then binds methods, and defines state/attributes within that constructor. Something like this: class MySpecialComponent extends React.Component { …
Max Millington
  • 3,842
  • 4
  • 20
  • 32
12
votes
1 answer

Adding a key from a variable string (es6) when using spread syntax

I would like to know if there is a clean way to set the value of a key from a string variable when using spread syntax in es6? Something like the following: let keyVar = 'newKey' let newObject = {keyVar:{some:'json'},...oldObject} But this leads…
JasoonS
  • 1,352
  • 2
  • 12
  • 25
11
votes
1 answer

Raising function * into async function *?

Suppose I have a function that takes a generator and returns another generator of the first n elements: const take = function * (n, xs) { console.assert(n >= 0); let i = 0; for (const x of xs) { if (i == n) { break; } yield…
sdgfsdh
  • 24,047
  • 15
  • 89
  • 182
11
votes
1 answer

Spread syntax ES6 with statement

I tried to write ternary operator with spread syntax and copy two objects. Is it possible to use ternary operator with spread syntax inside with literal objects? My code works okay, I just want to optimize it. hintStyle: disabled ?…
Palaniichuk Dmytro
  • 2,041
  • 3
  • 26
  • 53
11
votes
1 answer

Difference between Object.assign and object spread

Having var obj = { a: 1, b: 2}; What are the differences between obj = Object.assign(obj, { c: 3}); And obj = {...obj, c: 3 };
Marco Scabbiolo
  • 5,805
  • 3
  • 37
  • 43
11
votes
3 answers

Is it OK to use async/await almost everywhere?

I'm currently writing small NodeJS CLI tool for personal usage and I've decided to try ES7 async/await feature with Babel. It's a network tool so I obviously have asynchronous network requests. I wrote a simple wrapper for request package: export…
user0103
  • 1,130
  • 2
  • 16
  • 35
10
votes
2 answers

Javascript class methods versus properties

I've seen code using Javascript classes use the following form (example is React): class UserProfile extends Component { state = { open: false } handleOpen = () => { this.setState({ open: true }) } } Why is handleOpen implemented…
rhlsthrm
  • 657
  • 1
  • 8
  • 21
10
votes
1 answer

What should happen with `await` when the expression after the keyword does not evaluate to promise?

I have a ES7 code like this. async function returnsfive() { var three = 3; var threeP = await three; return threeP+2; } returnsfive().then(k=>console.log(k), e=>console.error("err", e)) What should happen at the var threeP = await three…
Karel Bílek
  • 32,538
  • 28
  • 83
  • 137
10
votes
1 answer

Async/Await not waiting

I'm running into an issue which I don't fully understand. I feel like there are likely concepts which I haven't grasped, code that could be optimized, and possibly a bug thrown in for good measure. To greatly simplify the overall flow: A request is…
ArrayKnight
  • 5,418
  • 4
  • 15
  • 20
10
votes
1 answer

How to use async/await with Gulp 4?

I'm trying to do something like this: gulp.task("test", async () => { return gulp.src("**/*.scss") .pipe(print((filePath) => `File: ${filePath}`)); }); (print is gulp-print) But it gives the following: [22:08:43] Starting…
glen-84
  • 1,384
  • 1
  • 13
  • 26
9
votes
2 answers

Arrow functions as class properties using Babel

Can someone explain how Babel in React supports fat arrow functions as class properties? Using Babel Try it out I can see they are not supported: class Question { // Property (not supported) myProp = () => { return 'Hello, world!'; } …
isar
  • 1,390
  • 15
  • 28
9
votes
2 answers

JS & ES6: Access static fields from within class

In ES6, given the following example: export default class MyStyle extends Stylesheet { static Color = { mainDark: '#000' } static Comp = { ... color: Color.mainDark } } How can I access Color.mainDark (the static…
Livioso
  • 1,035
  • 1
  • 10
  • 16
8
votes
1 answer

Why are arrow functions as static members values not lexically scoped?

class Foo { static v = 123; static bar = () => this.v; } console.log(Foo.bar()); I expect this code to return undefined, because arrow functions are lexically scoped, hence this must be eagerly bound to the outer scope. Yet, it returns…
zerkms
  • 230,357
  • 57
  • 408
  • 498
8
votes
2 answers

Is there a way to enable support of optional chaining operators in WebStorm

I work on a project where we use optional chaining operator (aka Elvis operator): const baz = new obj?.foo?.bar?.baz() Is it a way to make WebStorm understand it? P.S. It's a part of stage-1 proposals:…
Sergei Panfilov
  • 12,838
  • 13
  • 66
  • 89
8
votes
1 answer

Node.js Best Practice Exception Handling - After Async/Await

Their is already a question on this topic Node.js Best Practice Exception Handling which is old and answers are very much outdated, domains have even deprecated since then. Now in a post Async/Await Node.js scenario shouldn't we consider sync and…
adnan kamili
  • 7,575
  • 5
  • 50
  • 105