...

Web Technologies - TypeScript

Back to Course

Lesson Description


Lession - #1442 TypeScript Simple Types


What are the three main simple types in TypeScript?
TypeScript Simple Types boolean-true or false values.

number-whole numbers and floating point values.

string- text values like" TypeScript Rocks"

Type Assignment
When creating a variable, there are two main ways TypeScript assigns a type
  • Explicit
  • Implicit In both examples below firstName is of type string

    Explict Type
    Explicit- writing out the type

    
    let firstName string = " Dylan";
    


    Explicit type assignment are easier to read and further purposeful.

    Implicit Type
    Implicit- TypeScript will" guess" the type, based on the assigned value

    
    let firstName = " Dylan";
    


    Note Having TypeScript" guess" the type of a value is called infer.

    Implicit assignment forces TypeScript to infer the value.

    Implicit type assignment are shorter, faster to class, and often used when developing and testing.