Chris Hager
Programming, Technology & More

Javascript

RSS Feed

Vue.js Syntax Highlighting with highlight.js

This post explains how to use highlight.js for syntax highlighting in a Vue.js application, allowing highlighting both on creation of an element as well as on updates to the source-code, using a simple v-highlightjs directive.
Everyone loves a good syntax highlighting. This post explains how to use highlight.js for syntax highlighting in a Vue.js application. The method shown here allows syntax highlighting both on original creation of an element as well as on updates to the source-code, using a simple v-highlightjs directive such as this: <pre v-highlightjs><code class="javascript"></code></pre> You can see a live example here: jsfiddle.net/metachris/1vz9oobc. To achieve this, we just need to install the highlight.


Custom Errors in TypeScript 2.1

TypeScript 2.1 introduced a number of breaking changes, among them that “Extending built-ins like Error, Array, and Map may no longer work”. For a subclass like the following: class FooError extends Error { constructor(m: string) { super(m); } sayHello() { return "hello " + this.message; } } methods may be undefined on objects returned by constructing these subclasses, so calling sayHello will result in an error. instanceof will be broken between instances of the subclass and their instances, so (new FooError()) instanceof FooError will return false.

swirl