Update: Two months after, no database was harmed :)
Sunday, March 14, 2021
I'm on a roll! 😅
Update: Two months after, no database was harmed :)
Saturday, March 06, 2021
Spread and Rest in JavaScript
What does the rest parameter syntax look like?
Simple, It looks like this: ...stuff
That’s cool. What about the spread syntax? What does that look like?
Well, it also looks like this: ...stuff
And this is why the spread and the rest parameter syntax could be confusing and easily misplaced for each other. They have precisely the same syntax! What then separates them? Answer is the context they are used.
This post will look into these JavaScript syntaxes with the aim of disambiguating them. The hope is that it helps in removing the confusion.
Saturday, February 27, 2021
Introduction to Index Types in TypeScript
This post will look at Index Types in TypeScript. It will go over what they are and also touch on two type-operators related to them. These type operators are the index type query operator and indexed access operators.
This post is part of the Introduction to Advanced Types in TypeScript series. To better understand, it requires having some familiarity with Union Types, Generics, and Literal types. These are topics that have already been covered in the series.
Tuesday, February 16, 2021
Overview of Indexable Types In TypeScript
This blog post will look at Indexable Types. It is part of the Introduction to Advanced Types in TypeScript series.
In JavaScript, there are values, from which additional values can be retrieved via an index. A natural example of such a value is an Array: For example, given the following array:
const primaryColors = ["red", "green", "blue"]
The value primaryColors is an array value, and its individual content can be accessed by providing an index of type number:
console.log(primaryColors[0])
console.log(primaryColors[1])
console.log(primaryColors[2])
Sunday, February 07, 2021
Using Literal and Template Literal Types in TypeScript
This blog post will look at some of the use cases of literal and template literal types in TypeScript. It is a continuation of Literal and Template Literal Types, which introduces the language feature and it is a part of the Introduction to Advanced Types in TypeScript series.
This post will look at the following use cases:
- Compile time spell checker
- Alternative to enum
- Discriminated Union Pattern
- Stricter Type Constraints and Type Level Computation
Monday, February 01, 2021
Literal and Template Literal Types
This blog post will look at Literal and Template Literal Types. It is part of the Introduction to Advanced Types in TypeScript series.
In the post, Union and Intersection Types in TypeScript, the idea of viewing types with the perspective of Set theory was introduced. The key idea is to see types more or less as sets, and values of a type as elements that belong to a set. If this idea of viewing types from the perspective of Set theory is new to you, then I’ll advise to take a pause and read Union and Intersection Types in TypeScript before continuing with the rest of the post, because it is a useful perspective to understand literal types.
Monday, January 18, 2021
Union and Intersection Types in TypeScript
This blog post will look at Union and Intersection types in TypeScript. It is part of the Introduction to Advance Types in TypeScript series.
Union and Intersection types are useful features of TypeScript. But they can come across as a bit strange, especially to developers coming from more traditional languages like Java, C#, etc. Hence in this post, I will first start with a background section. This will help in developing the fundamental perspective needed to understand and appreciate union and intersection types in TypeScript.