How do I extend another VueJS component in a single-file component? (ES6 vue-loader)

After some testing, the simple solution was to be sure to export a Vue.extend() object rather than a plain object for any component being extended. In my case, the base component: import Vue from ‘vue’ export default Vue.extend({ [component “Foo” definition] }) and the extended component: import Foo from ‘./Foo’ export default Foo.extend({ [extended component … Read more

What is the correct way to define global variable in ES6 modules?

There are several ways to have global values available in your application. Using ES6 modules, you can create a constant which you export from your module. You can then import this from any other module or component, like so: /* Constants.js */ export default { VALUE_1: 123, VALUE_2: “abc” }; /* OtherModule.js */ import Constants … Read more

What causes NextJS Warning: “Extra attributes from the server: data-new-gr-c-s-check-loaded… “

This is caused by an extension passing these extra attributes with your code when it is executed on the browser trying to interact with the UI . Extensions similar to Grammarly and LanguageTool are therefore the cause of this warning, so you have to find out which one is doing this then disable/configure it. You … Read more

Jest equivalent to RSpec lazy evaluated variables (let)?

The best solutions I’ve found have been libraries like https://github.com/stalniy/bdd-lazy-var and https://github.com/tatyshev/given2 If you don’t want to introduce a dependency, you can get similar behavior (albeit without lazy evaluation) by doing something like this: beforeEach(() => { let input=”foo”; beforeEach(() => { setupSomeThing(input); }); describe(‘when input is bar’, () => { beforeAll(() => { input=”bar”; … Read more

How to iterate over keys of a generic object in TypeScript?

for..in When looking at the Typescript documentation (Typescript: Iterators and Generators), we see that the for..in syntax will iterate over the keys of the object. for..in returns a list of keys on the object being iterated, whereas for..of returns a list of values of the numeric properties of the object being iterated. We can use … Read more

Are ES6 classes just syntactic sugar for the prototypal pattern in Javascript?

No, ES6 classes are not just syntactic sugar for the prototypal pattern. While the contrary can be read in many places and while it seems to be true on the surface, things get more complex when you start digging into the details. I wasn’t quite satisfied with the existing answers. After doing some more research, … Read more