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
"use typeshade"
class Ray { origin: vec3 static count: f32 = 0. static { Ray.count = 1. }}
@fragmentexport 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.
"use typeshade"
class Ray { origin: vec3 static count: f32 = 1.}
@fragmentexport 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,invariantandblend_src(the last three since #168, surface §53). - Rule 6.10 Test
- A local
constbinds 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
thisor 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 onthis, on a field, a component or an element of it whatever class that field is, or throughsuper) must take the object by reference, and may return a value like any other method; a base’s body that a class calls throughsuperand 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
getorsetaccessor is a function of the module,Owner_get_xorOwner_set_x, which takes its object as a method does (Rules 8.10 and 8.28); a read ofo.xmust 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
#xmust be emitted without its#: a field as the struct memberx, a method asOwner_x, an accessor asOwner_get_xandOwner_set_x, a static field asOwner_x. - Rule 8.13 Test
- A static field must be a module constant
Owner_xwhen nothing in the program writes it, and a module variable in the per-invocation space (Rule 6.5) when something does; areadonlystatic is never written. - Rule 8.15 Test
- A member declared
privatemay be named only inside the body of the class that declares it, and one declaredprotectedonly 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
thisin 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:
-
src/compiler/ts/builtin-check.ts:448 -
src/compiler/ts/lower/class-access/checks.ts:28 -
src/compiler/ts/lower/class-methods/push-diag.ts:11 -
src/compiler/ts/lower/expression-prop.ts:172(3 sites) -
src/compiler/ts/lower/function-signature/parameters.ts:133 -
src/compiler/ts/lower/function.ts:2486 -
src/compiler/ts/lower/new-target.ts:71(3 sites) -
src/compiler/ts/lower/statement/writable.ts:59(2 sites) -
src/compiler/ts/semantic.ts:293 -
src/compiler/ts/structs/diagnostics.ts:7 -
src/language-service/diagnostics/refusal-tables.ts:11(2 sites) -
src/language-service/diagnostics/refused-attributes.ts:64