HTML and CSS Reference
In-Depth Information
Clearly, it's very easy to read. The TypeScript compiler is highly optimized to generate human-readable
JavaScript, unlike some other JavaScript compilers you may have seen. This means that, if you decide to stop using
TypeScript, you can simply take the generated JavaScript and just use that. That is a huge advantage over similar
JavaScript compilers.
There is a lot more to TypeScript than what was covered here. Let's save that for the rest of the chapter and have
you start making a rogue game engine right away.
Setting Up TypeScript
There are two ways to set up TypeScript: the first is through Visual Studio, as a plug-in, and the second is through
Node.js . I am going to focus on the latter, as it's cross-platform, and you can do some really interesting automation
with Node and Grunt. If you are unfamiliar with either of these two technologies, I highly recommend your checking
out Chapter 23, which covers them.
To get started, you will need to open the command line. On a Mac, use Terminal. For Windows, I use Git Bash,
which is part of Git's installer. You must install Grunt globally on your computer before you begin. You can do that by
typing the following code snippet at the command prompt:
>npm install -g grunt-cli
Now, you will want to create a directory and navigate to it. This new directory, which I have called RogueTS, is
going to be where you do all your work. You will create a package.json file by typing this at the command prompt:
> npm init
Next, you have to answer a few questions about the project. Figure 19-1 shows you how I configured mine.
Figure 19-1. Once you have filled out all the questions, npm will generate a package.json file for you
From here, you must install all the modules that are required to run TypeScript as well as to automate your
project. (I will go through this quickly, so, again, if you have never used Grunt before, see Chapter 23 for more details.)
Type the following code at the command prompt:
npm install typescript --save-dev
 
Search WWH ::




Custom Search