// primary type
const myName:string = 'cloer'
const age:number = 13
const married:boolean = false
// Array
const weekdays:string[] = ['mon', 'tue', 'wed']
const weekend:Array<string> = ['sat', 'sun']
// tuple
const user:[string, number] = [myName, age]
// void
const voidFunc = ():void => {
// No return
}
// never
const naverFunc1 = ():never=>{
while(true){
// Infinite loop
}
}
const naverFunc2 = ():never=>{
throw new Error() // always throw error
}
// enum
enum Score {
C, // 0
B = 3, // 3
A // 4
}
console.log(Score[4]) // A
console.log(Score.C) //0
enum City {
Seoul = 'Korea',
Toronto = 'Canada',
NewYork = 'USA'
}
console.log(City.NewYork) // USA
const myScore:Score = Score.C
const myCity = City.Seoul
console.log(myScore) // 0
console.log(myCity) // Korea
// null, undefined
const n:null = null
const u:undefined = undefined