Skip to Content
0 likes
Brand a userId So It Won't Accept an orderId Level: Advanced

Add a brand to two string ids and a parse function that creates them. After this, passing an orderId where a userId is expected is an error in the editor.

0 likes
Conditional Types That Extract a Promise's Value Level: Advanced

Write a conditional type with infer that takes the value out of a promise and see how it differs from Awaited. After this, you can read the value type of an async function without writing it by hand.

0 likes
const Assertions for a Fixed Lookup Table Level: Advanced

Freeze a lookup table with as const and derive its keys and values as types. After this, the table and the type that describes it can never drift apart.

0 likes
Migrate One Module While Testing Its JavaScript Boundary Level: Advanced

Convert one JavaScript module, catch a lost runtime guard, and verify an unchanged JavaScript caller against the emitted TypeScript build.

0 likes
Diagnose a Stale TypeScript Project-Reference Build Level: Advanced

Reproduce a project-only build that consumes stale shared declarations, rebuild the graph, and verify that an API change reaches its consumer.

0 likes
satisfies on a Config Object Without Widening Level: Advanced

Check a config object against a type with satisfies and keep its precise keys and literal values. After this, a typo in a key is caught and the object still autocompletes.

0 likes
Speed Up tsc With incremental and Smarter Includes Level: Advanced

Count the files tsc reads, narrow the include list and turn on incremental with a cache file. After this, you know which change made the build faster because you measured it.

0 likes
Template Literal Types for /users/:id Routes Level: Advanced

Turn a route pattern into a type that finds the parameter names and checks the paths you pass. After this, a typo in a route or a missing parameter is a compile error.

0 likes
Hand-Write a .d.ts for a Small JS Helper Level: Advanced

Write a declaration file for a JavaScript helper with a generic function and an overload, then test it with a short file. After this, calls to the helper are checked and the JavaScript stays as it is.

0 likes
Read EXPLAIN ANALYZE in 10 Minutes Level: Advanced

Run one slow query with EXPLAIN ANALYZE and read it with a five-question checklist: rows touched, filtered rows, estimates, loops and sort spills. After this, you can find the slow node of a plan and check your fix.

0 likes
Find Slow Queries With pg_stat_statements Level: Advanced

Turn on pg_stat_statements in a Docker container and list the statements that cost the most in total. After this, you know which query to tune first, and you do not have to guess.

0 likes
Create an Index Without Blocking Writes Level: Advanced

Build an index with CREATE INDEX CONCURRENTLY while a writer is active, and handle the transaction-block error and the invalid index that a failed build leaves. After this, you can add an index to a busy table without stopping its writers.