Tag: ecmascript 6

ES6 Classes: Is this a proof for prototype extending another one?

While playing around with Babel.js and doing some extending with classes I realized something that might be a good way to differentiate common class inheritance (Java, C#…) and prototype (I don’t really say class here somehow) inheritance. Given the following to base-class: class Menu { constructor(){} render(){ this.addObjectsToStage(); } addObjectsToStage() { var objects = this.objects.getAllObjects(); […]

Is it possible to list a module's named ES6 exports without importing its dependencies?

I’d like to get a list of all named exports of a module, but don’t want to import the module’s dependency tree. Why? I’m writing a gulpfile that will perform operations on a series of subfolders, whose names match the export names I’m trying to get. I’m not doing anything with the modules themselves. I’m […]

React Error – Uncaught Invariant Violation: Element type is invalid

…expected a string (for built-in components) or a class/function (for composite components) but got: object. Hi I’m currently trying my hand at React, I’m following a tutorial which is outdated, which is causing some problems. I’m trying to amend the errors myself as I go along, however I have stumbled whilst trying to set up […]

ag-grid not showing nested json

I have problem with ag-grid. I tried to bind my data with ag-grid. So when I enter new grade in my system I expand ag-grid by one column : var newGrade = {headerName: “Grade”, field: ‘grades[‘ + indexOfNewGrade + ‘].value’}; this.$scope.columnDefs.push(newGrade); this.$scope.gridOptions.api.setColumnDefs(this.$scope.columnDefs); this.$scope.gridOptions.api.setRowData(this.selectedEventLog.getEntries()); I am 100% sure that for example : this.selectedEventLog.getEntries()[0].grades[0].value returns 1 when […]

Using jsdoc with and the es2015 module syntax

I have two small problems in jsdoc 3.4.0 when using the es2015 module syntax. 1) The example code: /** @module */ /** Example for a local function */ function localFUnction() {} /** Example for an exported function */ function publicFunction() { localFUnction(); } export default { publicFunction }; results in: Module: module/module Methods (inner) localFUnction() […]

Uncaught SyntaxError: Unexpected token import when import module

I have typescript file that will compile to javasript for the browser. It looks as follow: /// <reference path=”typings/jquery/jquery.d.ts” /> /// <reference path=”typings/jquery-backstretch/jquery-backstretch.d.ts” /> /// <reference path=”typings/jquery-semantic/jquery-semantic.d.ts” /> import {Validator} from “classes/validator”; var main = () => { $(“.ui.dropdown”).dropdown(); $(“.left-half”).backstretch([“../images/lotus.jpg”]); const val = new Validator(); val.foo(); }; $(document) .ready(() => { main(); }); The compiled […]

Babel redeclares function parameter if 'let' with the same name is used twice (in a for loop)

When I do something (stupid) like this: function doBar(bar) { for (let bar = 0; bar < 10; bar++) { let bar = true; } } Babel generates this: function doBar(bar) { for (var bar = 0; bar < 10; bar++) { var _bar = true; } // bar is redeclared and has the value […]

Duplicated declarations in compiled out-file using Babel

I am trying to compile two ES6 files into a single ES5 output file using Babel. The resulting file seems to contain DUPLICATED declarations like: var _createClass = function () { … } and Object.defineProperty(exports, ‘__esModule’, {value: true}); Here are the files: File1 (./ec6/ec6Class.js) export class MyClass { constructor(dep1, dep2) { } foo() { console.log(‘foo’) […]

How to declare JSDoc type for an imported class?

For example, I have // ./command/queue.js export default class Queue { }; // ./myclass.js import CommandQueue from “./command/queue”; export default class MyClass { /** * @type {CommandQueue} <- ??? */ commandQueue = null; } How to set a type for commandQueue property? WebStorm says that CommandQueue is an unresolved variable or type. What is a […]

Use .babelrc from different path

Is there a way to provide the path to the .babelrc file to babel-cli? Something like: babel src –out-dir lib –config random-folder/sub-folder/.babelrc