0. any 타입


let someValue: any = 5;
// any는 모든 타입이 올 수 있음

someValue = "hello"
someValue = true;

(왠만해서는 안하는게 좋다 , 타입스크립트를 쓰는 이유가 없어지기 때문이다)

1. 유니언 타입


제한된 타입을 동시에 지정 하고 싶을 때

let price: number | string

2. 타입 별칭 (Type Aliases)


같은 코드를 반복하는 것보다 코드를 타입으로 지정하고 재활용

type StrOrNum = number | string;

let totalCost : number;
let orderID : StrOrNum;

const calculateTotalCost = (price: StrOrNum , qty:number):void => {
  itemPrice = price;
};

const findOrderID = (customer : {costomerId : number | string, name: string},
, productId : number | string) : number | string
 => {
  return orderID;
}

3. 타입 가드 (Type Guard)


TypeScript 조건문에 typeofinstanceof를 사용하면, TypeScript는 해당 조건문 블록 내에서는 해당 변수의 타입이 다르다는 것(=좁혀진 범위의 타입)을 이해한다.

3-1) typeof