JavaScript to TypeScript Conversion Exercise

Overview

This exercise involves converting a JavaScript codebase into TypeScript. The goal is to leverage TypeScript's features such as type annotations and interfaces to improve the code's type safety and maintainability.

Instructions

  1. Clone the repository: Clone this repository to your local machine using the following command:
git clone git@github.com:turingschool-examples/js-to-typescript-practice.git
  1. Navigate to the project directory: Move into the cloned repository directory:
cd js-to-typescript-practice
  1. Install Dependencies Install the TypeScript dependency by running
npm install
  1. Understand the Codebase Familiarize yourself with the existing JavaScript code in the index.ts file. Identify areas where TypeScript features can be applied, such as type annotations for variables, function parameters, and return types, as well as interfaces for objects.

  2. Convert JavaScript to TypeScript

    • Add type annotations to variables, function parameters, and return types.
    • Define interfaces for objects where applicable.
    • Resolve any type errors that TypeScript flags.
  3. Run the Application Run the following command to compile the TypeScript code and run the application:

    npm start

    Not only will this compile the TypeScript code and run the application, but it will also watch any changes made. If you make changes to the TypeScript code, the application will recompile and the changes will be reflected in the console. If there are any errors, make sure to check the console for more information.

Solution Branch

A solution branch named ts-solution is available for reference. You can check out this branch to compare your implementation:

git checkout ts-solution

Additional Resources