Function Types and Return Types
You already know JavaScript. This week, you'll add TypeScript — a type system layered on top of JavaScript that catches bugs before your code runs. Every valid JavaScript program is already valid TypeScript, so you're not learning a new language. You're adding type annotations that tell the compiler (and your editor) what types your variables, parameters, and return values should be.
This week focuses on the syntax and concepts you need to start writing typed code. You'll learn how to annotate variables, functions, and objects, how to define reusable shapes with interfaces and type aliases, how to use generics to write flexible but type-safe code, and how to narrow union types so TypeScript knows exactly what you're working with. By the end of the week, you should be comfortable reading and writing TypeScript, and ready to apply it when you move on to React and beyond.
fetch and handle success and failure in a type-safe way.The HackYourFuture curriculum is licensed under CC BY-NC-SA 4.0

Found a mistake or have a suggestion? Let us know in the feedback form.