TS8010
On this page

TS8010

Front-end code STRUCT_FIELD

An invalid struct field or declaration shape.

The registry text and every compiler message on these pages are the compiler's own English.

When it fires

An invalid struct field or declaration shape. Fieldless classes are accepted; this code still covers invalid field declarations and unsupported empty non-class structs.

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(@location(0) uv: 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(@location(0) uv: vec2): vec4 {
return vec4(tint(uv).rgb, 1.)
}

The rules this enforces

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, which reflect().vertex and the manifest both report.
Rule 6.9 Test
A struct must be the members written in it, in one of three spellings (class, interface, a type over an object literal).
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 26de7be8, one line per file:

Edit this page Report a problem