Tim Mouskhelichvili • October 4, 2022 • 2 minutes to read
When developing a web application or TypeScript library, a developer may need to initialize an empty typed object. Luckily, it is easy to achieve. To initialize an empty typed object in TypeScript, you can: Use type assertion Create a [...]
Tim Mouskhelichvili • October 3, 2022 • 2 minutes to read
When declaring an empty array in TypeScript, the compiler cannot infer its type by default. That's why you need to specify the array's type explicitly. Luckily, it is easy to do. Here is one way to declare an empty [...]
Tim Mouskhelichvili • September 28, 2022 • 3 minutes to read
TypeScript adds strong typings to your JavaScript. Everything has its type in TypeScript. However, the compiler is sometimes incorrect and infers the wrong type. Luckily, TypeScript offers a special keyword to cast object types. The as keyword converts an [...]
Tim Mouskhelichvili • September 27, 2022 • 2 minutes to read
Sometimes, a TypeScript developer may need to find the class name of an object. Luckily, it is easy to do. To find the class name of an object at runtime in TypeScript, you can: Use the constructor property of [...]
Tim Mouskhelichvili • September 26, 2022 • 3 minutes to read
Sometimes a developer needs to check the type of a TypeScript interface at run time. Typically, the instanceOf keyword is used for those tasks. Unfortunately, you cannot use the instanceOf keyword on an interface in TypeScript. However, there are [...]
Tim Mouskhelichvili • September 22, 2022 • 3 minutes to read
Sometimes, when developing a TypeScript project and importing a new package, you get a "cannot find module" error. Luckily, this error is easy to fix. There are many reasons why the "cannot find module" error can happen in TypeScript: [...]
Tim Mouskhelichvili • September 20, 2022 • 2 minutes to read
JavaScript offers many ways to iterate over an array, for example, the for loop, the map function, and the forEach function, which is the subject of this React guide. In React, the forEach function is used to iterate over [...]
Tim Mouskhelichvili • September 19, 2022 • 2 minutes to read
In HTML, the label element defines a caption for an input. We use the "for" attribute to associate a label to a form input. However, if you try to add the "for" attribute on a label when using React [...]
Tim Mouskhelichvili • September 14, 2022 • 3 minutes to read
Often when developing a React application, a developer needs to filter data. Luckily, JavaScript offers a simple way to do it. In React, the easiest way to filter data is to use the built-in JavaScript filter function. This article [...]
Tim Mouskhelichvili • September 13, 2022 • 2 minutes to read
Developers use different files to separate various code pieces when developing a React application. Those files interact by exporting and importing each other's classes, functions, and variables. This brings the question of how to export a function in React [...]