# 객체 또는 배열에서 타입 추출하기

### typeof

값에서 타입을 뽑아옵니다.

```javascript
const user = { id: 1, name: 'kim' } as const
type User = typeof user; // { id: number, name: string }
```

### keyof

객체 타입의 키만 뽑아 유니온으로 만든다.

```javascript
type User = { id: number, name: string };
type UserKey = keyof User; // 꼭 keyof는 타입으로 선언된 타입 선언문에만 사용
// result : 'id' | 'name'
```

### keyof typeof

값에서 타입을 뽑고, 그 타입의 키를 뽑는다.

```javascript
const STATUS = {
  READY: 'ready',
  DONE: 'done'.
} as const

type STATUS_KEY = keyof typeof STATUS;
// result : 'READY' | 'DONE'
```

For the site tree, see the [root Markdown](https://slashpage.com/timmy.md).
