AZ.dev

Developer Reference

Opinionated micro-docs. One right answer. Copy-paste ready.

Categories

Recently Added

Fix "Cannot find module" with ES modules in Node.js
Node.js Node.js ES modules require explicit file extensions in import paths.
Undo the last commit but keep the changes
Git Reset the last commit while keeping all changes staged and ready to re-commit.
Array reduce: sum values and transform objects
JavaScript Array.reduce() iterates an array and accumulates a single result.
Fastify route runs after a hook already sent a reply
Node.js A preHandler or onRequest hook sends a 401, 403 or 429, but the route handler runs anyway, crashes on missing state, and Fastify logs FST_ERR_REP_ALREADY_SENT and ERR_HTTP_HEADERS_SENT.
Why useEffect runs twice in development and how to write it so that's fine
React In development, Strict Mode mounts each component, unmounts it, and mounts it again, so an effect runs, cleans up, and runs once more.
Stash work in progress including new, untracked files
Git git stash alone leaves new files behind.
Check an object against a type without losing its literal types
TypeScript Use satisfies when you want the compiler to check a value against a type but keep the narrower type it inferred.
Run a TypeScript file with node and no build step
Node.js Current Node runs .ts files by stripping the type annotations.
Reset a component's state when the thing it shows changes
React Give the component a key tied to its subject.
Fail a Node script without cutting off its output
Node.js Set process.exitCode and let the script end on its own.