TypeScript in practice
Write TypeScript from your first typed function to a typed event emitter, and pass checks on both what the code does and what its types allow.
- 01
Add Types to a Function's Parameters
- easy
- Code
- 02
Describe an Object with a Type
- easy
- Code
- 03
Make a Parameter Optional
- easy
- Code
- 04
Accept Only a Few Exact Strings
- easy
- Code
- 05
Type an Array of Numbers
- easy
- Code
- 06
Allow Two Kinds of Value
- easy
- Code
- 07
Return a Value or Nothing
- easy
- Code
- 08
Write Your First Generic Function
- easy
- Code
- 09
Pick Keys from an Object, Typed
- easy
- Code
- 10
Return a Result Instead of Throwing
- easy
- Code
- 11
Handle Every Case of a Union
- easy
- Code
- 12
Check Unknown Data with a Type Guard
- easy
- Code
- 13
Zip Two Lists into Typed Pairs
- easy
- Code
- 14
Chunk a List, Keeping the Item Type
- easy
- Code
- 15
Get the First Item, Typed by Length
- easy
- Code
- 16
Fill In Options So Every Key Is Set
- easy
- Code
- 17
Drop Duplicates by Key, Keeping Item Types
- easy
- Code
- 18
Describe Each State of Remote Data
- easy
- Code
- 19
Assert a Value Is a Non-empty String
- easy
- Code
- 20
Filter Logs by a Typed Level
- easy
- Code
- 21
Describe Errors by Their Class
- easy
- Code
- 22
Parse Keyboard Shortcuts into Typed Keys
- easy
- Code
- 23
Make a Read-Only Object Writable Again
- easy
- Code
- 24
Keep Only an Object's String Fields
- easy
- Code
- 25
Flatten Nested Arrays One Level, Typed
- easy
- Code
- 26
List an Object's Values with Their Types
- easy
- Code
- 27
Join Two Tuples, Position by Position
- easy
- Code
- 28
Write a Generic Stack Class
- easy
- Code
- 29
Write a Typed Observable Subject
- easy
- Code
- 30
Share Behaviour Through an Abstract Class
- easy
- Code
- 31
Guard a Balance with a Private Field
- easy
- Code
- 32
Make a Class Iterable with Symbol.iterator
- easy
- Code
- 33
Paginate a List with Typed Pages
- easy
- Code
- 34
Check Feature Flags by Known Name
- easy
- Code
- 35
Sort Table Rows by a Typed Column
- easy
- Code
- 36
List Which Fields Changed, Typed
- easy
- Code
- 37
Keep Milliseconds and Seconds Apart
- easy
- Code
- 38
Build a Typed Deferred Promise
- easy
- Code
- 39
Sleep Until Done or Aborted
- easy
- Code
- 40
Time Out a Promise with a Typed Error
- easy
- Code
- 41
Retry an Async Call, Keeping Its Result Type
- easy
- Code
- 42
Poll Until a Typed Result Is Ready
- easy
- Code
- 43
Cache a Function's Results, Keeping Its Types
- medium
- Code
- 44
Group a List by a Computed Key
- medium
- Code
- 45
Build a Typed Event Emitter
- medium
- Code
- 46
Freeze Nested Data, Types Included
- medium
- Code
- Pro
- 47
Build a Query String from Typed Params
- medium
- Code
- Pro
- 48
Partition a List with a Type Guard
- medium
- Code
- Pro
- 49
Index a List by a Computed Key
- medium
- Code
- 50
Map an Object's Values, Keeping Its Keys
- medium
- Code
- 51
Omit Keys from an Object, Typed
- medium
- Code
- 52
Curry a Two-Argument Function, Typed
- medium
- Code
- 53
Count Items by a Computed Key
- medium
- Code
- 54
Swap Keys and Literal Values, Typed
- medium
- Code
- Pro
- 55
Reduce Todo Actions from a Typed Union
- medium
- Code
- 56
Model an Optional Value with Some and None
- medium
- Code
- 57
Parse JSON Safely into a Checked Shape
- medium
- Code
- 58
Tell Cats from Dogs by Their Properties
- medium
- Code
- 59
Charge a Fee per Payment Method
- medium
- Code
- 60
Summarise an Event Log by Kind
- medium
- Code
- 61
Route Requests Through a Handler per Method
- medium
- Code
- Pro
- 62
Await an Object of Promises by Key
- medium
- Code
- Pro
- 63
Drop Null and Undefined Fields, Typed
- medium
- Code
- 64
List an Object's Entries as Exact Pairs
- medium
- Code
- Pro
- 65
Merge Two Objects, Later Types Win
- medium
- Code
- 66
Split a Tuple into Head and Tail
- medium
- Code
- 67
Build an Enum Object from a List of Names
- medium
- Code
- 68
Read Object Keys Without Losing Their Types
- medium
- Code
- 69
Build a Typed LRU Cache Class
- medium
- Code
- 70
Expire Cache Entries with an Injected Clock
- medium
- Code
- 71
Write a Priority Queue Class with a Comparator
- medium
- Code
- 72
Run and Undo Typed Commands
- medium
- Code
- 73
Chain Results with Ok and Err Classes
- medium
- Code
- 74
Look Up Plugins by Name, Fully Typed
- medium
- Code
- 75
Subscribe to a Typed Slice of a Store
- medium
- Code
- Pro
- 76
Translate Messages by Known Keys
- medium
- Code
- 77
Turn Environment Variables into Typed Config
- medium
- Code
- Pro
- 78
Add Up Prices in Whole Cents
- medium
- Code
- 79
Read Search Params into a Typed Object
- medium
- Code
- 80
Wrap Storage with Typed Keys and Values
- medium
- Code
- Pro
- 81
Check Whether Date Ranges Overlap
- medium
- Code
- 82
Total a Cart with Typed Discounts
- medium
- Code
- 83
Debounce a Function You Can Cancel, Typed
- medium
- Code
- 84
Throttle a Function, Keeping Its Types
- medium
- Code
- 85
Run Async Work Exclusively with a Typed Mutex
- medium
- Code
- 86
Process Items One at a Time with a Typed Worker
- medium
- Code
- 87
Map with a Concurrency Limit, Typed and in Order
- medium
- Code
- Pro
- 88
Share In-Flight Requests per Key, Typed
- medium
- Code
- Pro
- 89
Batch an Async Stream with a Typed Generator
- medium
- Code
- 90
Keep Two Kinds of ID from Mixing Up
- hard
- Code
- Pro
- 91
Pipe a Value Through Typed Steps
- hard
- Code
- Pro
- 92
Build an Exact Object from Entries
- hard
- Code
- 93
Sort by a Key That Holds Numbers or Strings
- hard
- Code
- Pro
- 94
Type a Traffic Light State Machine
- hard
- Code
- Pro
- 95
Chain Validation Steps, Keeping Every Error Type
- hard
- Code
- Pro
- 96
Read Typed Values from Form Fields
- hard
- Code
- Pro
- 97
Merge Overrides into Defaults at Any Depth
- hard
- Code
- Pro
- 98
Find the Required Fields Still Missing
- hard
- Code
- 99
Bind Every Method to Its Object
- hard
- Code
- Pro
- 100
Make a Builder That Can't Build Too Early
- hard
- Code
- Pro
- 101
Resolve Typed Services from a DI Container
- hard
- Code
- Pro
- 102
Type a State Machine Class from Its Table
- hard
- Code
- Pro
- 103
Fetch JSON into a Validated Type
- hard
- Code
- Pro
- 104
Infer Types from a Validation Schema
- hard
- Code
- Pro
- 105
Parse CSV Rows with Typed Columns
- hard
- Code
- 106
Limit Concurrent Work with a Typed Semaphore
- hard
- Code
- 107
Settle a Tuple of Promises, Typed per Element
- hard
- Code
- Pro
- 108
Race Named Promises and Know Which Won
- hard
- Code
- Pro