---
title: "TS8007 LOOP_INFINITE: a TypeShade compiler error code"
description: "TS8007 LOOP_INFINITE, an error code of the TypeShade compiler. A loop that certainly never ends: a while (true) or a for with no condition…"
url: https://typeshade.dev/reference/errors/ts8007/
language: en
---

# `TS8007`

Front-end code `LOOP_INFINITE`

A loop that certainly never ends: a `while (true)` or a `for` with no condition, written or folded from constants, with no `break` or `return`, or a `for` with constant bounds whose step does not move the counter toward its bound.

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 = uv.x
  while (true) {
    g = g * 0.5
  }
  return vec4(g, g, g, 1.)
}
```

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

**TS8007** error, line 6: while (true) has no break or return in its body, so it never ends. Leave it with a break, or write the exit into the condition.

## 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 = uv.x
  for (let i = 0; i < 4; i++) {
    g = g * 0.5
  }
  return vec4(g, g, g, 1.)
}
```

## The rule this enforces

**[Rule 7.5](https://typeshade.dev/reference/rules/7-5/) Test**

A `for` loop means what it means in TypeScript: its initializer runs once, its condition (`true` when it has none) is tested before each trip, and its update runs after each trip and at each `continue` (change 0136).

## 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:89`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/loop-bound/counted-for.ts#L89) (5 sites)
- [`src/compiler/ts/loop-bound/open-loop.ts:61`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/loop-bound/open-loop.ts#L61)
