Tag: TypeScript
-
React: Call Child Functions from Parent Functional Component
In the dynamic world of React development, one question often leads to another, unfolding layers of complexity and elegance in code. Recently, a junior programmer on my team approached me with a seemingly straightforward query: “How can I call child functions from a parent functional component in React?” Another colleague quickly interjected, “You can’t do…
-
JavaScript destructuring nested object and array
JavaScript destructuring is a powerful feature that allows developers to extract data from arrays and objects in an elegant and concise way. This technique makes it easier to work with complex data structures and reduces the amount of code required to extract information from these structures. Whether you’re a seasoned JavaScript developer or just starting…
-
How to mock class constructor with parameters- Jest and TypeScript
Earlier I wrote How to Mock a TypeScript class or dependency using Jest, that is basically a how to auto mock the ES class or module when it comes to typescript. Since it happen to come up on google results, get to see what people search around the subject and “jest mock constructor with parameters…
-
NodeJS Application Insights, logging and telemetry best practices
Distributed tracing and Real Time Application Monitoring is an essential component of any modern software architecture. This is done through telemetry, meaning produce some kind of tracing data about the software (included but not limited to logging) and transmit it to some external system to be stored and processed. Telemetry monitoring combined with tracing helps…
-
How to setup a TypeScript project dev environments like a pro
There are many ways to set up a nice developing environment for typescript. Since I like simplicity and ease of work, let’s setup a TypeScript project that is minimal and easy to work with. Though, It doesn’t mean we need to stick to the defaults; this setup works out of the box, it is pretty…
-
How to Mock a TypeScript class or dependency using Jest
Jest is an awesome and easy to use testing framework for JavaScript, but when it comes to TypeScript and mocking (specially to mock typescript classes) it can really become painful as TypeScript is not relaxed about the types as JavaScript is. In this article I am going to show you how to mock a dependency…