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 found functions during code review where an Array or Object is manipulated in the subroutine returning the input Array or Object. Ideally, functions should remain pure.

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 with one value 😎. This applies to all SQL languages, C#, Java, Python, Rust, GoLang, the list goes on, and illustrated here in TypeScript.

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 or more types. This means that a variable or property can be either a number, string, or custom type by declaring it like so...

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 loops in TypeScript (and in this case ES6+ as well). Often during code review, one will find references to an item via its parent array and index numerous times (think myArray[i].firstName and guess how lastName is accessed? 😞). It is a best practice in most if not all languages to create a variable out of this value accessed by index once.

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 manipulation, and accessing elements within. TypeScript (and ES6) have the majority this functionality built in!

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 often prone to error, difficult to read, and in many cases tedious to refactor and or implement.

Developer Ethos

During code review, triage, and early stages of sprint development we are so focused on the deliverables that we often forget that our commits, communication, teamwork, and ownership are more than simple roles and responsibilities… they are all part of our development culture. I will ABC (Always Be Collaborative). Do not build in isolation. Collaborate …