---
title: "TS8035 CLASS_MEMBER: an error code of the TypeShade compiler"
description: "TS8035 CLASS_MEMBER, an error code of the TypeShade compiler. A class member shape that the surface does not take…"
url: https://typeshade.dev/reference/errors/ts8035/
language: en
---

# `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](https://typeshade.dev/reference/rules/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

```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

```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](https://typeshade.dev/reference/rules/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](https://github.com/typeshade/typeshade/issues/168), surface §53).

**[Rule 6.10](https://typeshade.dev/reference/rules/6-10/) Test**

A local `const` binds its name once and leaves what it holds as writable as TypeScript does.

**[Rule 8.1](https://typeshade.dev/reference/rules/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](https://typeshade.dev/reference/rules/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](https://typeshade.dev/reference/rules/3-9/)).

**[Rule 8.10](https://typeshade.dev/reference/rules/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](https://typeshade.dev/reference/rules/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](https://typeshade.dev/reference/rules/8-18/)) when a function handed over writes the variable the call is on.

**[Rule 8.11](https://typeshade.dev/reference/rules/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](https://typeshade.dev/reference/rules/8-10/) and [8.28](https://typeshade.dev/reference/rules/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](https://typeshade.dev/reference/rules/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](https://typeshade.dev/reference/rules/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](https://typeshade.dev/reference/rules/6-5/)) when something does; a `readonly` static is never written.

**[Rule 8.15](https://typeshade.dev/reference/rules/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](https://typeshade.dev/reference/rules/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

- [Functions](https://typeshade.dev/guide/language/functions/)
- [Error codes](https://typeshade.dev/reference/errors/)

## Source

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

- [`src/compiler/ts/builtin-check.ts:448`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/builtin-check.ts#L448)
- [`src/compiler/ts/lower/class-access/checks.ts:28`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/lower/class-access/checks.ts#L28)
- [`src/compiler/ts/lower/class-methods/push-diag.ts:11`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/lower/class-methods/push-diag.ts#L11)
- [`src/compiler/ts/lower/expression-prop.ts:172`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/lower/expression-prop.ts#L172) (3 sites)
- [`src/compiler/ts/lower/function-signature/parameters.ts:133`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/lower/function-signature/parameters.ts#L133)
- [`src/compiler/ts/lower/function.ts:2486`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/lower/function.ts#L2486)
- [`src/compiler/ts/lower/new-target.ts:71`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/lower/new-target.ts#L71) (3 sites)
- [`src/compiler/ts/lower/statement/writable.ts:59`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/lower/statement/writable.ts#L59) (2 sites)
- [`src/compiler/ts/semantic.ts:293`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/semantic.ts#L293)
- [`src/compiler/ts/structs/diagnostics.ts:7`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/structs/diagnostics.ts#L7)
- [`src/language-service/diagnostics/refusal-tables.ts:11`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/language-service/diagnostics/refusal-tables.ts#L11) (2 sites)
- [`src/language-service/diagnostics/refused-attributes.ts:64`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/language-service/diagnostics/refused-attributes.ts#L64)
