How to assign the correct typing to React.cloneElement when giving properties to children?

The problem is that the definition for ReactChild is this: type ReactText = string | number; type ReactChild = ReactElement<any> | ReactText; If you’re sure that child is always a ReactElement then cast it: return React.cloneElement(child as React.ReactElement<any>, { width: this.props.width, height: this.props.height }); Otherwise use the isValidElement type guard: if (React.isValidElement(child)) { return React.cloneElement(child, … Read more

What does the Reflect object do in JavaScript?

UPDATE 2015: As pointed out by 7th’s answer, now that ES6 (ECMAScript 2015) has been finalized, more appropriate documentation is now available: ES6 spec, Reflection MDN Reflect (including details and examples to all of its methods) **Original answer (for (historic) understanding and extra examples)**: The Reflection proposal seems to have progressed to the Draft ECMAScript … Read more

Unexpected comma using map()

Explanation template literals use the toString() method which by default joins the returned array by map with a ,. To avoid this “problem” you can use join(”) Code var description = [ ‘HTML & CSS’, ‘Javascript object-oriented programming’, ‘Progressive Web apps (PWAs)’, ‘Website Performance Optimization’, ‘Webpack and Gulp workflows’, ‘Fullstack React.js’, ‘Web Components’, ‘Responsive web … Read more

Debugging in Safari’s Web Inspector, when using a module loader like SystemJS

Well, maybe you can use some IDE like WebStorm with a strong Debugger for Web and Node. Examples: You can see more about WebStorm debugger here. Some alternatives for WebStorm: Atom (Free) Intellij IDEA (community: Free) Visual Studio Code (Free) … P.S: I develop Ionic and React apps with WebStorm 😀

Why do arrow functions not have the arguments array? [duplicate]

Arrow functions don’t have this since the arguments array-like object was a workaround to begin with, which ES6 has solved with a rest parameter: var bar = (…arguments) => console.log(arguments); arguments is by no means reserved here but just chosen. You can call it whatever you’d like and it can be combined with normal parameters: … Read more