---
title: "TS8016 INDEX_OOB: an error code of the TypeShade compiler"
description: "TS8016 INDEX_OOB, an error code of the TypeShade compiler. A constant index outside the length of what it indexes."
url: https://typeshade.dev/reference/errors/ts8016/
language: en
---

# `TS8016`

Front-end code `INDEX_OOB`

A constant index outside the length of what it indexes.

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 {
  const w = array<f32, 3>(0.2, 0.5, 0.3)
  return vec4(uv, w[3], 1.)
}
```

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

**TS8016** error, line 6: Index 3 is out of range for length 3.

## 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 {
  const w = array<f32, 3>(0.2, 0.5, 0.3)
  return vec4(uv, w[2], 1.)
}
```

## See also

- [Types](https://typeshade.dev/guide/language/types/)
- [Error codes](https://typeshade.dev/reference/errors/)

## Source

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

- [`src/compiler/ts/lower/index-select.ts:143`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/lower/index-select.ts#L143) (2 sites)
