---
title: "TS8018 ASSIGN_TARGET: TypeShade 컴파일러가 진단에 붙이는 오류 코드 한 가지"
description: "TS8018 ASSIGN_TARGET, TypeShade 컴파일러의 오류 코드입니다. 임시 값처럼 쓸 수 있는 자리가 아닌 곳에 대입하거나 ++/--를 씁니다."
url: https://typeshade.dev/ko/reference/errors/ts8018/
language: ko
---

# `TS8018`

프런트엔드 코드 `ASSIGN_TARGET`

임시 값처럼 쓸 수 있는 자리가 아닌 곳에 대입하거나 `++`/`--`를 씁니다. 모르는 이름은 `UNKNOWN_NAME`이고, 알려진 불변 바인딩에 쓰는 것은 `CONST_ASSIGN`입니다.

레지스트리에는 이 상수에 대한 문서 주석이 없습니다. 그래서 위 설명은 컴파일러가 이 코드와 함께 내는 메시지를 보고 이 사이트가 쓴 것입니다.

레지스트리 설명과 컴파일러 메시지는 컴파일러 원문이라 한국어 페이지에서도 영어로 둡니다.

## 예제

example.shade.ts

```ts
"use typeshade"

@fragment
export function main(uv: location<0, vec2>): vec4 {
  vec2(uv).x = 1.
  return vec4(uv, 0., 1.)
}
```

빌드할 때 고정된 컴파일러로 이 프로그램을 컴파일하면 다음 진단이 나옵니다.

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

## 고치는 법

같은 프로그램을 고친 모습입니다. 진단 없이 컴파일됩니다.

example.shade.ts

```ts
"use typeshade"

@fragment
export function main(uv: location<0, vec2>): vec4 {
  let st = uv
  st.x = 1.
  return vec4(st, 0., 1.)
}
```

## 이 코드가 적용하는 규칙

**[규칙 8.11](https://typeshade.dev/ko/reference/rules/8-11/) 테스트**

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/ko/reference/rules/8-10/) and [8.28](https://typeshade.dev/ko/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.

**[규칙 8.17](https://typeshade.dev/ko/reference/rules/8-17/) 테스트**

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.

## 함께 보기

- [타입](https://typeshade.dev/ko/guide/language/types/)
- [오류 코드](https://typeshade.dev/ko/reference/errors/)

## 소스

커밋 af54ddad5에서 컴파일러가 이 코드를 내는 곳입니다. 파일마다 한 줄씩 적었습니다.

- [`src/compiler/ts/lower/class-access.ts:350`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/lower/class-access.ts#L350)
- [`src/compiler/ts/lower/control/for-update.ts:122`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/lower/control/for-update.ts#L122)
- [`src/compiler/ts/lower/statement/assign.ts:113`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/lower/statement/assign.ts#L113)
- [`src/compiler/ts/lower/statement/lvalue.ts:85`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/lower/statement/lvalue.ts#L85) (5곳)
- [`src/compiler/ts/lower/statement/writable.ts:51`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/lower/statement/writable.ts#L51) (4곳)
- [`src/language-service/diagnostics/refused-uses.ts:113`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/language-service/diagnostics/refused-uses.ts#L113)
