← All languages
TypeScript
Types, generics and safer contract bindings.
Theory — 50 written topics
Prefer to read first? The written TypeScript topics and their multiple-choice questions now live under the Learn tab.
Open TypeScript theory →Easy
Lessons 1-20 — fundamentals
- 1. Primitive TypesAnnotate variables with basic types.
- 2. Array TypesDefine an array of numbers.
- 3. TuplesFixed-length arrays with specific types.
- 4. Function TypesDefine a function type alias.
- 5. InterfacesShape of an object.
- 6. Optional PropertiesProperties that may or may not exist.
- 7. Readonly PropertiesPrevent modification of properties.
- 8. Type AliasesCustom names for types.
- 9. Literal TypesSpecific allowed values.
- 10. Intersection TypesCombining multiple types.
- 11. Narrowing: typeofUsing typeof for basic narrowing.
- 12. Narrowing: Null ChecksHandling potentially null values.
- 13. The unknown TypeSafely handling unknown inputs.
- 14. The never TypeRepresenting values that never occur.
- 15. Type AssertionsOverriding the compiler's inference.
- 16. Non-null AssertionTelling TS a value is definitely not null.
- 17. Index SignaturesDynamic property names.
- 18. Record UtilityShortcut for index signatures.
- 19. Partial UtilityMake all properties optional.
- 20. Pick UtilitySelect a subset of properties.
Medium
Lessons 21-37 — patterns and real code
- 21. Generic FunctionsIdentity function for any type.
- 22. Generic InterfacesWrappers with dynamic types.
- 23. Generic ConstraintsRestricting allowed generic types.
- 24. keyof OperatorExtract keys of an object type.
- 25. Indexed Access TypesLookup property types.
- 26. Basic Mapped TypesCreate new types by iterating over keys.
- 27. ReturnType UtilityExtract return type of a function.
- 28. Parameters UtilityExtract parameter types as a tuple.
- 29. Discriminated UnionsSwitching on a common literal property.
- 30. Template Literal TypesString manipulation at the type level.
- 31. Omit UtilityRemove properties from a type.
- 32. Exclude UtilityRemove types from a union.
- 33. Extract UtilityKeep only shared types in a union.
- 34. User-Defined Type GuardsFunctions that signal a type change to the compiler.
- 35. ReadonlyArrayPrevent mutation of arrays.
- 36. ConstructorParametersExtract arguments of a class constructor.
- 37. Generic DefaultsDefault types for generic parameters.
Hard
Lessons 38-50 — advanced and capstone
- 38. Conditional TypesTypes that depend on a condition.
- 39. The infer KeywordExtracting types within conditional expressions.
- 40. Recursive TypesTypes that refer to themselves.
- 41. Branded TypesOpaque types to prevent accidental assignment.
- 42. Mapped Types: Key RenamingRenaming keys during mapping using `as`.
- 43. Function OverloadsMultiple signatures for a single function.
- 44. Distributive ConditionalsHow unions are handled in conditional types.
- 45. Deep ReadonlyRecursively making all properties readonly.
- 46. Awaited UtilityRecursively unwrap Promises.
- 47. Exhaustive Never CheckEnsuring every case is handled in a switch.
- 48. Contract-Binding TypesDefining types that enforce a runtime structure (Schema validation logic).
- 49. Polymorphic this typesReferencing the current class type fluently.
- 50. Variance (in/out)Explicitly marking generic direction.