📄️ ”[number]” syntax
The [number] syntax is a TypeScript syntax that allows you to retrieve the type of an array's elements.
📄️ class dynamic inherit
In this article, we will demonstrate the way to dynamically inherit a class in TypeScript.
📄️ Conditional Types
Conditional Types allows us to create a type that depends on another type.
📄️ Generic type constraints
We can make use of node's built-in EventEmitter when we want to create a custom event emitter. However, it is not type-safe. We can use TypeScript to create a typed event emitter.
📄️ Type Infer
What is type infer?
📄️ Object.keys with typescript
A common issue when using Object.keys with typescript is that the type of the returned array is string[] instead of the correct type of the object's keys. This makes it impossible to use the returned array to access the object's properties.
📄️ Request Handler - Axios
When we want to create our lightweight SDK without using any third-party libraries, we might want to create a request handler to handle the api requests in a controllable and predictable way.
📄️ tsconfig.json cheat sheet
📄️ Extend npm package type with type definition
To extend or override types in other modules, you need to know the module name. Typically, these names can be found in the module's type definition files. Here are some common methods to determine the module name:
📄️ TypeScript documentation for mono-repo
In a mono-repo, you can generate TypeScript documentation for all packages using TypeDoc. This guide will show you how to generate documentation for a mono-repo with multiple packages.
📄️ User-defined type guard
If you are coming from Javascript to Typescript, you must have come across the situation that you want to filter out undefined from an array. However, the type of the array is still T | undefined after filtering even though we know that the array does not contain undefined anymore.