(Solved) Argument of type ‘() => Promise’ is not assignable to parameter of type ‘EffectCallback’

I’ve been using useEffect hooks heavily since React introduced them in version 16.8. A way to think of Effect hooks is like React lifecycle method (componentDidMount, componentDidUpdate, componentDWillUnmount) bundled into one function, or hook as React defines it to perform side effects in function components. Recently I came across the error Argument of type ‘() … Read more

(Solved) Property ‘allSettled’ does not exist on type ‘PromiseConstructor’

Recently I learned about the Promise.allSettled() method which generates a single promise from an array of promises similar to the Promise.all() method, with the main difference that Promise.allSettled() runs all the promises passed regardless if a promise is rejected. I initially was using Promise.all() for logic in a NodeJs Express application using TypeScript. However, after … Read more

How to make redirects from the server side using NextJS?

Whether you recently changed the path of your articles from /blog/[article-slug] to articles/[article-slug], or you need to redirect a user to the login screen to authenticate prior to granting access to a page, learning how to do redirects on the server side is an effective way to avoid React doing unnecessary rendering on the client … Read more

(Solved) TypeScript Array.find() possibly ‘undefined’

Errors like “TS2532: Object is possible ‘undefined’” can happen after defining the value of a variable by using the array.find() method. Here are the possible reasons why thearray.find() method returns undefined: The predicate parameter or callback function passed to the array.find() doesn’t explicitly use the return keyword to return a truthy value. The predicate parameter … Read more

TypeScript | A Practical Guide to Use Extends in TypeScript

With the introduction of ECMAScript 2015, commonly known as ES6, you can implement object-oriented programming as a class-based approach in JavaScript/TypeScript. Before that, JavaScript developers would use the prototype-based approach to implement the object-oriented pattern in their code. Similar to object-oriented languages like Java and C#, now TypeScript developers can use various object-oriented features like interfaces, inheritance, … Read more

Can You Learn TypeScript Without JavaScript? (Should You?)

TypeScript is a programming language that can be used to create robust, well-organized code. It’s popular among developers for its clear syntax and ability to communicate type information to other developers. However, TypeScript is reliant on JavaScript, so can you learn it without learning JavaScript first? You can learn TypeScript without JavaScript. However, it’s much … Read more