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

How to support top-level awaits in typescript?

I'm using version 4.3.5 of typescript with Ionic and have ts(1378) error. Here are is the tsconfig: { "compilerOptions": { "target": "es2017", "lib": [ "dom", "dom.iterable", "esnext" ], "sourceMap": true, …
2
votes
8 answers

What's the shortest way to copy only selected attributes in JavaScript?

Given the following two objects: let a = { foo: 'bar' }; let b = { one: 1, two: 2, three: 3, four: 4, five: 5, six: 6, seven: 7 }; We can assume that all values within these objects are primitives. The goal is to copy some attributes…
2
votes
1 answer

Regex - find all words starting with $_ that fall anywhere between template strings

Can I solve the following with a single regex? I know it can be done with two separate regex, but I'm curious if it can be done with just one instead? Find all instances of words (variables) that begin with $_, but only when they fall anywhere…
slopps
  • 127
  • 1
  • 10
2
votes
1 answer

Is there any way for Eclipse to handle async await (ES2017) in JavaScript without errors?

I have tried Wild Web Plugin and it still shows "Semi-colon expected" at the codes that use async. Wild Web Plugin claims that it handles ES2018 (https://marketplace.eclipse.org/content/wild-web-developer-web-development-eclipse-ide), but it's not…
Javier
  • 881
  • 6
  • 18
2
votes
5 answers

Angular 8 Native Typescript crash-free, accessor shorthand

Angular 8 : I used to use as a short hack on typescript side : object['accessor']['accessor']['accessor'] to get object.accessor.accessor.accessor without running the risk of throwing an error if one of the children was empty. What is the best way…
tatsu
  • 2,316
  • 7
  • 43
  • 87
2
votes
0 answers

Error Gulp Build: async functions is only available in es8 (use esversion 8)

When I'm going to compile my code with gulp displays the following error (image highlighted). It follows the function of the 1685 line that uses async in angular cli. $scope.GetNomePacienteIndicou = async function(chave_indicacao){ …
Victor
  • 53
  • 5
2
votes
2 answers

Clarification on functionality of Typescript's target and lib settings

When tsconfig.json has the following "target": "es5", "lib": [ "es6", "dom", "es2017" ] it doesn't seem to convert es2017 constructs to es5. For instance, the following will fail on IE11: var foo = [1, 2, 3].includes(1); Is this by design or am I…
AngryHacker
  • 59,598
  • 102
  • 325
  • 594
2
votes
2 answers

Bind this in an instance

I've a simple class handling the readable stream of a Fetch response: class ProgressIndicator { constructor(res) { this.res = res; this.contentLength = parseInt(res.headers.get('content-length', 10)); this.loaded = 0; return…
Angel Luis
  • 487
  • 2
  • 5
  • 19
2
votes
2 answers

Array > Object: how to index an array of objects with reduce, omitting the index from nested element in result (es2017)?

I have an array like this: const peopleArray = [ { "id": "Antoine", "country": "France" }, { "id": "Alejandro", "country": "Spain" } ] That I would like to represent as on object like this (note that…
Ville
  • 1,182
  • 10
  • 16
2
votes
2 answers

How to send response in mid of multiple async calls to database in NodeJS?

Need to terminate POST function and send Error: something as response, without terminating program. Sample for-loop: for (let i = 0; i < req.body.listoftouristsbyid.length; i++) { client.query("SELECT tourists.id FROM tourists WHERE tourists.id =…
λjk.jk
  • 127
  • 1
  • 12
2
votes
2 answers

Can Object.values() be used in Angular Projects?

It appears it does not work in Stackblitz, but can Object.values() be used in general in Angular projects? IIUC Angular includes CoreJS and the purpose of it is to allow things like Object.values() to be available across all browsers?
Ole
  • 41,793
  • 59
  • 191
  • 359
2
votes
2 answers

Can we add properties to immutable object in JavaScript?

An object is like: const obj = [{name: 'Alex', age: 20}, {name: 'James', age: 22}]; This obect is immutable from Immutable.js. Is it possible to add a new key for each object? example: const obj = [{name: 'Alex', age: 20, city: 'New York'}, {name:…
2
votes
1 answer

Set version of EcmaScript generated by Babel, in react app

I'm using the latest ES8 features in my react code, for example, async and await. Because of misconfiguration problem in my webpack config, I cannot use source maps, and this slows down debugging. A quick solution could be to locally compile source…
Dan
  • 55,715
  • 40
  • 116
  • 154
2
votes
2 answers

Convert Ember function to use ES2017 async/await

I'd like to convert this Ember route action to use ES2017 async / await. Can someone please explain what this would look like? Per spec, I already added: babel: { includePolyfill: true } to my ember-cli-build.js file: save() { let tenant =…
dpigera
  • 3,339
  • 5
  • 39
  • 60
2
votes
1 answer

Why is Boolean.prototype a Boolean object again? (And same for String and Number, but not Date or RegExp?)

In ES5, Boolean.prototype is a Boolean object: The Boolean prototype object is itself a Boolean object (its [[Class]] is "Boolean") whose value is false. In ES6 / ES2015, it isn't: The Boolean prototype object is an ordinary object. It is not a…
cpcallen
  • 1,834
  • 1
  • 16
  • 27