TS8035
On this page

TS8035

Front-end code CLASS_MEMBER

A class member shape the surface does not take, or a use of a member the class rules refuse, and a new that builds no class (Rule 8.13).

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

When it fires

A class member shape the surface does not take, or a use of a member the class rules refuse, and 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, and so does a field holding a function, which is a method (Rule 8.16). What is refused, in the declaration: a field holding a function when the field is static, or when the function takes type parameters, is async or a generator, or is an expression body with no return type; a static block, an index signature, a second constructor, a second body for a method, a decorator on a method or on a parameter property, an async or generator method, an abstract member with a body or an initializer, an abstract method or accessor in a class that is not abstract or in the class a mixin returns, an abstract overload signature of a method whose body is not, a class that is not abstract and leaves an abstract method or accessor unimplemented (an abstract field is a member of every struct below it), one name declared as two kinds of member, or as another kind than the class it extends declares it, two members that would emit one function or constant name (a private name loses its #), and a parameter named self_, the name the emitted function gives its object. A second body and an abstract member are said where they are written, whether or not the class is instantiated or the mixin applied. In a use: this outside a method, or naming an instance field in a static one; super.m with no body above to name, or naming a field holding a function; an instance method called on the class or a static one on a value; a member the class does not have; a # member reached outside its class body; a getter with no setter assigned, or a setter with no getter read; a compound assignment through a getter and setter whose object would run twice; a method that changes its object called on something it cannot write (a parameter, a const whose value something else may hold, a dropped value) or used as a value when it returns nothing. In a new, once for the file where the new is written, an abstract class, new this() outside a static member, and a target that resolves to something other than a class — a WGSL constructor or cast (new vec3f()), a type alias of one (type S = vec3), a WGSL type with no constructor (new sampler()) or one the library declares for TypeScript (new Array(4)), a function (Math.sin and an imported one included), an enum or one of its members, a namespace, Math, console or Symbol, an interface or type alias, a type parameter, a mixin applied to a class, or a value (PI included). A target nothing declares, and a member the object before it does not have (new Math.Foo()), is UNKNOWN_NAME. A getter or setter missing its type is UNKNOWN_TYPE, a readonly field written outside the constructor CONST_ASSIGN.

Example

example.shade.ts
"use typeshade"
class Ray {
origin: vec3
static count: f32 = 0.
static { Ray.count = 1. }
}
@fragment
export function main(@location(0) uv: 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(@location(0) uv: 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, @builtin, @location, @interpolate, @invariant, @blend_src, and @diagnostic (the last four since #168, surface §53 and §54); every other WGSL attribute is either inferred by the compiler or carried as an argument (@compute([64, 1, 1]) carries @workgroup_size), and a decorator outside that list must be refused.
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 top-level function; an entry method on a class must be refused.
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, 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 (Rule 8.10); 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

TS8002 UNKNOWN_TYPE
A type name nothing declares, said once for the file wherever it is written (a parameter, a claim, a type argument, B<vec3<Foo>> included, an alias, an implements clause, the base a class or an interface extends, a body no call lowers), a type the library declares for TypeScript alone (Number) where the file declares none of its name, or a type this surface does not take in a position the mapper reads (Rule 2.1).
TS8005 CONST_ASSIGN
An assignment to a name that cannot change, such as a const or a read-only resource.
TS8022 UNKNOWN_NAME
Reference to a name TypeShade cannot resolve (identifier, struct field, or struct shape) that is not a function call (UNKNOWN_FN) or a type name (UNKNOWN_TYPE), in a body a call lowers or in one no call lowers; a name the library declares for TypeScript's own use (Object, Math, Symbol), or the file declares as an enum, a namespace, a class or a type, read as a value says what it is.

Source

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

Edit this page Report a problem