let a = "hello"
a = 39
이는 불가능하다.
처음에 hello 가 a에 들어가면서 a의 타입이 string으로 확정되기 때문이다.
let a: string;
a = "Mark"
이렇게 a의 타입을 미리 선언해줄 수 있다.
이러면 a에는 string 외의 다른 타입은 들어갈 수 없다.
let a: number
a = "Mark"
이렇게 하면 오류가 나게 된다.
ex.
function hello(b: number) {
}
hello(39)
이런 식으로도 활용할 수 있다.