TS8018
On this page

TS8018

Front-end code ASSIGN_TARGET

An assignment or ++/-- target that is not a writable place, such as a temporary or an input that has no writable value local.

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

When it fires

An assignment or ++/-- target that is not a writable place, such as a temporary or an input that has no writable value local. Whole writes to ordinary value parameters use automatic local copies. Unknown names use UNKNOWN_NAME; writes to known immutable bindings use CONST_ASSIGN.

Example

example.shade.ts
"use typeshade"
@fragment
export function main(@location(0) uv: vec2): vec4 {
vec2(uv).x = 1.
return vec4(uv, 0., 1.)
}

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

TS8018 error, line 5: Assignment target must be a name, or a field, component or element of one.

How to fix it

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

example.shade.ts
"use typeshade"
@fragment
export function main(@location(0) uv: vec2): vec4 {
let st = uv
st.x = 1.
return vec4(st, 0., 1.)
}

The rules this enforces

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.17 Test
A local function (a const that holds an arrow function or a function expression, or a function declaration, written inside a function’s body) is a function of the module named after the body that declares it (surface §14), and it may read and write the variables of the functions around it, as a TypeScript closure does.

See also

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