What is the exact parsing precedence of arrow function (fat arrow =>) in Javascript?

As you say, => is not an operator. Arrow functions are primary syntax. The rules for them are defined in the specification, starting with the ArrowFunction production. ArrowFunction is defined as ArrowParameters followed by => followed by the misleadingly-named ConciseBody. ConciseBody has two forms. You’re asking about the form using ExpressionBody, which is where the … Read more

ES6 module syntax: is it possible to `export * as Name from …`?

No, it’s not allowed in JS either, however there is a proposal to add it. For now, just use the two-step process with importing into a local variable and exporting that: // file: constants.js export const SomeConstant1 = ‘yay’; export const SomeConstant2 = ‘yayayaya’; // file: index.js import * as Constants from ‘./constants.js’; export {Constants};

ESLint: “error Parsing error: The keyword ‘const’ is reserved”

ESLint defaults to ES5 syntax-checking. You’ll want to override to the latest well-supported version of JavaScript. Try adding a .eslintrc.json file to your project. Inside it: { “parserOptions”: { “ecmaVersion”: “latest” }, “env”: { “es6”: true } } Hopefully this helps. EDIT: I also found this example .eslintrc.json which might help.

ES6 – declare a prototype method on a class with an import statement

You can still attach a method on a class‘ prototype; after-all, classes are just syntactic sugar over a “functional object”, which is the old way of using a function to construct objects. Since you want to use ES6, I’ll use an ES6 import. Minimal effort, using the prototype: import getColor from ‘path/to/module’; class Car { … Read more

import * as React from ‘react’; vs import React from ‘react’;

TL;DR Indeed ES import statements import default and import * are not the same thing, the fact that they behave the same in this case is a combination of how React authors chose to publish the library and compatibility layers in TypeScript (using esModuleInterop) or Babel and your bundler to make them “just work”. It … Read more