
The most common forEach mistakes in TypeScript
forEach looks like the simplest array method there is, but in TypeScript it hides real traps: async callbacks TypeScript won't flag, narrowing lost inside closures, implicit-any indexing.
10posts

forEach looks like the simplest array method there is, but in TypeScript it hides real traps: async callbacks TypeScript won't flag, narrowing lost inside closures, implicit-any indexing.

The difference between a thrown exception and an unhandled promise rejection, why a surrounding try/catch sometimes doesn't help, and how to catch async errors correctly.

Why 'TypeError: Cannot read properties of undefined (reading ...)' happens, the three most common causes, and how optional chaining and nullish coalescing prevent it.

What this warning means, the two patterns that trigger it (derived state, callback refs), and how to move the update out of the render phase.

Why React throws 'Too many re-renders. React limits the number of renders...' and the two most common causes: setState in the render body and unstable effect dependencies.

What the call stack actually is, the two most common causes of a stack overflow in JavaScript, and how to convert deep recursion into an iterative version.

Why let and const throw ReferenceError instead of returning undefined like var, what the Temporal Dead Zone actually is, and the patterns that trigger it by accident.

Why JSX won't render an object directly, the three real-world cases that trigger it (Date, error objects, Map/Set), and how to fix each one.

How Error Boundaries work in React: components that catch errors from their children to improve your app's stability and reliability.

The most common mistakes to avoid when using React hooks: conditional calls, order, nested functions, and how to recognize them.