TS8010
On this page

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).

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
"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
"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 Test
An entry point’s inputs and outputs are explicit parameters and return values.
Rule 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); 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), which reflect().vertex and the manifest both report.
Rule 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 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 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 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
module validation failed

Source

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

Edit this page Report a problem