Hits bn

# 자주쓰는 타입변환

# object key to union

const myObject = {
    key1: "value1",
    key2: "value1",
};
type MY_OBJECT_KEYS = keyof typeof myObject; // "key1" | "key2"

# array to union (opens new window)

//TypeScript 3.4부터 as const를 통해 type assertion 가능
const pathType = ["FILE", "URL"] as const;
type PATH_TYPES = typeof pathType; //  "FILE" | "URL"
Last Updated: 3/23/2022, 7:11:31 PM