# Google TypeScript Style

[GTS](https://www.npmjs.com/package/gts)는 Google의 TypeScript 스타일 가이드이며 포맷터(formatter), 린터(linter), 자동 코드 수정(automatic code fixer)의 구성(configuration)입니다. 이 구성을 사용해 TypeScript 프로젝트를 손쉽게 시작할 수 있습니다.

{% embed url="<https://github.com/google/gts>" %}

## GTS로 프로젝트 시작하기

GTS를 사용해 프로젝트를 시작하는 방법은 다음과 같이 간단합니다.

```bash
npx gts init
```

앞서 작성한 명령은 TypeScript 프로젝트 설정에 필요한 `tsconfig.json`, `.eslintrc.json` , `.prettierrc.js` 파일을 생성하고, `package.json` 파일을 만든 후 (설치 과정 옵션 질문에 `Y` 답변 시), 의존 패키지까지 설치합니다.

```bash
.
├── src/
│   └── index.ts        # 엔트리 파일
├── .eslintignore       # ESLint 제외 항목
├── .eslintrc.json      # ESLint 구성
├── .prettierrc.js      # Prettier 구성
├── tsconfig.json       # TypeScript 구성
├── package.json
└── package-lock.json
```

## GTS 명령 목록

GTS는 다음 명령을 제공합니다. (`package.json` 파일 `scripts` 참고)

| 명                 | 설명                                    |
| ----------------- | ------------------------------------- |
| `npm run compile` | TypeScript 컴파일러를 사용하여 소스 코드를 컴파일합니다.  |
| `npm run lint`    | TypeScript 린팅을 통해 타입 문제를 확인합니다.       |
| `npm run fix`     | 가능한 경우, TypeScript 린팅 문제를 자동으로 수정합니다. |
| `npm run clean`   | 출력된 결과물을 모두 제거합니다.                    |

## 개별 파일 명령

디렉토리(폴더) 단위가 아닌, 개별 파일 단위로 명령을 실행할 수도 있습니다.

```bash
npx gts lint index.ts 
npx gts lint one.ts two.ts three.ts 
npx gts lint *.ts
```
