JQuery and TypeScript – We Have a Big Problem With jquery.d.ts

This is a call to all my TypeScript connections. This is a call to all. We have a big problem with the official Definitely Typed definition for jQuery. The most fundamental definition for the JQuery interface is incorrect, as you can see in the snippet from jquery.d.ts below. We can fix it, but not withoutContinue reading “JQuery and TypeScript – We Have a Big Problem With jquery.d.ts”

Avoid Expensive innerHTML Manipulation with insertAdjacentHTML

It is pretty well known these days that fiddling with innerHTML is terribly inefficient. It triggers serialization, and it can result in invalid markup. Nevertheless, you’ll still find this being done in many applications. elem.innerHTML = elem.innerHTML + ‘<a href=”https://www.example.com”>Visit Example Dot Com</a>’; // or elem.innerHTML += ‘<a href=”https://www.example.com”>Visit Example Dot Com</a>’; You can avoidContinue reading “Avoid Expensive innerHTML Manipulation with insertAdjacentHTML”

Expecting One Out Of Two Members in TypeScript Types

We’re going to use a simple restaurant set-menu example to explore TypeScript types. By the end of this thought-process, we’re going to be able to require one out of two members that are present on a type. Here’s the scenario. You have a set three-course menu. It looks like this: type SetMenu = { starter:Continue reading “Expecting One Out Of Two Members in TypeScript Types”

The ESM Module Loader is Experimental

If you fire up a new TypeScript app and whack it into Node, you might come across the following error about The ESM Module Loader is Experimental. (dev) [email protected]:~$ node –experimental-modules run.ts (node:11333) ExperimentalWarning: The ESM module loader is experimental. (node:11333) Warning: To load an ES module, set “type”: “module” in the package.json or useContinue reading “The ESM Module Loader is Experimental”

Genius in Hindsight: TypeScript Type Annotations

When TypeScript first landed in public view in October 2012, the type annotations looked a bit funky. If you were a student of type theory, they would have been familiar; but most programmers wouldn’t have seen a type annotation like this before: var name: string; Given the popularity of putting type names before variable names,Continue reading “Genius in Hindsight: TypeScript Type Annotations”

Visual Studio Code IntelliCode Extension Preview

IntelliCode brings AI-assisted power-ups to your auto-completion. It has been in preview within Visual Studio for some time (you can read about Visual Studio IntelliCode here) – but it has now landed in Visual Studio Code, which is exceptionally handy if you’re a TypeScript programmer like me. So what is IntelliCode? It’s a simple VSCodeContinue reading “Visual Studio Code IntelliCode Extension Preview”