Skip to Content
0 likes
Write a Generic identity and map Without Losing Types Level: Intermediate

Turn two any-typed helpers into generic functions and see what the compiler now catches. After this, a typo or a wrong method on the result is a compile error.

0 likes
Install @types for a Library That Ships No Types Level: Intermediate

Reproduce the missing declaration error, check whether the library has its own types, install the @types package and prove the types work. After this, you know the fallback when no types package exists.

0 likes
Partial and Required on a Form Draft Object Level: Intermediate

Derive a draft type with Partial, require every field with Required, and write one check that turns a draft into the finished type. After this, an unfinished form cannot reach the submit function.

0 likes
Pick and Omit Without Duplicating an Interface Level: Intermediate

Derive a public type from User with Omit and a short card type with Pick, then close the gap where Omit accepts a misspelled key. After this, one change to User updates every smaller type.

0 likes
private Fields vs #private: Which One Fits Level: Intermediate

Run the same class with the private keyword and with a hash field, and compare the output, the errors and what outside code can still reach. After this, you can pick one and say why.

0 likes
Record Keys That Match a Real Enum Level: Intermediate

Key a lookup table by an enum or a union of literals so a missing or misspelled key is a compile error. After this, adding a status shows you every table that needs an entry.

0 likes
Type JSON from fetch Without as MyType Everywhere Level: Intermediate

Replace scattered casts with one assertion function and one typed fetch helper. After this, a 404 or a changed payload fails with a clear message instead of carrying a wrong type.

0 likes
unknown First, Then Narrow: Parse an API Payload Level: Intermediate

Receive a nested payload as unknown and narrow it with two small helpers until every property is checked. After this, you can write a parser that rejects wrong data and returns a real type.

0 likes
Add a CHECK Constraint to a Table That Has Data Level: Intermediate

Find the rows that break the rule, fix them, then add the constraint as NOT VALID and validate it. After this, you can add a rule to a table that already has data without the command failing.

0 likes
Delete Duplicate Rows and Keep One Level: Intermediate

Number the copies with ROW_NUMBER, preview the rows that would go, delete them inside a transaction and add a UNIQUE rule. After this, one copy of each row survives and the duplicates cannot come back.

0 likes
Fix "must appear in the GROUP BY clause" Level: Intermediate

Read the error, then fix it the right way: group by the column, aggregate it or move the aggregate into a subquery. After this, you know which fix keeps your numbers correct.

0 likes
Get the Latest Row per Group With DISTINCT ON Level: Intermediate

Keep one row per group in the order you choose with the PostgreSQL DISTINCT ON clause, and compare it with the standard ROW_NUMBER version. After this, the latest order per customer is one query.