---
title: "TS8010 STRUCT_FIELD: an error code of the TypeShade compiler"
description: "TS8010 STRUCT_FIELD, an error code of the TypeShade compiler. An invalid struct field or declaration shape."
url: https://typeshade.dev/reference/errors/ts8010/
language: en
---

# `TS8010`

Front-end code `STRUCT_FIELD`

An invalid struct field or declaration shape. A class with no fields is accepted; this code covers an invalid field declaration, an empty struct that is not a class, an `@align` on a field, which is not applied, and a user-defined value whose uses give it two locations ([Rule 6.6](https://typeshade.dev/reference/rules/6-6/)).

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"

class Tint {
  rgb: vec3
  alpha: f32
}

function tint(uv: vec2): Tint {
  return { rgb: vec3(uv, 0.) }
}

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

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

**TS8010** error, line 9: Missing field "alpha" for struct Tint.

## How to fix it

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

example.shade.ts

```ts
"use typeshade"

class Tint {
  rgb: vec3
  alpha: f32
}

function tint(uv: vec2): Tint {
  return { rgb: vec3(uv, 0.), alpha: 1. }
}

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

## The rules this enforces

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

An entry point’s inputs and outputs are explicit parameters and return values.

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

The byte layout the emitted module assumes for a resource and the layout `reflect()` reports must agree byte for byte, under WGSL’s uniform and storage layout rules, and so must the layout the manifest carries ([Rule 11.10](https://typeshade.dev/reference/rules/11-10/)); a vertex entry’s vertex buffer is one layout, its `@location` inputs tightly packed in the order written and numbered in that order where no `location<n, T>` states the number ([Rule 6.6](https://typeshade.dev/reference/rules/6-6/)), which `reflect().vertex` and the manifest both report.

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

A struct must be the members written in it, in one of four spellings (`class`, `interface`, a `type` over an object literal, an object type literal written where a type stands).

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

A private name `#x` must be emitted without its `#`: a field as the struct member `x`, a method as `Owner_x`, an accessor as `Owner_get_x` and `Owner_set_x`, a static field as `Owner_x`.

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

A constructor’s parameter property (`constructor(public x: f32)`, or `private`, `protected` or `readonly` in place of `public`) is a field of its class, at the constructor’s place among the members, which the constructor assigns from the parameter before the field initializers run.

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

A member declared `private` may be named only inside the body of the class that declares it, and one declared `protected` only inside the bodies of that class and of the classes that extend it, on an object of the naming body’s own class or of one that extends it; a name either rule does not allow must be refused with the remedy.

## See also

**[`SD0020`](https://typeshade.dev/reference/errors/sd0020/)**

module validation failed

- [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/entry-locations.ts:69`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/entry-locations.ts#L69)
- [`src/compiler/ts/lower/expression-prop/object-literal.ts:74`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/lower/expression-prop/object-literal.ts#L74) (5 sites)
- [`src/compiler/ts/lower/function-signature/parameters.ts:316`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/lower/function-signature/parameters.ts#L316)
- [`src/compiler/ts/source-file.ts:383`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/source-file.ts#L383)
- [`src/compiler/ts/structs/diagnostics.ts:11`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/structs/diagnostics.ts#L11)
- [`src/compiler/ts/structs/entry-io.ts:186`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/structs/entry-io.ts#L186) (2 sites)
- [`src/language-service/diagnostics/refusal-tables.ts:10`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/language-service/diagnostics/refusal-tables.ts#L10)
