TS8035
On this page

TS8035

Front-end code CLASS_MEMBER

A class member shape that the surface does not take, a use of a member that the class rules refuse, or a new that builds no class (Rule 8.13). Getters and setters, static fields and methods, overload signatures, abstract members, # private names and methods that change their object all compile. The message names the member or the target and the edit.

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 Ray {
origin: vec3
static count: f32 = 0.
static { Ray.count = 1. }
}
@fragment
export function main(uv: location<0, vec2>): vec4 {
return vec4(uv, 0., 1.)
}

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

TS8035 error, line 6: A static block runs when the class is defined, and a shader has no such moment. Give each static field its value where it is declared.

How to fix it

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

example.shade.ts
"use typeshade"
class Ray {
origin: vec3
static count: f32 = 1.
}
@fragment
export function main(uv: location<0, vec2>): vec4 {
return vec4(uv, 0., 1.)
}

The rules this enforces

Rule 6.7 Test
The attribute names the compiler reads are vertex, fragment, compute, workgroup_size, builtin, location, interpolate, invariant and blend_src (the last three since #168, surface §53).
Rule 6.10 Test
A local const binds its name once and leaves what it holds as writable as TypeScript does.
Rule 8.1 Test
An entry point is a function declaration at the top of the file or of a namespace, exported or not, with exactly one stage attribute written before the declaration: @vertex export function vs(…), @fragment …, or @compute([x, y?, z?]) ….
Rule 8.9 Test
Method dispatch must be static, and a generic function or class must be compiled once per set of type arguments the program uses (Rule 3.9).
Rule 8.10 Test
A method that writes its object (assigns to this or to a field, a component or an element of it, applies ++ or -- to one, hands one to a parameter that its function writes (Rule 8.25), or calls such a method or reads such a getter on this, on a field, a component or an element of it whatever class that field is, or through super) must take the object by reference, and may return a value like any other method; a base’s body that a class calls through super and that writes its object takes it by reference too, and so does the copy of a method that takes a function (Rule 8.18) when a function handed over writes the variable the call is on.
Rule 8.11 Test
A get or set accessor is a function of the module, Owner_get_x or Owner_set_x, which takes its object as a method does (Rules 8.10 and 8.28); a read of o.x must call the getter, and an assignment, a compound assignment, ++ and -- must call the setter with the new value, the compound forms reading the old one through the getter.
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.13 Test
A static field must be a module constant Owner_x when nothing in the program writes it, and a module variable in the per-invocation space (Rule 6.5) when something does; a readonly static is never written.
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.
Rule 8.16 Test
An instance field that holds an arrow function or a function expression is a method of its class under the field’s name: the function’s parameters, return type and body are the method’s, an expression body is the value it returns, and this in it is the object, as it is in TypeScript.

See also

Source

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

Edit this page Report a problem