---
title: "TS8008 LOOP_INDUCTION: TypeShade 컴파일러가 진단에 붙이는 오류 코드 한 가지"
description: "TS8008 LOOP_INDUCTION, TypeShade 컴파일러의 오류 코드입니다. for...of 루프가 for (const x of xs)나 for (let x of xs)처럼 요소 하나를 선언하지 않습니다."
url: https://typeshade.dev/ko/reference/errors/ts8008/
language: ko
---

# `TS8008`

프런트엔드 코드 `LOOP_INDUCTION`

`for...of` 루프가 `for (const x of xs)`나 `for (let x of xs)`처럼 요소 하나를 선언하지 않습니다.

레지스트리에는 이 상수에 대한 문서 주석이 없습니다. 그래서 위 설명은 컴파일러가 이 코드와 함께 내는 메시지를 보고 이 사이트가 쓴 것입니다.

레지스트리 설명과 컴파일러 메시지는 컴파일러 원문이라 한국어 페이지에서도 영어로 둡니다.

## 예제

example.shade.ts

```ts
"use typeshade"

@fragment
export function main(uv: location<0, vec2>): vec4 {
  let g = 0.
  const xs: array<vec2, 3> = [vec2(1.), vec2(2.), vec2(3.)]
  for (const [a, b] of xs) {
    g += a
  }
  return vec4(g, g, g, 1.)
}
```

빌드할 때 고정된 컴파일러로 이 프로그램을 컴파일하면 다음 진단이 나옵니다.

**TS8008** error, 7행: for-of declares one element: \`for (const x of xs)\` or \`for (let x of xs)\`.

## 고치는 법

같은 프로그램을 고친 모습입니다. 진단 없이 컴파일됩니다.

example.shade.ts

```ts
"use typeshade"

@fragment
export function main(uv: location<0, vec2>): vec4 {
  let g = 0.
  const xs: array<vec2, 3> = [vec2(1.), vec2(2.), vec2(3.)]
  for (const x of xs) {
    g += x.x
  }
  return vec4(g, g, g, 1.)
}
```

## 함께 보기

- [제어 흐름](https://typeshade.dev/ko/guide/language/control-flow/)
- [오류 코드](https://typeshade.dev/ko/reference/errors/)

## 소스

커밋 af54ddad5에서 컴파일러가 이 코드를 내는 곳입니다. 파일마다 한 줄씩 적었습니다.

- [`src/compiler/ts/loop-bound/counted-for.ts:49`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/loop-bound/counted-for.ts#L49) (3곳)
- [`src/compiler/ts/lower/control.ts:195`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/lower/control.ts#L195)
- [`src/compiler/ts/lower/control/for-of.ts:48`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/lower/control/for-of.ts#L48)
- [`src/compiler/ts/lower/control/for-update.ts:45`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/lower/control/for-update.ts#L45)
