Category: React

  • typescript rootDir and outDir not working – keep compiling in src folder

    Typescript rootDir and outDir not working – keep compiling in src folder If you are facing the issue where TypeScript’s rootDir and outDir options are not working as expected and your files keep compiling in the src folder instead of the specified output directory, you are not alone. This problem can be frustrating, but fortunately,…

  • Fetch new data every 30 seconds using useQuery in React

    Fetch new data every 30 seconds using useQuery in React When working with React and TypeScript, it’s common to use the useQuery hook from the popular library react-query to fetch data from an API. However, there may be scenarios where you need to automatically fetch new data at regular intervals, such as every 30 seconds.…

  • Unknown file extension “.ts” for /app/src/index.ts starting node app in combination with nodemon

    Unknown file extension “.ts” for /app/src/index.ts starting node app in combination with nodemon If you are encountering the error message “Unknown file extension ‘.ts’ for /app/src/index.ts starting node app” when trying to start your Node.js app using nodemon, don’t worry, you’re not alone. This error typically occurs when nodemon is unable to recognize TypeScript files…

  • Why @testing-library/jest-dom requires ts extensions for import itself?

    Why @testing-library/jest-dom requires ts extensions for import itself? If you are using TypeScript and have come across the @testing-library/jest-dom library, you may have noticed that it requires ts extensions for import itself. In this blog post, we will explore why this is the case and provide solutions to this problem. Understanding the Issue The @testing-library/jest-dom…

  • Is there a way to alias relative paths in typescript?

    Is there a way to alias relative paths in TypeScript? When working with TypeScript, managing relative paths can become cumbersome, especially when dealing with deeply nested folder structures. However, TypeScript provides a solution to this problem through path aliases. Path aliases allow us to create custom shortcuts for our import statements, making our code more…

  • Axios request can’t access relevant method in backend

    Axios request can’t access relevant method in backend If you are using TypeScript and facing an issue where your Axios request is unable to access the relevant method in the backend, you are not alone. This problem can occur due to various reasons, but fortunately, there are multiple solutions you can try to resolve it.…

  • Typescript generic help – ‘T’ could be instantiated with a different subtype of constraint

    Typescript generic help – ‘T’ could be instantiated with a different subtype of constraint When working with TypeScript generics, you may come across a situation where you want to ensure that a generic type parameter can only be instantiated with a specific subtype of a constraint. In this blog post, we will explore different solutions…

  • Getting “error TS2589” on GH Actions but works locally

    Getting “error TS2589” on GH Actions but works locally If you are encountering the “error TS2589” while running your TypeScript code on GitHub Actions, but it works fine locally, don’t worry, you are not alone. This error typically occurs due to differences in the TypeScript compiler versions between your local environment and the GitHub Actions…

  • Uncaught (in promise) TypeError: Cannot read properties of undefined (reading ‘displayName’)

    Uncaught (in promise) TypeError: Cannot read properties of undefined (reading ‘displayName’) If you are encountering the error message “Uncaught (in promise) TypeError: Cannot read properties of undefined (reading ‘displayName’)” while working with TypeScript, don’t worry, you’re not alone. This error typically occurs when you try to access a property of an undefined or null value.…

  • Zod Conditional Requirements Based on Values in Array Field

    Zod Conditional Requirements Based on Values in Array Field When working with TypeScript, you may come across a situation where you need to enforce conditional requirements based on the values in an array field. This can be particularly useful when you want to validate certain fields based on the presence or absence of specific values…