index.ts
// void, never
function sayHello(): void {
console.log("hello");
}
function showError(): never {
throw new Error();
}
function inLoop(): never {
while (true) {
// ....
}
}
// enum
// 수동으로 값을 주지 않으면 값이 0, 1, 2, ....
enum Os {
Window,
Ios,
Android,
}
console.log(Os[1]); // "Ios"
console.log(Os["Ios"]); // 1
// Window, Ios, Android만 사용 가능
let myOs: Os;
myOs = Os.Window;
// null, undefined
let a: null = null;
let b: undefined = undefined;
index.js
// void, never
function sayHello() {
console.log("hello");
}
function showError() {
throw new Error();
}
function inLoop() {
while (true) {
// ....
}
}
// enum
// 수동으로 값을 주지 않으면 값이 0, 1, 2, ....
var Os;
(function (Os) {
Os[Os["Window"] = 0] = "Window";
Os[Os["Ios"] = 1] = "Ios";
Os[Os["Android"] = 2] = "Android";
})(Os || (Os = {}));
console.log(Os[1]); // "Ios"
console.log(Os["Ios"]); // 1
// Window, Ios, Android만 사용 가능
let myOs;
myOs = Os.Window;
// null, undefined
let a = null;
let b = undefined;