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
8
votes
1 answer

Why was await* removed from the async/await proposal?

The only place it seems to be documented is this issue thread and the actual specification. However, the reasoning for the removal isn't posted anywhere I could find. The new recommended way seems to be await Promise.all(), but I'm curious as to why…
m0meni
  • 14,160
  • 14
  • 66
  • 120
8
votes
2 answers

Assigning properties to non-prototype with decorators

I am building a simple mapping between frontend/backend data structure. In order to do that I've created a decorator that looks like the following: function ApiField( apiKey: string, setFn: (any) => any = (ret) => ret, getFn: (any) =>…
Nik
  • 336
  • 1
  • 3
  • 15
7
votes
3 answers

Property 'trimLeft' does not exist on type 'string'. Lib: ["dom", "es2018"]

I am getting this Error when running the following code let foo = ' foo ' console.log(foo.trimLeft()) //foo.trimStart() works neither I know most of the solutions in the internet say, that I have to fix my tsconfig.json to include…
uloco
  • 1,913
  • 3
  • 17
  • 34
7
votes
1 answer

Rewrite firebase service using dynamic import

Please help me to rewrite the code to use the dynamic import feature. Unfortunately i have no idea how to use dynamic import in module. import firebase from 'firebase/app'; import 'firebase/firestore'; const config = { apiKey: '', authDomain:…
7
votes
2 answers

How to import two component but same name from two libraries?

I need Tooltip component from two libraries. For example import { Tooltip } from "react-leaflet"; import { Tooltip } from "recharts"; But the same name of Tooltip of two libraries, I get an error. How to import Tooltip without error.
azmul hossain
  • 941
  • 1
  • 9
  • 13
7
votes
4 answers

Dependency injection library - renaming injected values

I'd like to inject lodash by name, something like this: let val = function(lodash){ // lodash will be injected, simply by using require('lodash'); }; but say I want to rename the import, I want do something like this: let val =…
7
votes
2 answers

Property initializer syntax in ESnext

I understand there is a TC-39 proposal for a new syntax called "property initializer syntax" in JavaScript classes. I haven't yet found much documentation for this, but it is used in an egghead course when discussing React. class Foo { bar = () =>…
Ben Aston
  • 45,997
  • 54
  • 176
  • 303
7
votes
1 answer

Override constructor with an class decorator?

How can I override a constructor with an ES7 class decorator? For example, I'd like to have something like: @injectAttributes({ foo: 42 }) class Bar { constructor() { console.log(this.foo); } } Where the injectAttributes decorator will…
David Wolever
  • 130,273
  • 78
  • 311
  • 472
7
votes
3 answers

Remove TypeScript type annotations and assertions from code base

Considering that there is a project that should be converted from TypeScript to Babel, files contain typing information that cannot be just ignored by Babel. How can TS type annotations and assertions be stripped off from the entire code base in…
Estus Flask
  • 150,909
  • 47
  • 291
  • 441
7
votes
1 answer

Why do I have to put async keyword to functions which have await keywords?

I just want to wait for a process to finish, not want to make the function asynchronous. See the below code. I had to make getUserList asynchronous because there was an await keyword in the function. Therefore I also had to write like "await…
Nigiri
  • 2,759
  • 4
  • 22
  • 47
7
votes
1 answer

Getting value from returned promise from async function

I'm getting used to the proposed async/await syntax and there's some unintuitive behavior. Inside the "async" function, I can console.log the correct string. However, when I try to return that string, instead, it returns a promise. Checking this…
Brian Boyko
  • 517
  • 4
  • 13
7
votes
2 answers

technical difference between ES7 async function and a promise?

I'm trying to understand better what an async function in JavaScript is technically, even if I basically know how to use them. Many introductions to async/await make belive that an async function is basically just a promise, but that obviously is…
Udo G
  • 11,022
  • 11
  • 47
  • 77
6
votes
1 answer

Arrow vs classic method in ES6 class

Is there any reason to write classic syntax of ES6 methods? class MyClass { myMethod() { this.myVariable++; } } When I use myMethod() as callback on some event, I must write something like this (in JSX): // Anonymous…
Vesmy
  • 842
  • 2
  • 10
  • 23
6
votes
2 answers

React native bind animated event

Need a little help with some JS. Is it possible to bind an animated event as needed below? I need to do this: onScroll={ Animated.event([ { nativeEvent: { contentOffset: {y: this.state.animTop} } …
6
votes
4 answers

Can I create an object for which Array.isArray() returns true without using the Array constructor or array literal?

I can easily make a plain object look like an array by setting its prototype to Array.prototype: const obj = {}; Reflect.setPrototypeOf(obj, Array.prototype); (I'm aware that there are also some problems with the magic length property and sparse…
Michał Perłakowski
  • 70,955
  • 24
  • 137
  • 155