Here are some notes on the Pluralsight course 'TypeScript 4: Getting Started'.
TypeScript is a superset of JavaScript to help write code faster, and compiles to JavaScript that will run in Node.js or any modern browser.
The demo project was created in Visual Studio Code.
Installation
To install TypeScript globally, enter the following in a terminal (e.g. Visual Studio Code):
npm install -g typescript
Compiling
cd to dir with .ts file, then
tsc filename.ts
Start Server
cd to root dir of project, then
npm start
then go to http://localhost:8080/ in a browser (or different port number).
Default Compiler Options
tsc --init
Notes
- Valid JavaScript is valid TypeScript, i.e. you can write JS code in a TS file.
- To assert object is non null (e.g you know they exist in the html file) add an exclamation mark ! after the object. Example: variable!.innerText = "e.g.";
Created: 04-Sep-2022