Hands-OnReady to supercharge your Node.js development? Nodemon’s got your back! In this tutorial, we’ll show you how to set up Nodemon to automatically restart your Node.js app when you make changes to your TypeScript code. Get ready for a faster, smoother development experience.
Continue reading →Best PracticesThe error message that undefined cannot be assigned to a specific type often occurs when working with optional parameters. When a parameter is marked as optional, it can either be undefined
or of the specified type. In TypeScript this is represented by a union type such as undefined | string
. If you want to use a function that doesn’t accept undefined
as a parameter (e.g., parseInt
), you must first validate that your value exists.
Here are some helpful tricks for accomplishing this.
Continue reading →New FeaturesType coercion means that one type of data is automatically turned into another type, like when TypeScript changes a number into a string. This process is based on JavaScript’s underlying mechanics and takes place automatically to ensure that interactions between different types don’t cause errors.
Continue reading →Best PracticesGitHub workflows provide an excellent platform for setting up a continuous integration pipeline. Within a workflow, you can define one or more jobs. GitHub provides virtual machines, referred to as runners, for executing jobs in a GitHub Actions workflow. These runners can be hosted either on GitHub’s infrastructure (GitHub-hosted runners) or your own infrastructure (self-hosted runners).
In this tutorial, you will learn how to use a matrix strategy to run jobs concurrently using different runner images. This approach enables you to test your TypeScript code across different operating systems or configurations, such as different versions of Node.js.
Continue reading →Hands-OnIn this TypeScript tutorial, we explore the concepts of type annotations and type inference. We clarify the distinction between the two and discuss their significance in writing maintainable and robust code.
Continue reading →New FeaturesTypeScript uses a structural type system, which means that type compatibility is based on the shape or structure of the types rather than their explicit declarations or names. This allows you to define two types with different names but identical properties, enabling interchangeability between them.
Continue reading →New FeaturesThe introduction of the satisfies operator in TypeScript 4.9 enables us to verify that the type of an expression corresponds to a specific type. It can offer greater precision compared to a type annotation and assist in narrowing down a union type.
Continue reading →New FeaturesDownleveling refers to the process of transpiling modern TypeScript code into an older version of JavaScript. It allows developers to target older JavaScript runtime environments that may not support the latest features and syntax introduced in newer versions of ECMAScript.
When downleveling is applied, TypeScript’s compiler (tsc
) converts your source code into an older version of JavaScript that is compatible with the specified target environment.
Continue reading →Best PracticesThe noUncheckedIndexedAccess compiler option is designed to help catch potential errors caused by accessing arrays or tuples with possibly undefined
or out-of-bounds indices. When this option is enabled, TypeScript assumes that indexed accesses can result in undefined values and requires developers to handle such cases explicitly.
Continue reading →New FeaturesThe void operator, present in both TypeScript and plain JavaScript, evaluates an expression and returns undefined
. Although it may not initially seem particularly useful, the void operator plays a significant role in preventing unintended leakage of return values and handling Promises for side effects.
Continue reading →