---
canonical: "https://www.jsolly.com/blog/TypeScript-revealed-210-issues-JavaScript-codebase/"
title: "Adding TypeScript to a JavaScript Project | A Step-by-Step Guide"
description: "Add TypeScript to your JavaScript project by converting .js files to .ts and fixing any compilation errors. Follow this guide for detailed instructions."
author: "John Solly"
published: "2022-07-19T21:59:53.847Z"
updated: "2022-07-19T21:59:53.847Z"
---

<a id="adding-typescript-to-a-javascript-project--a-step-by-step-guide"></a>

# Adding TypeScript to a JavaScript Project | A Step-by-Step Guide

![Meta Image](https://d1d7p8ufhgz4ld.cloudfront.net/media/post_metaimgs/TypeScript.webp)

All I needed to do to add TypeScript to my JavaScript project was install TypeScript, add a config file, and change the file extensions from .js to .ts. You can see the code change in [this PR](https://github.com/jsolly/GeoAsteroids/pull/22/files).

<pre><code class="language-bash">sudo npm install -g typescript</code></pre>

<pre><code class="language-bash">// tsconfig.json
{
    "compilerOptions": {
        "target": "ES6",
        "outDir": "./built",
        "rootDir": "./src",
        "strict": true
    }
}</code></pre>

Now, when I run `$ tsc` TypeScript files are compiled into JavaScript and placed in a folder named ./built. Although the app works, it's not flexing TypeScript until I add types to my variables and functions and resolve the 210 warnings spit out to the console on the compile step.

<pre><code class="language-bash">Found 210 errors in 9 files.

Errors  Files
    39  src/asteroids.ts:18
    27  src/canvas.ts:5
    29  src/collisions.ts:34
     2  src/keybindings.ts:10
    42  src/lasers.ts:22
     9  src/scoreLevelLives.ts:39
    28  src/ship.ts:134
    30  src/soundsMusic.ts:8
     4  src/utils.ts:9</code></pre>

Stay tuned for a future post about my journey to resolving all these errors!

July 19, 2022 in [Dev Tools](https://www.jsolly.com/blog/category/dev-tools/)

Updated July 19, 2022
