Advanced #

Multi Threading
A complete guide to concurrency in TypeScript — the single-threaded model and event loop, Web Workers in the browser with safe typing and structured communication, Node.js Worker Threads with SharedArrayBuffer and Atomics, worker pools for parallel computation, SharedArrayBuffer and ownership transfer with Transferables, the difference between concurrency vs parallelism, and when worker threads deliver real benefits vs disproportionate overhead.
I/O
A complete guide to I/O operations in TypeScript — the fundamental difference between async vs sync I/O and their performance implications, file operations with fs/promises and streaming for large files, safe path handling with the path module, reading terminal input with readline and Promisify, the File System API in the browser with showOpenFilePicker, the Fetch API with full type safety, correct error handling for every type of I/O error, and file watching for hot reload.
Socket
A complete guide to socket programming in TypeScript — the difference between TCP sockets vs WebSockets vs UDP, TCP servers and clients with the net module and protocol framing for binary data, shared message types for type-safe communication, Socket.io with typed events using generics, JWT authentication on the socket handshake, room and namespace management, reconnection with exponential backoff, and TLS security for production sockets.
Web Socket
A complete guide to WebSocket in TypeScript — the HTTP upgrade handshake process, WebSocket servers with the ws library and proper connection management, discriminated unions for message types, ping-pong heartbeats for dead connection detection, broadcasting and rooms without Socket.io, browser WebSocket clients with auto-reconnect and exponential backoff, authentication via query parameters and the upgrade header, and Server-Sent Events as an alternative for one-way communication.
Web Server
A complete guide to building a web server in TypeScript — the built-in Node.js HTTP module, Express.js with type-safe requests and responses including Request augmentation for JWT payloads, a layered architecture with separate Routers and Controllers, correct middleware typing, request body validation with Zod, centralized error handling with custom AppError, graceful shutdown, type-safe environment variables, and a comparison of the Fastify vs Hono vs NestJS frameworks.
Unit Test
A complete guide to unit testing in TypeScript — the difference between unit vs integration vs e2e tests and the testing pyramid, Jest and Vitest setup with correct TypeScript configuration, the anatomy of a good test with the AAA pattern, testing pure functions and classes, testing async and Promises, testing HTTP endpoints with Supertest, meaningful code coverage vs coverage theater, the right test doubles, and the FIRST principles for quality tests.
Mocking
A complete guide to mocking in TypeScript — the test double taxonomy (dummy, stub, spy, mock, fake) and when to choose each, jest.fn and jest.Mocked for typed mocks, jest.spyOn for spying on real implementations, jest.mock for module mocking including partial mocks, manual mocks in the __mocks__ folder, mocking Date and timers with jest.useFakeTimers, mocking fetch with msw, the over-mocking anti-pattern, and when fakes are better than mocks.
About | Author | Content Scope | Editorial Policy | Privacy Policy | Disclaimer | Contact