Skip to content

davidhu2000/typescript_crash_course

Repository files navigation

TypeScript Crash Course

Code Triagers Badge

This guide assumes you have basic knowledge of how JavaScript works, so it will not go into details with explaining certain JavaScript topics.

TypeScript Benefits

  • an extra compliation step.
  • strong / static typing
  • type definitions for popular JS libraries
  • encapsulation - the ability to define data and a set of functions into a single component
  • private / public member variable decorators.

Installation and Basic Usage

npm install --global typescript

This will install TypeScript as a global module, so you can use it no matter what directory you are in. You can use the command tsc filename.ts to compile the TypeScript file into JavaScript.

Configuration

tsc --init

This command will create a tsconfig.json file in the root of the project folder. It specifies the global TypeScript project settings and compiler options. It will create a file similar to the file below:

{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "strict": true
  }
}

This has all the comments removed, but you can checkout the complete generated tsconfig.json here

You can checkout Compiler Options for more information.

You can create multiple tsconfig.json files within the same project directory, so different sub directories will use different compiler options.

Table of Contents

  1. types, variables, and functions
  2. interfaces and classes
  3. inheritance
  4. decorators
  5. generics

About

A crash course on how to use TypeScript

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published