Solution Architect / Enterprise Architect / Principal Advisor

TypeScript Bits

Category — TypeScript Bits 9 posts
TypeScript Bits 2 min Novice

Avoid using ts-node when performance testing

Often times when performance testing, or comparing resource utilization (ex NodeJS vs Java), I have seen developers load testing, performance testing, and even one-off testing, with ts-node. ts-node is an awesome piece of kit…

TypeScript Bits 2 min Novice

Double vs Triple Equals

A very common point of confusion in JS/TS programming is what double equals and triple equals actually do. While this is base JS functionality, the method by how it works is quite simple (maybe)…

TypeScript Bits 5 min Intermediate

Enum Flags … are … awesome!

An often overlooked feature of most if not all languages is the concept of Enum Flags. In a nutshell, Enum Flags are an efficient way of storing and representing a collection of boolean values…

TypeScript Bits 2 min Novice

JS Array Functions Instead of Lodash

Lodash is an amazing library and is often used to minimize the hassle of working with arrays, numbers, objects, strings, etc. However, it is often seen that one of its primary uses is array…

TypeScript Bits 2 min Intermediate

Literal Types / Type Guards

When using TypeScript, we often (and hopefully as a manner of practice, always) declare the type of a variable or property. TypeScript allows the possibility of a variable or property to be of one…

TypeScript Bits 2 min Novice

Preload dotenv, don’t require it

Oh my dotenv! If you work with NodeJS at some point you will use and implement dotenv. It loads environment variables from a .env file (configurable name btw), into process.env, following the 12 Factor…

TypeScript Bits 2 min Novice

Template Literals

In many TS code-reviews one may find string concatenation (with the addition operator) used to assemble a message, query, multi-line comments, or other manners of literals. While this gets the job done, it is…

TypeScript Bits 2 min Intermediate

The awesome Readonly<T> Utility Type

Lets all be honest, side effects are terrible. They are especially terrible when working with a runtime that doesn’t implicitly discern between mutable and immutable pre transpilation or compilation (like JavaScript). I have often…

TypeScript Bits 2 min Novice

Use for..of in lieu of traditional incremental for loops when appropriate

For loops are for loops, sure. There is absolutely nothing wrong with the traditional incremental iterator approach. However, this recommendation is about readability, maintenance, decreasing code smells, as well as best practice when using…