Tag: ecmascript 6

ES6 in Google Web-starter-kit – Uncaught ReferenceError: require is not defined

After removing the line “only”: “gulpfile.babel.js”, in the .babelrc file, I created a class: export default class App { constructor() { console.log(“Cool”) } }

Convert a string to a template string

Is it possible to create a template string as a usual string let a=”b:${b}”; an then convert it into a template string let b=10; console.log(a.template());//b:10 without eval, new Function and other means of dynamic code generation?

How can I transform commonjs to es2015 module with babel plugin?

I use the webpack2 to build my web and I want to benefit from tree-shaking, which only works with es2015 modules. So I want to ask for commonjs to es2015 transformer of babel plugin like this rollup plugin https://github.com/rollup/rollup-plugin-commonjs.

Is there a way to use non-null assert operator and ES2015 Object shorthand syntax together?

I have a piece of code where I want to simultaneously use ES2015 Object shorthand syntax and Typescript 2.0 non-null assertion operator. In the code below item is of type number | undefined. Right now I have to use the verbose syntax: const { item } = this.state; this.props.onSubmit({ item: item! }); But I want […]

Requiring modules from requirejs (with babeljs plugin) in es6 scripts

I’m trying to use RequireJS babel plugin along with ReactJS to make a simple class in es6 but cant figure out how to Import or Require Reacts library from RequireJS while also exporting the class to use in another script. Below is the jsbin of what i’ve done so far but currently it errors when […]

How does an imported module get evaluated in ES6 exactly?

(There is another question of similar title out there but I have a different question here.) It’s stated that in ES6, an imported module is “executed” immediately. However, say for example I have exported an object: let Player = { player: null, init(domId, playerId, onReady) { window.onYouTubeIframeAPIReady = () => { this.onIframeReady(domId, playerId, onReady) } […]

Confusing “multiple properties with the same name in strict mode” error message

Background Inside my Angular2 project, I have a file named random.metadata.ts, which contains this code: import { Component, ChangeDetectionStrategy, AnimationEntryMetadata, ViewEncapsulation, Type } from ‘@angular/core’; export interface RandomInterface { configurationUrl?: string; changeDetection?: ChangeDetectionStrategy; viewProviders?: any[]; moduleId?: string; templateUrl?: string; template?: string; styleUrls?: string[]; styles?: string[]; animations?: AnimationEntryMetadata[]; interpolation?: [string, string]; entryComponents?: Array<Type<any> | any[]>; properties?: […]

How to link RCTCameraRoll for Android

I’m trying to use the CameraRoll library, but the documentation does not specify how to link it for Android. Instead, it only contains steps for iOS. It states that Android is supported but I have no idea how to link it in order to use it.

Which browsers support import and export syntax for ECMAScript 6?

I am currently writing a web application using the MEAN Stack, and am attempting to write code in ECMAScript 6 JavaScript; however, I am getting errors in both Chrome and Firefox when using import and export syntax. Are there currently any browsers that fully support ECMAScript 6? Please note: I am not asking when ECMAScript […]

What Purpose Does Array.of() Serve That An Array Literal Could Not Already?

This question already has an answer here: Array.of vs “[ ]”. When to use Array.of over “[ ]”? 3 answers What is the use case for Javascript's (ES6) Array.of()? 4 answers