Skip to content

Repository files navigation

TypeScript Beginner exercises tutorial at 4Geeks Academy

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.

Before you start... some related tutorials:

  1. TypeScript for Beginners ← 🔥 You are here
  2. Master TypeScript: Arrays
  3. Master TypeScript: Functions
  4. 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.

One click installation (recommended):

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

Local installation

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).

  1. Install LearnPack:
$ npm i @learnpack/learnpack -g
  1. Install the local TypeScript plugin for LearnPack, which compiles your app.ts before running or testing it:
$ learnpack plugins:install file:$(pwd)/learnpack-typescript-plugin
  1. Start the tutorial/exercises by running the following command at the same level where your learn.json file is:
$ learnpack start

If 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.

How are the exercises organized?

Each exercise is a small TypeScript program containing the following files:

  1. app.ts: the TypeScript file you write your code in.
  2. app.js: the JavaScript version of app.ts, generated automatically every time you click Run or Test. You don't need to edit it.
  3. README.md: contains exercise instructions.
  4. solution.hide.ts: a possible solution, in case you get stuck.
  5. 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.

For maintainers

  • The plugin in learnpack-typescript-plugin/ is the same one used by the master-typescript-* repos. On every Run or Test it compiles app.ts into app.js in the same folder, then hands it to the Node plugin (@learnpack/node).
  • npm run transpile:all regenerates every app.js from its app.ts. Run it after editing a starter file, so the committed app.js matches.
  • npm run typecheck type-checks every app.ts and solution.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_function and 17-Create_a_for_loop. Any other error is a bug.

Contributors

Thanks goes to these wonderful people (emoji key):

  1. Alejandro Sanchez (alesanchezr), contribution: (coder) 💻 (idea) 🤔, (build-tests) ⚠️ , (pull-request-review) 👀 (build-tutorial) ✅ (documentation) 📖

  2. Paolo (plucodev), contribution: (bug reports) 🐛, contribution: (coder), (translation) 🌎

  3. 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.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages