Posts > TS Basic: Intro

TS Basic: Intro

What

Typescript is a tool that provides type-checking before you run your code. Javascript provides dynamic typing running the code to see what happens. TS predicts what code is expected before it runs.

Why

  • TS will know what kind of type your variable is ( string, number, or object )
  • avoids type errors
  • if your function is non-existent it’ll inform you right away before running your code
  • if you have an issue with your object it’ll tell you which object and what type it should be used instead of just throwing a undefined
  • Static Type Checking
    • tools that help find bugs 🐞 before our code runs.
    • describes the shape and behavior of what our values will be when we run our program
    • TS tells us when thing might be going off the rails 🚂
  • captures Non-exception Failures
    1. undefined - instead of throwing it to you undefined TS will tell you the property does not exist and tell you the available property of the object
    2. Typos - TS caches typos
    3. uncalled function - throw errors on your uncalled/unused functions
    4. basic logic error

Installation of TSC ( Typescript Compiler )

global

npm install -g typescript

module level

npm install typescript

👌Bawas sa pagcheck sa console at browser kung may mali ba code mo.

Tags 🏷