Typescript is just a type system.
We're just writing javascript code including types.
Browser don't understand typescript.
Helps us to catch errors during development.
Adding type annotation for analyze the code.
How typescript works in development?
No effects of how our code is getting executed.
There is no performance optimization in any logic we made.
There are two types of Types in typescript
Primitive types
number
boolean
void
undefined
string
symbol
null
Object types
functions
arrays
classes
objects
It's a code, we can tell typescript what type of value a variable will refer to
// number
let grapes : number = 12 ;
// string
let name : string = "John Doe" ;
// boolean
let hasValue : boolean = true ;
// null
let isnull : null = null ;
// undefined
let isundefined : undefined = undefined ;
// Date
let now : Date = new Date ( ) ;
// Array
let cart : string [ ] = [ 'apples' , 'grapes' , 'toothbrush' ] ;
// Function
let newFunction : void = ( i : number ) => {
console . log ( i )
// not returning anything
}