ECMAScript 6 spread syntax in object deconstruction. Support in TypeScript and Babel

Is the following valid ECMAScript 6? It seems to be supported by the latest version of Babel but it isn’t by TypeScript. I couldn’t find any ES6 references dealing with this case. Answer No, this is not valid ECMAScript 6. ES6 does only support rest syntax in function parameters and array destructuring, and spread syntax in function calls and array construction. It seems to be supported by the latest version of Babel Babel does implement the objectRestSpread ES7 proposal as a experimental plugin. You shouldn’t use this feature, it may break at any time.

Stop awaiting remaining promises if one returns sentinel value

I have a function validateTables() that validates that data exists in several tables using a call (per table) to an async helper function queryTable() that queries the api. To pass validation, data must exist in every table. If a table is empty, the helper function will return false. I currently have the set of calls in a Promise.all() that checks the resulting array for any false values. For performance, I would rather stop awaiting the resolution of any remaining promises if and when a promise resolves to false. Promise.race() and .all() don’t work because they are concerned with when or

How do I merge two arrays of Objects with a shared ID in TypeScript?

I have two Arrays of Objects, that share an ID. How do I merge them into a single Array, where all items have been merged based on the ID? I’m using TypeScript and Angular. Answer I think you could use something like this:

How to replace all the special character who follows another character

I have a long string containing some special characters. I need to check those special characters who do not follow space and replace it with a special character and space. Example Input Output Here you can see the last < replaced with < as it follows z which is not space. Keep this in mind in the HTML the special characters are coming in entities like Regex solution will be great. Answer Description of the pattern: a ” < ” character that is not followed by a white-space

Filter nested obejct

So I have this function that in theory should filter an array of movies by a given genre, but i get this error: Am I doing this stuff right or did i mess up one of the functions? Any help would be very much appreciated! edit: here’s an example of a movie object Answer as some comments suggested, i was able to solve the problem with the following: found out my object wasn’t an array so i used Object.values to get the collections values i made sure to check if every movie has a genre object that is not null

Bootstrap carousel or event not firing with Angular

I’ve checked everywhere with no luck. I’m trying to detect when the carousel changes to a new slide (weather automatically or by user click). I have tried many combinations with no luck. The event just does not fire at all. I’ve used the event handler .on to attach events in the typescript file but they do not fire. I’ve also tried the now deprecated .bind as well and again nothing happens. Using Angular 8.3 Bootstrap 4.4.1 Here is the HTML And the typescript Answer There are a few different ways to do this, but the below works well for me:

Use .reduce to sum object variabele based on object enum

I’m trying to use the .reduce method to sum the amount of different Expense objects. These Expenses can be of different type, and I’d like to keep the objects in the array splitted by that. So for example, the following array of expenses: Should become this: Also note that there should not be amount: 0 if no expenses of that type are present, but just an expense less. So without expenses of type C, the result should look like: This is how far I got: This works, but I feel like mapping to the object first and converting that to

How to pass data back to previous screen in react native navigation v5?

I just updated to react native navigation version 5. Now I am trying to send data back to previous screen on goBack() call. I push next view with And making move back after selecting item from FlatList with call: But by sending function over with params I get a warning: Non-serializable valuse were found in the navigation state… Can someone please tell me correct way to do this. Answer navigation send data to screens. follow official documentation React Native

Onclick the + button, add fields [closed]

Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 6 months ago. Improve this question when you click on the “+” button, regenerate all fields below the existing ones, with TypeScript. I tried to rely on pure javascript, with appendChild, but I didn’t have much success. Answer You can use cloneNode to clone the existing div then insert it after the current div before the next sibling. The issue might be the fact that your

Getting error while referencing the type as index

I have an array of objects with the following structure I need to take each key within each object inside array and form an array out of it. Basically grouping based on the key present in all the objects.If the object has no “values” it should return 0 across the val1,val2,val3. Here I am passing an string, that will be used inside reduce.I am getting this error any cannot be used as index whenever I pass in a dynamically string that will be used inside a reduce function whenever typescript is enabled. The code works just fine, but after I