Skip to main content

9 docs tagged with "typescript"

View All Tags

”[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.

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.

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.