Latest video
Latest posts

JavaScript in TypeScript: Learn How to Use Them Together

Hands-On

It is possible to use regular JavaScript code in a TypeScript application. TypeScript is a superset of JavaScript, which means that any valid JavaScript code is also valid TypeScript code. This allows developers to gradually adopt TypeScript by starting with their existing JavaScript codebase and gradually migrating it to TypeScript. Additionally, developers can use legacy JavaScript libraries and frameworks in a TypeScript application without any issues.

Continue reading →

Type Checking with Assertion Functions in TypeScript

Best Practices

An assertion function is the implementation of a runtime check that is able to identify the type of unknown input. When the conditions of the assertion functions are passed, TypeScript’s compiler will then assume that the input is of the type claimed by the signature of the assertion function.

Continue reading →

How to use Mapped Types in TypeScript

New Features

TypeScript 2.1 introduced mapped types which allow you to build new types based on the properties of an existing type.

Continue reading →

How to use const assertions in TypeScript

New Features

TypeScript 3.4 introduced const assertions, a feature that allows you to claim a value as immutable. This feature is particularly valuable in combination with array literals, as it prevents new values from being pushed into an existing array.

Continue reading →

How to write Express.js middleware with TypeScript

Hands-On

You can extend your Express.js server easily with custom middleware. All you have to do is to write a function that accepts three parameters (req, res, next).

Continue reading →

Error TS1196: Catch clause variable type annotation

Best Practices

By default, TypeScript’s compiler doesn’t allow you to add a custom type annotation to an error in a try-catch statement (TS1196). That’s because the underlying code can throw any type of error, even system generated exceptions, which makes it impossible for TypeScript to know the error type from the start. Luckily, there is the concept called “type guards“ which can help the TypeScript compiler to infer a specific type.

Continue reading →

React with TypeScript for Beginners

React

It’s 2021 and TypeScript’s support for React apps improved by a lot. If you are new to TypeScript and React, you can learn from Amir Ghezelbash how to develop your first React app. In his tutorials, Amir starts from scratch and shows you on a weekly basis how to improve your React and TypeScript skills.

Continue reading →

When to use static methods in TypeScript?

Best Practices

When developing class functions that don’t rely on an internal state, it’s a good idea to turn them into static methods. This can be easily done by adding the keyword static to your function’s declaration.

Continue reading →

Fastest way to set up a TypeScript project with Node.js (npm)

Hands-On

Setting up a TypeScript project with Node.js takes only a few minutes. Here is how to do it the fastest way by just using npm and yarn.

Continue reading →

TypeScript code coverage with Karma

Testing

Configuring code coverage with TypeScript and Karma to get coverage reports for code running in web browsers.

Continue reading →
12