This is my first time going through JavaScript and TypeScript for real.
I want to understand the workflows in creating, testing, and running web development code with TypeScript and NodeJS.
NOTE: These notes are NOT a replacement for watching the actual tutorial they were based on. These are just my personal notes and examples based on the 21-episode tutorial series (see below for more details).
- After NodeJS is installed, run
npm install -g typescript
- Open a terminal
- Run
tsc
{INPUT_FILE} [{OUTPUT_FILE}]
- Example:
tsc sandbox.ts sandbox.js
- NOTE: If the {OUTPUT_FILE} arg is omitted, the output file will be the same name as the {INPUT_FILE}, but with a .js file extension.
If you're making frequent edits to your TypeScript files, and want them quickly compiled each time you save, you can pass in -w
to the tsc
(TypeScript Compiler)!
Once finished, you can easily break out (Ctrl + C
).
If you're using a folder structure (such as public/
and src/
), and don't wish to enter a ton of commands to compile every .ts
(TypeScript) file, and then manually drag them into the corresponding folders, use the following:
- Open a terminal
- Navigate (
cd
) into your project's root folder - Run
tsc --init
to generate the startingtsconfig.json
file - Open the new
tsconfig.json
file - Set
rootDir
to./src
(for example) - Set
outDir
to./public
(for example) - Add
"include": ["src"]
so that it ignores anything OUTSIDE of thesrc
folder - Now, run
tsc
(ortsc -w
) and your files should automatically be done from thesrc
topublic
directories
I am following a tutorial series of 21 episodes from here.
Their repository example can be found here.
- Installing TypeScript
- TypeScrypt for Java/C# Programmers (notably important, since I have a strong background in Unity + C#)