By @alesanchezr and other contributors at 4Geeks Academy
Estas instrucciones están disponibles en 🇪🇸 español 🇪🇸
Complete selection of auto-graded and interactive TypeScript exercises for anyone who wants to start programming with TypeScript!
These exercises are the TypeScript version of JavaScript for Beginners: the same 25 exercises, with type annotations introduced along the way.
- TypeScript for Beginners ← 🔥 You are here
- Master TypeScript: Arrays
- Master TypeScript: Functions
- Master TypeScript: Objects
We need you! These exercises are built and maintained in collaboration with contributors such as yourself. If you find any bugs or misspellings please contribute and/or report them.
You can open these exercises in just a few seconds by clicking: Open in Codespaces (recommended) or Open in Gitpod.
Once you have VSCode open the LearnPack exercises should start automatically. If exercises don't run automatically you can try typing on your terminal:
$ learnpack start
Clone the repository in your local environment and follow the steps below. Make sure you have node.js 20 or newer (LearnPack does not run on older versions).
- Install LearnPack:
$ npm i @learnpack/learnpack -g- Install the local TypeScript plugin for LearnPack, which compiles your
app.tsbefore running or testing it:
$ learnpack plugins:install file:$(pwd)/learnpack-typescript-plugin- Start the tutorial/exercises by running the following command at the same level where your learn.json file is:
$ learnpack startIf LearnPack asks to install @learnpack/node (or jest), answer yes, then run learnpack start again.
Note: The exercises have automatic grading, but it's very rigid and strict, my recommendation is to not take the tests too serious and use them only as a suggestion, or you may get frustrated.
Each exercise is a small TypeScript program containing the following files:
- app.ts: the TypeScript file you write your code in.
- app.js: the JavaScript version of
app.ts, generated automatically every time you click Run or Test. You don't need to edit it. - README.md: contains exercise instructions.
- solution.hide.ts: a possible solution, in case you get stuck.
- tests.js: contains the testing script for the exercise (you don't have to open this file).
The tests check what your code does, not its types. Type mistakes show up as red underlines in your editor.
- The plugin in
learnpack-typescript-plugin/is the same one used by themaster-typescript-*repos. On every Run or Test it compilesapp.tsintoapp.jsin the same folder, then hands it to the Node plugin (@learnpack/node). npm run transpile:allregenerates everyapp.jsfrom itsapp.ts. Run it after editing a starter file, so the committedapp.jsmatches.npm run typechecktype-checks everyapp.tsandsolution.hide.ts. Four starter files contain an error on purpose, because fixing it is the exercise:05-Constants,08-Calling_your_first_function,10-Create_a_new_functionand17-Create_a_for_loop. Any other error is a bug.
Thanks goes to these wonderful people (emoji key):
-
Alejandro Sanchez (alesanchezr), contribution: (coder) 💻 (idea) 🤔, (build-tests)
⚠️ , (pull-request-review) 👀 (build-tutorial) ✅ (documentation) 📖 -
Paolo (plucodev), contribution: (bug reports) 🐛, contribution: (coder), (translation) 🌎
-
Ricardo Rodriguez (RickRodriguez8080) contribution: (build-tutorial) ✅, (documentation) 📖
This project follows the all-contributors specification. Contributions of any kind are welcome!
This and many other exercises are built by students as part of the 4Geeks Academy Coding Bootcamp by Alejandro Sánchez and many other contributors. Find out more about our Full Stack Developer Course, and Data Science Bootcamp.