---
title: "TS8041 TEXTURE_ARGUMENT: a TypeShade compiler error code"
description: "TS8041 TEXTURE_ARGUMENT, an error code of the TypeShade compiler. A plain argument of a texture read that the target has no overload for…"
url: https://typeshade.dev/reference/errors/ts8041/
language: en
---

# `TS8041`

Front-end code `TEXTURE_ARGUMENT`

A plain argument of a texture read that the target has no overload for: a coordinate or gradient of the wrong width for the texture's dimension or of an element kind that the read does not take, a layer, mip level or sample index that is not a whole number of 0 or more, or a `level`, `bias` or `depth_ref` that is not an `f32`. A texture that is wrong for the call, such as a sampled texture handed to `textureStore`, is `TYPE_MISMATCH`.

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"

declare const tex: texture_2d<f32>
declare const smp: sampler

@fragment
export function main(uv: location<0, vec2>): vec4 {
  return textureSample(tex, smp, vec3(uv, 0.))
}
```

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

**TS8041** error, line 8: `textureSample` on a `texture_2d`<`f32`> takes a `vec2` coordinate; got `vec3`.

## How to fix it

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

example.shade.ts

```ts
"use typeshade"

declare const tex: texture_2d<f32>
declare const smp: sampler

@fragment
export function main(uv: location<0, vec2>): vec4 {
  return textureSample(tex, smp, uv)
}
```

## See also

**[`SD0015`](https://typeshade.dev/reference/errors/sd0015/)**

array-texture layer must be an integer

- [Resources](https://typeshade.dev/guide/language/resources/)
- [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/expression-call/args.ts:66`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/lower/expression-call/args.ts#L66) (5 sites)
