#2 Overview of TypeScript
#2.0 How Typescript Works
#2.1 Implicit Types vs Explicit Types
let a = "hello" // let a : string
a = "bye"
a = 1 // error : type number is ~~
// ๋ณ์ ์ ์ธ์ string์ผ๋ก ํ์ผ๋ฉด string์ผ๋ก ๋ฎ์ ์ ์์
// JS๋ ๋ฌธ์ ์์ง๋ง TS์์๋ ๋ฌธ์ ๊ฐ ๋จ
let b : boolean = "x" // error : "x"๋ boolean์ด ์๋
// ํ์
์ ์ ์ธํ๋ ๋ฐฉ์, ๋ช
์์ ์ผ๋ก ํ์
์ ์ ์ธํจ
// ๋ช
์์ ์ ์ธ์ ์ต์ํ ํ๋๊ฒ ์ข์ => ํ์
์ถ๋ก ์ ํ์ฑํ
let c = [1, 2, 3] // let c : number[]
c.push("1") // error : number array์ string์ ์ถ๊ฐํ๋ฉด ํ์
์ด ์์#2.2 Types of TS part One
#2.3 Types of TS part Two
#2.4 Types of TS part Three
Last updated