---
title: "TS8002 UNKNOWN_TYPE: an error code of the TypeShade compiler"
description: "TS8002 UNKNOWN_TYPE, an error code of the TypeShade compiler. A type name that nothing declares, in a parameter, a type argument, an alias…"
url: https://typeshade.dev/reference/errors/ts8002/
language: en
---

# `TS8002`

Front-end code `UNKNOWN_TYPE`

A type name that nothing declares, in a parameter, a type argument, an alias, an `implements` clause or a base class, or a type that this surface does not take where the mapper reads one ([Rule 2.1](https://typeshade.dev/reference/rules/2-1/)). A base that the file declares and does not collect as a struct is `STRUCT_FIELD`.

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"

function shade(x: float): f32 {
  return x * 0.5
}

@fragment
export function main(uv: location<0, vec2>): vec4 {
  return vec4(uv, shade(uv.x), 1.)
}
```

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

**TS8002** error, line 3: Unknown type "float". GLSL's and HLSL's float is `f32` here.

## How to fix it

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

example.shade.ts

```ts
"use typeshade"

function shade(x: f32): f32 {
  return x * 0.5
}

@fragment
export function main(uv: location<0, vec2>): vec4 {
  return vec4(uv, shade(uv.x), 1.)
}
```

## The rules this enforces

**[Rule 2.1](https://typeshade.dev/reference/rules/2-1/) Test**

Every author-facing name must come from exactly one of three sources:

**[Rule 4.1](https://typeshade.dev/reference/rules/4-1/) Test**

Every type an author writes must be a type borrowed from WGSL under a TypeScript spelling, a member of the `f64` family ([Rule 4.4](https://typeshade.dev/reference/rules/4-4/)), a key type, or a type ECMAScript defines that the compiler represents ([Rule 1.5](https://typeshade.dev/reference/rules/1-5/)).

**[Rule 4.8](https://typeshade.dev/reference/rules/4-8/) Test**

Every `matCxR` with `C` and `R` in 2, 3, 4 must be a type, and a square one must also answer to `matN`.

**[Rule 6.2](https://typeshade.dev/reference/rules/6-2/) Test**

A storage binding’s access mode is inferred from what the program does: a binding that some entry writes, by assignment, a mutating method, an atomic builtin, or a write through a function or a reference parameter, is `var<storage, read_write>`, and every other storage binding is `var<storage, read>`.

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

The refusals of surface §28 (a union of two GPU types, a string type, an absent literal outside the positions of [Rule 7.10](https://typeshade.dev/reference/rules/7-10/), a mixed tuple, a rest tuple, `symbol`, an intersection of carriers, `instanceof`, `in`) must apply to expressions as they do to types, each in one sentence.

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

`T | undefined` and `T | null` are optional values.

**[Rule 8.18](https://typeshade.dev/reference/rules/8-18/) Test**

A function whose parameter has a function type, written out (`f: (x: f32) => f32`) or through a type alias of one, takes a function: a function declared at the top of the file or of a namespace, a method, a static method, a constructor, a field that holds a function ([Rule 8.16](https://typeshade.dev/reference/rules/8-16/)) and a local function ([Rule 8.17](https://typeshade.dev/reference/rules/8-17/)).

**[Rule 8.19](https://typeshade.dev/reference/rules/8-19/) Test**

A function that writes no return type returns what its body does, as TypeScript infers it: a function of the file or of a namespace, a local function ([Rule 8.17](https://typeshade.dev/reference/rules/8-17/)), each instance of a generic function ([Rule 8.9](https://typeshade.dev/reference/rules/8-9/)) and of a function that takes a function ([Rule 8.18](https://typeshade.dev/reference/rules/8-18/)), a method, a getter and a field that holds a function ([Rule 8.16](https://typeshade.dev/reference/rules/8-16/)) take the type of their first `return` with a value, the `return`s after it are typed against that type as against a written one, and one with no such `return` returns nothing.

**[Rule 12.4](https://typeshade.dev/reference/rules/12-4/) Test**

One mistake reads as one diagnostic; a refusal must not be followed by further diagnostics about the same mistake.

**[Rule 12.6](https://typeshade.dev/reference/rules/12-6/) Test**

A requirement the front end can check must be checked at the front end, in the author’s words, and not left to Tint or a driver.

## 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/array-limits/module-check.ts:22`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/array-limits/module-check.ts#L22)
- [`src/compiler/ts/array-limits/written-length.ts:31`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/array-limits/written-length.ts#L31)
- [`src/compiler/ts/bindings.ts:277`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/bindings.ts#L277) (4 sites)
- [`src/compiler/ts/generic-structs.ts:111`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/generic-structs.ts#L111)
- [`src/compiler/ts/generics.ts:109`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/generics.ts#L109)
- [`src/compiler/ts/lower/expression-array.ts:101`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/lower/expression-array.ts#L101) (2 sites)
- [`src/compiler/ts/lower/expression-array/fold.ts:29`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/lower/expression-array/fold.ts#L29) (2 sites)
- [`src/compiler/ts/lower/expression-array/untyped-list.ts:52`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/lower/expression-array/untyped-list.ts#L52)
- [`src/compiler/ts/lower/expression-call.ts:619`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/lower/expression-call.ts#L619)
- [`src/compiler/ts/lower/function-signature/parameters.ts:158`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/lower/function-signature/parameters.ts#L158)
- [`src/compiler/ts/lower/function.ts:326`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/lower/function.ts#L326) (3 sites)
- [`src/compiler/ts/lower/function/type-arguments.ts:98`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/lower/function/type-arguments.ts#L98)
- [`src/compiler/ts/optional/positions.ts:88`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/optional/positions.ts#L88) (2 sites)
- [`src/compiler/ts/semantic.ts:135`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/semantic.ts#L135) (2 sites)
- [`src/compiler/ts/source-file.ts:477`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/source-file.ts#L477)
- [`src/compiler/ts/type-map.ts:1184`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/type-map.ts#L1184)
- [`src/compiler/ts/type-map/storage-texture.ts:28`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/type-map/storage-texture.ts#L28)
- [`src/core/coverage/wgsl/predeclared-types.ts:111`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/coverage/wgsl/predeclared-types.ts#L111)
