---
title: "TS8020 FUNCTION_SHAPE: TypeShade 컴파일러가 진단에 붙이는 오류 코드 한 가지"
description: "TS8020 FUNCTION_SHAPE, TypeShade 컴파일러의 오류 코드입니다. TypeShade가 지원하지 않는 함수 선언이나 매개변수 모양입니다. 이름이나 본문이 없는 경우, 나머지 매개변수, 구조 분해 매개변수가 그렇습니다."
url: https://typeshade.dev/ko/reference/errors/ts8020/
language: ko
---

# `TS8020`

프런트엔드 코드 `FUNCTION_SHAPE`

TypeShade가 지원하지 않는 함수 선언이나 매개변수 모양입니다. 이름이나 본문이 없는 경우, 나머지 매개변수, 구조 분해 매개변수가 그렇습니다.

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

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

## 예제

example.shade.ts

```ts
"use typeshade"

function shade(x?: f32, y: f32): f32 {
  return (x ?? 0.5) * y
}

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

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

**TS8020** error, 3행: "y" is required and follows the optional parameter "x": a required parameter cannot follow an optional one (TypeScript's TS1016). Write "y?: T", or move it before "x".

## 고치는 법

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

example.shade.ts

```ts
"use typeshade"

function shade(y: f32, x?: f32): f32 {
  return (x ?? 0.5) * y
}

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

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

**[규칙 7.10](https://typeshade.dev/ko/reference/rules/7-10/) 테스트**

`T | undefined` and `T | null` are optional values.

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

An object has the identity a JavaScript object has (change 0142).

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

A function whose parameter has a function type, written out (`f: (x: f32) => f32`) or through a type alias of one, takes a function: a function declared at the top of the file or of a namespace, a method, a static method, a constructor, a field that holds a function ([Rule 8.16](https://typeshade.dev/ko/reference/rules/8-16/)) and a local function ([Rule 8.17](https://typeshade.dev/ko/reference/rules/8-17/)).

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

A function that writes no return type returns what its body does, as TypeScript infers it: a function of the file or of a namespace, a local function ([Rule 8.17](https://typeshade.dev/ko/reference/rules/8-17/)), each instance of a generic function ([Rule 8.9](https://typeshade.dev/ko/reference/rules/8-9/)) and of a function that takes a function ([Rule 8.18](https://typeshade.dev/ko/reference/rules/8-18/)), a method, a getter and a field that holds a function ([Rule 8.16](https://typeshade.dev/ko/reference/rules/8-16/)) take the type of their first `return` with a value, the `return`s after it are typed against that type as against a written one, and one with no such `return` returns nothing.

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

A kernel function’s parameter of an array with no size is the caller’s array (change 0142): the body reads its elements and its `.length`, writes its elements in place, and cannot assign it whole ([`TS8018`](https://typeshade.dev/ko/reference/errors/ts8018/)).

## 함께 보기

- [함수](https://typeshade.dev/ko/guide/language/functions/)
- [오류 코드](https://typeshade.dev/ko/reference/errors/)

## 소스

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

- [`src/compiler/ts/lower/function-args.ts:210`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/lower/function-args.ts#L210) (2곳)
- [`src/compiler/ts/lower/function-signature.ts:112`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/lower/function-signature.ts#L112) (3곳)
- [`src/compiler/ts/lower/function-signature/entry-refusals.ts:83`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/lower/function-signature/entry-refusals.ts#L83) (2곳)
- [`src/compiler/ts/lower/function-signature/parameters.ts:56`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/lower/function-signature/parameters.ts#L56) (8곳)
- [`src/compiler/ts/lower/function-types.ts:76`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/lower/function-types.ts#L76)
- [`src/compiler/ts/lower/function.ts:300`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/lower/function.ts#L300) (4곳)
- [`src/compiler/ts/lower/local-functions.ts:83`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/lower/local-functions.ts#L83) (2곳)
- [`src/compiler/ts/lower/runtime-array.ts:49`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/lower/runtime-array.ts#L49)
- [`src/compiler/ts/semantic.ts:304`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/semantic.ts#L304)
