Setting an ES6 class getter to enumerable

ES6 style getters are defined on the prototype, not on each individual person. To set the greeting property to enumerable you need to change: // Make enumerable (doesn’t work) Object.defineProperty(Person, ‘greeting’, {enumerable: true}); To: // Make enumerable Object.defineProperty(Person.prototype, ‘greeting’, {enumerable: true}); Object.keys only returns that object’s own enumerable properties, so properties on the prototype are … Read more

How to generate d.ts and d.ts.map files using webpack?

Running ts-loader before babel-loader will do the trick. Specifying that you want declaration files in config is all you need. If you are using an absolute path, the output d.ts files will also contain absolute paths which are useless and will result in typescript compilation errors. To fix that, I wrote a plugin to convert … Read more

nodejs 8 import module – require or import? [duplicate]

UPDATE-2018.11.15 ↓ Short answer We’re still using require Long answer ESM loading has partially landed in node 8.5.0 which was released in September 2017. As such, it has beeen part of the specs as an experimental feature for a little while: see the API documentation here. Caveats include the need for the –experimental-modules flag and … Read more

ES6 Classes Default Value

If you’re going to use ES6, why not use all of ES6, i.e. default values for parameters and destructuring assignment class myClass { constructor({a=”default a value”, b = ‘default b value’, c=”default c value”} = {a:’default option a’, b:’default option b’, c:’default option c’}) { this.a = a; this.b = b; this.c = c; } … Read more

VSCode Linter ES6 ES7 Babel linter

How I proceed: install globally eslint : npm install -g eslint install babel-eslint : npm install –save-dev babel-eslint install eslint-plugin-react : npm install –save-dev eslint-plugin-react create .eslintrc file in you root directory. here is my config: { “env”: { “browser”: true, “node”: true, “es6”: true, “jest”: true, “jquery”: true }, “parser”: “babel-eslint”, “parserOptions”: { “ecmaVersion”: … Read more

Is it possible to do multiple class imports with ES6/Babel?

You can export like this: import App from ‘./App’; import Home from ‘./Home’; import PageWrapper from ‘./PageWrapper’; export { App, Home, PageWrapper } Then, you can import like this wherever you need it: import { App, PageWrapper } from ‘./index’ //or similar filename … You can read more about import and export here. I also … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)