TypeScript: Guides and Practical Know-how | Page 2 | mironsoft Blog
TypeScript
-
Apr 11, 2026
pnpm workspaces organize multiple TypeScript packages in one repository without the dependency duplication of npm or the generous hoisting of Yarn Classic. Anyone setting up a new monorepo or migrating an existing one benefits from a stricter, more predictable dependency tree.
-
Apr 8, 2026
Writing test data as loosely typed object literals invites silent decay the moment the underlying domain type changes and gains a new required field. Type-safe factory functions with Partial-T and sensible defaults centralize test data in one place, force synchronization with the real interface, and keep Vitest suites maintainable and consistent across hundreds of test files.
-
Apr 8, 2026
Maintaining TypeScript types manually alongside objects and constants eventually produces drift between code and type definition. The keyof and typeof operators derive types directly from existing values and interfaces, so object keys, configuration values and literal options stay automatically in sync while the compiler reliably rejects typos in property access.
-
Apr 4, 2026
Prisma generates a fully typed database client from a single schema file. Every query, every relation and every field is known at compile time, which makes entire classes of runtime errors at the database boundary disappear.
-
Mar 29, 2026
A TypeScript review that only checks syntax misses the actual risks: any creep, unnecessary as assertions, unreadable generic constructs, and non-null assertions that mask real error sources. This article covers the most important red flags experienced reviewers look for, a practical checklist, and a way to keep type-safety rigor and review speed in balance.
-
Mar 26, 2026
Anyone who sees TypeScript's type system only as an annotation for runtime values misses its real power. Conditional types correspond to if/else, mapped types correspond to forEach, infer corresponds to pattern matching, and recursion is the only available control flow construct. Together these four building blocks form a complete functional language evaluated at compile time, one capable of building even small parsers.
-
Mar 26, 2026
An error code as a number or a single boolean for the failure case hides from the compiler which error kinds actually exist. Discriminated unions make every possible error variant visible as its own named type and, through exhaustiveness checking, guarantee that none of them are ever forgotten in the code.
-
Mar 20, 2026
Teams that maintain TypeScript interfaces and JSON Schema separately eventually lose sync between the two: a field gets renamed in the type, the schema keeps the old name, and a consumer validates against rules that no longer match the real API. Tools like ts-json-schema-generator and zod-to-json-schema derive the schema directly from TypeScript code, making the type the single source of truth.
-
Mar 17, 2026
Internal CLI tools almost always grow organically: a flag here, a subcommand there, until nobody can say precisely what a user is allowed to type anymore. With Commander and yargs you can declare flags, options and subcommands so that TypeScript infers the handler signature automatically, turning typos in flag names into compile errors instead of silent undefined values at runtime.
-
Mar 16, 2026
Test code often gets a free pass on type discipline because deadlines are tight, a mock gets copy-pasted, or it is supposedly just a test. Yet tests are exactly where type regressions in the code under test need to be caught reliably. This article covers practical typed mocking patterns using vi.mocked, satisfies, and mock factories, plus unknown and zod as replacements for any in loosely shaped test data.