TypeScript: Guides and Practical Know-how | Page 15 | mironsoft Blog
TypeScript
-
Mar 16, 2025
switch/case only handles primitive equality, nested conditions quickly become unreadable, and there is no expression character at all. The TC39 Pattern Matching Proposal changes that: a match expression checks structure, type, shape, and value of an object at the same time, declaratively, exhaustively, and without a fallthrough bug.
-
Mar 6, 2025
Every new global state, whether theme, authentication, or feature flags, tends to add another layer of nested context providers around a React application's root. This article shows how to replace that deeply nested Provider Hell with a composable AppProviders pattern, including provider order, memoization, TypeScript typing, and testing.
-
Mar 6, 2025
Components that handle data fetching, form validation and UI state all at once are hard to test, hard to maintain and hard to reuse. Custom Hook Extraction is the fundamental React pattern that separates logic from presentation, making both better at the same time.
-
Mar 4, 2025
No separate generation step, no client rebuild after every schema change: Drizzle derives query types live from the TypeScript schema.
-
Mar 4, 2025
The new using keyword in JavaScript automates releasing resources when a scope is left: database connections, file handles, locks and workers are guaranteed to be cleaned up, whether the block ends normally, throws an exception, or triggers an early return.
-
Mar 3, 2025
React 19 brings new hooks and refines existing ones, but the biggest problem in practice is not a lack of knowledge, it is the wrong choice: useEffect where useRef would suffice, useMemo where no memoizing is needed at all. This cheat sheet gives clear decision rules for when which React hook is the right one.
-
Feb 28, 2025
In JavaScript, the original error gets lost on re-throw: an Error is replaced by another one, and the context disappears. The error.cause feature from ES2022 solves exactly this problem. It allows structured error chains where each layer keeps its own context while the root error is passed through.
-
Feb 28, 2025
A TypeScript library that extends React, Vue or another host library must not bundle its types itself, otherwise two copies of the same type declaration collide for the consumer. Declaring peer dependencies in a type-safe way means setting up the right version range, the right imports and the right CI test matrix for exactly that problem.
-
Feb 26, 2025
Both constructs type objects that hold several values of the same shape, yet they hand the compiler completely different promises. Treating { [key: string]: T } and Record<K, V> as interchangeable results in either overly loose types that wave through every typo, or overly strict types that break against runtime reality. This article walks through syntax, semantics, and a concrete decision rule for everyday work.
-
Feb 25, 2025
TypeScript types disappear completely once your code compiles, yet real data from APIs, forms, and third party libraries does not always match the shape it promised. This article shows how built in narrowing, custom type guard functions, and assertion functions work together to check values reliably at runtime and hand the compiler precise, trustworthy types afterward.