TS8018
Front-end code ASSIGN_TARGET
An assignment or ++/-- target that is not a writable place, such as a temporary. An unknown name is UNKNOWN_NAME, and a write to a known immutable binding is CONST_ASSIGN.
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"
@fragmentexport function main(uv: location<0, 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.
"use typeshade"
@fragmentexport function main(uv: location<0, vec2>): vec4 { let st = uv st.x = 1. return vec4(st, 0., 1.)}The rules this enforces
- 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.17 Test
- A local function (a
constthat holds an arrow function or a function expression, or afunctiondeclaration, 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
Source
Where the compiler raises this code at commit af54ddad5, one line per file:
-
src/compiler/ts/lower/class-access.ts:350 -
src/compiler/ts/lower/control/for-update.ts:122 -
src/compiler/ts/lower/statement/assign.ts:113 -
src/compiler/ts/lower/statement/lvalue.ts:85(5 sites) -
src/compiler/ts/lower/statement/writable.ts:51(4 sites) -
src/language-service/diagnostics/refused-uses.ts:113