---
title: "TS8008 LOOP_INDUCTION: a TypeShade compiler error code"
description: "TS8008 LOOP_INDUCTION, an error code of the TypeShade compiler. A for...of loop that does not declare one element…"
url: https://typeshade.dev/reference/errors/ts8008/
language: en
---

# `TS8008`

Front-end code `LOOP_INDUCTION`

A `for...of` loop that does not declare one element, as `for (const x of xs)` or `for (let x of xs)` does.

The registry has no documentation comment for this constant, so the line above is written by this site from the messages the compiler raises it with.

The registry text and every compiler message on these pages are the compiler's own English.

## Example

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.)
}
```

Compiled at build time against the pinned compiler, this program gets:

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

## How to fix it

The same program, corrected. It compiles with no diagnostic.

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.)
}
```

## See also

- [Control flow](https://typeshade.dev/guide/language/control-flow/)
- [Error codes](https://typeshade.dev/reference/errors/)

## Source

Where the compiler raises this code at commit af54ddad5, one line per file:

- [`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 sites)
- [`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)
