Tag: ecmascript 6

Chrome debugger doesn't show dynamic class names

My Javascript code generates a bunch of ES2015 classes dynamically, including a custom name: const EntitySubclass = class extends Entity {}; Object.defineProperties(EntitySubclass, { name: { value: dynamicClassName } }); This works fine in the code itself. CustomClass.name returns the expected name. But when shown in the Chrome console or debugger, one of those classes is […]

Force a yielded function to error for unit test

I am trying to unit test this Koa middleware: function * onError(next) { try { yield next } catch (err) { this.status = 500 this.body = err.message } } I wish to trigger the catch block but I can’t seem to get yield next to cause an error. If this was a non generator method […]

TypeScript can I mix import of regular js in a .ts file?

I’m using webpack and write in es6. I’m in the process of integrating typescript to the project. so my need is to import “old” es6 modules to the new .ts file. I keep getting the following error: let’s say I have a const consts = { login: ‘/api/login’, user: ‘/api/user’, register: ‘/api/register’ }; export default […]

Multi-Level Menu

I’ve been scratching my head on how to get this dynamic menu working in a cleaner way than I currently do, I currently receive a list of menu items as a flat XML structure. I’ve created an object below illustrating how the data will look inside an object, it has a parent-child relationship for each […]

ES6 arrow losing enclosing scope

Hi I was under the impression that if you use a arrow function, this refers to the enclosing scope as explained on the following link https://www.sitepoint.com/bind-javascripts-this-keyword-react/: ES2015 Arrows The ES2015 specification introduces the arrow function syntax for writing function expressions. As well as being terser than regular function expressions, they can also have implicit return […]

AngularJS + Webpack Mysterious Bug – Cannot read property 'call' of undefined

I’m working on a project using AngularJS with Webpack, I’m getting a very weird bug: Sometimes an error will show up: TypeError: Cannot read property ‘call’ of undefined at __webpack_require__ (vendor.js:51) at Object.357 (templates.js:377) at __webpack_require__ (vendor.js:51) at exam (app.js:17755) at Object.invoke (vendor.js:21978) at vendor.js:24895 at forEach (vendor.js:17592) at Object.<anonymous> (vendor.js:24893) at Object.invoke (vendor.js:21978) at […]

How to get ESLint to work React + Babel in Sublime Text 3 editor?

I am using ReactJS and Babel. Here is what I have in my .eslintrc.json: { “parser”:”babel-eslint”, “env”: { “browser”: true, “commonjs”: true, “es6”: true, “node”: true }, “extends”: “eslint:recommended”, “parserOptions”: { “ecmaFeatures”: { “experimentalObjectRestSpread”: true, “jsx”: true }, “sourceType”: “module” }, “plugins”: [ “react” ], “rules”: { “indent”: [ “error”, “tab” ], “linebreak-style”: [ “error”, […]

Possible strange behaviour with ES6 deconstruction syntax

This question already has an answer here: Babel 6 changes how it exports default 4 answers

(React ES6) Adding Modal Trigger to Map Markers Dynamically

So I am trying to dynamically create Modals and Markers from the same data in React in ES6 using react-bootstrap, and having the markers be the triggers for the modals. Right now I keep calling the same modal Code of page that generates markers/modals: class SimpleMapPage extends React.Component { //shouldComponentUpdate = shouldPureComponentUpdate; constructor(props) { super(props); […]

webcomponents-lite with ES6 doesn't work in IE 11 and 10

We are using WebComponents with ES6 syntax. WebComponents polyfill webcomponents-lite.js (which doesn’t include ShadowDOM) is not working in IE 11 whereas the webcomponents.js (which includes ShadowDOM) works fine. For our project use case, we would like to use ‘custom-elements’ without ShadowDOM. An error is thrown in IE, if we use webcomponents-lite.js – SCRIPT5022: Exception thrown […]