TypeScript Data Types system

When a variable is declared some part of memory is reserved. But how much memory will be reserved. It depends upon the data type of the variable.  i.e. how much memory will be reserved and which type of data can be stored in reserved memory is depends upon data type of the variable. The Type System of a language represents these data types.

Data types in TypeScript:

  1. Any Type: represents the super type of all data types in TypeScript. TypeScript provides the compile time data type-checking for the variables. In some situation we may not know what type of value for variable will come. These values may come from dynamic content e.g. from the user. In such cases, we want to opt-out of type-checking and let the values pass through compile-time checks. The any type is used for these variables.

  2. Built-in types:
  3. Data typeKeywordDescription
    NumbernumberIt represents a double precision 64-bit floating point values which can be used to represent both integers and fractions.
    StringstringIt represents a sequence of characters.
    BooleanbooleanIt represents logical values true and false.
    VoidvoidIt is used on function return types to represent non-returning functions.
    NullnullIt is used to represent an intentional absence of an object value.
    UndefinedundefinedIt represents uninitialized variables.
  4. User-defined types: include Enumerations (enums), classes, interfaces, arrays, and tuple.

Content Protection by DMCA.com
Please Share