π This article was originally published on MAK Studio. Check out the full interactive lesson with live demos and code examples.
Home βΊ
Courses βΊ
TypeScript βΊ
Problem Solvers
π· Problem Solvers Β· 20 answers
TypeScript problems. Solved in 5 minutes each.
Every page here answers one specific question β the exact thing you typed into Google. No filler, no "in this article we will explore." Just the answer, working code, the reason it works, and the mistakes to avoid. This is what you need at 2 AM when the compiler won't stop complaining.
~5 min per page
All levels
TypeScript 5 Β· React 19
TypeScript path
Types & interfaces
Generics
Error messages
React + TS
All problems
How to use this page. Find your problem in the list below. Click it. The answer is the first thing on the page β no scrolling required. Every page has a "Short answer" box at the top, followed by the working code, then the explanation. If you're looking for a structured learning path instead, the 8-lesson TypeScript track covers every concept from scratch.
π§± Types & interfaces
Shape definitions, optional/required fields, and choosing between interface and type.
[#### How to type an object with dynamic keys
Record, index signatures, and why { [key: string]: T } isn't always enough.](https://makuistudio.com/courses/typescript/problems/dynamic-keys.html)
[#### interface vs type β when to use each
The one real difference (declaration merging) and the decision rule that follows.](https://makuistudio.com/courses/typescript/problems/interface-vs-type.html)
[#### How to make all properties optional
Partial, deep partial, and when optional isn't what you actually want.](https://makuistudio.com/courses/typescript/problems/partial.html)
[#### How to extend an interface
extends, intersections (&), and the difference between extending and composing.](https://makuistudio.com/courses/typescript/problems/extend-interface.html)
[#### How to use Record in TypeScript
Typed dictionaries, constraining keys, and why Record beats index signatures.](https://makuistudio.com/courses/typescript/problems/record-type.html)
[#### Pick vs Omit in TypeScript
Whitelist vs blacklist, and the pattern that scales when your type grows.](https://makuistudio.com/courses/typescript/problems/pick-omit.html)
𧬠Generics
Reusable type-safe code. Constraints, defaults, and when generics actually help.
[#### How to constrain a generic type
, keyof constraints, and accessing properties on T.](https://makuistudio.com/courses/typescript/problems/constrain-generic.html)
[#### When to use generics vs any
Why any throws away information and how preserves it.](https://makuistudio.com/courses/typescript/problems/generic-vs-any.html)
[#### How to use keyof in TypeScript
Key unions, indexed access with T[K], and the get pattern.](https://makuistudio.com/courses/typescript/problems/type-keyof.html)
[#### When to use the satisfies operator
Type checking without widening β the operator that fixed config objects.](https://makuistudio.com/courses/typescript/problems/satisfies-operator.html)
β οΈ Error messages
The compiler messages that stop you cold. What they mean, how to fix them.
[#### "Property does not exist on type"
When the compiler doesn't know your shape. Interfaces, type guards, and the fixes.](https://makuistudio.com/courses/typescript/problems/property-does-not-exist.html)
[#### "Object is possibly null"
Narrowing with early returns, optional chaining, and the non-null assertion's real cost.](https://makuistudio.com/courses/typescript/problems/object-possibly-null.html)
[#### unknown vs any
The safe alternative to any β and how to narrow unknown correctly.](https://makuistudio.com/courses/typescript/problems/unknown-vs-any.html)
[#### Enum vs union type
Why modern TS prefers string literal unions over enum β and when enums still win.](https://makuistudio.com/courses/typescript/problems/enum-vs-union.html)
[#### How to narrow a union type
typeof, in, instanceof, discriminated unions, and exhaustive checking with never.](https://makuistudio.com/courses/typescript/problems/narrow-union.html)
[#### How to use discriminated unions
The pattern that models state machines β impossible states unrepresentable.](https://makuistudio.com/courses/typescript/problems/discriminated-union.html)
βοΈ React + TypeScript
Props, state, events, refs, and the patterns every React + TS codebase uses.
[#### How to type useState with an object
Nullable state, partial updates, and the generic annotation that fixes it.](https://makuistudio.com/courses/typescript/problems/usestate-object.html)
[#### How to type an event handler
ChangeEvent, MouseEvent, FormEvent β the cheat sheet for every React event.](https://makuistudio.com/courses/typescript/problems/type-event-handler.html)
[#### Type guard for array of objects
Validating API responses at the boundary β isUserArray built from scratch.](https://makuistudio.com/courses/typescript/problems/type-guard-array.html)
[#### How to type a generic function
The signature that preserves type information through a transformation.](https://makuistudio.com/courses/typescript/problems/generic-vs-any.html)
π All 20 problems
Sorted by category. Click any to jump straight to the answer.
1
Types & interfaces
6 problems
Dynamic keysinterface vs typePartial
ExtendingRecordPick/Omit
Dynamic keys β
interface vs type β
Partial β
Extending β
Record β
Pick/Omit β
2
Generics
4 problems
ConstraintsGeneric vs any
keyofsatisfies
Constrain generic β
Generic vs any β
keyof β
satisfies β
3
Error messages
6 problems
Property does not existPossibly nullunknown vs any
Enum vs unionNarrowingDiscriminated unions
Property not found β
Possibly null β
unknown vs any β
Enum vs union β
Narrow union β
Discriminated β
4
React + TS
4 problems
useStateEvent handlersType guardsGenerics
useState with object β
Event handler β
Type guard array β
Generic function β
π Continue your TypeScript path
[πΊοΈ TypeScript learning path
8 lessons from setup to React](https://makuistudio.com/courses/typescript/index.html)
[π· Lesson 1: Setup & first types
Start from zero](https://makuistudio.com/courses/typescript/lessons/intro.html)
[βοΈ React track
Where TS pays off the most](https://makuistudio.com/courses/react/index.html)
[π¨ JavaScript track
The prerequisite for everything TS](https://makuistudio.com/courses/javascript/index.html)
TypeScript Problem Solvers Β· 20 answers
π Want more free lessons?
This is part of a free 30+ lesson curriculum on HTML, Python, AI, and JavaScript. No sign-up. No ads. Just code.
Top comments (0)