Blog
Mert Özen's blog posts on software development, backend, frontend, and DevOps.
Conditional Types in TypeScript: Making Decisions at the Type Level
We look at the T extends U ? X : Y syntax, what extends means for assignability, distributive behavior over unions, turning it off with [T] and filtering unions with never, backed by real tsc output.
infer in TypeScript: Capturing Types Inside Conditional Types
We use infer to capture pieces of a matching type, write ReturnType, Parameters and Awaited ourselves, match tuple and string patterns, constrain infer and avoid the overload pitfall.
Mapped Types in TypeScript: Producing a New Type from an Existing One
We cover mapped type syntax, how homomorphic mapped types carry readonly and ? modifiers, managing modifiers with + and -, key remapping with as, and filtering properties with never.
Template Literal Types in TypeScript: Building Strings at the Type Level
We cover union products with template literal types, patterns like ${number}, the Uppercase and Capitalize intrinsics, deriving event names, generating keys with mapped types and parsing routes with infer.
Recursive Types in TypeScript: JSON, DeepReadonly and DeepPartial
We cover self-referencing types, a recursive JSON type, DeepReadonly and DeepPartial with their function and array pitfalls, recursive conditional types and the TS2589 limit with tail recursion.
Variance and Assignability in TypeScript: Covariance, Contravariance and strictFunctionTypes
We look at the direction of assignability, covariance in return types, contravariance in parameters, strictFunctionTypes, method bivariance, the array soundness hole and in/out variance annotations.
Branded Types in TypeScript: Keeping UserId and OrderId Apart
Where structural typing can't tell apart values with the same shape but different meaning, we use brands, produce them with validation functions and build a sturdier Brand helper with unique symbol.
Decorators in TypeScript: Standard TC39 Decorators and the context Object
We look at the standard decorators that arrived in TS 5.0: method, class, field and accessor decorators, the context object, why they aren't erasable and how they differ from the old experimentalDecorators setting.
using and await using in TypeScript: Resource Management with Symbol.dispose
We look at the TypeScript side of using and await using from TS 5.2: the Disposable types, the lib setting you need, the compiler's checks, DisposableStack, and what tsc's output means for Node and Safari.
Type-Level Programming in TypeScript: Solving the Easy type-challenges
We solve ten easy type-challenges (MyPick, MyReadonly, TupleToObject, First, Length, MyExclude, MyAwaited, If, Concat, Includes), each checked with type-level tests built on Equal and Expect.
Migrating from JavaScript to TypeScript: checkJs, JSDoc and Gradual strict
We walk through migrating a JavaScript project to TypeScript gradually: allowJs, checkJs and // @ts-check, writing types with JSDoc, the JSDoc changes in TypeScript 7, gradual strict and @ts-expect-error.
TypeScript 7 and Beyond: The Go-Based Compiler and the New Defaults
We look at the Go-based TypeScript 7 compiler, the defaults that came with 6.0, the settings removed in 7.0, isolatedDeclarations, the TC39 Type Annotations proposal and what the 7.1 beta brings.