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.

sudo npm install -g typescript
// tsconfig.json
{
    "compilerOptions": {
        "target": "ES6",
        "outDir": "./built",
        "rootDir": "./src",
        "strict": true
    }
}

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.

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

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

Back to Home
 Profile Picture
Profile Picture

About John Solly

I am a Senior Software Engineer with a focus on geospatial applications, based in the Columbus, OH metropolitan area. This blog is where I delve into the intricacies of GIS (Geographic Information Systems), offering deep dives into different components of the geospatial technology stack. For those who share a passion for GIS and its applications, you've found a spot to explore and learn.

Interested in collaborating or learning more about my work? Take a look at my portfolio for a showcase of my projects and expertise.

Comments

  • No comments yet.
Login to Comment