---
title: "규칙 8.16: 함수와 진입점, TypeShade 셰이더 언어 설계 규칙과 그 근거, 출처, 검증 방식"
description: "TypeShade 언어 설계 규칙 8.16(함수와 진입점)입니다. An instance field that holds an arrow function or a function expression is a method of its class under the field's name…"
url: https://typeshade.dev/ko/reference/rules/8-16/
language: ko
---

# 규칙 8.16

8장, 함수와 진입점 테스트

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. With no return type written, it returns what its body does, and an expression body that is an assignment, `++` or `--` runs as a statement ([Rule 8.19](https://typeshade.dev/ko/reference/rules/8-19/)). A static field that holds a function, a function with type parameters, and an `async` or generator function must be refused with the remedy. A member a class that extends declares again must keep the kind the class above gives it, as TypeScript requires (a field, a method or an accessor, a field that holds a function standing where a method was and a field where an abstract accessor was), and `super.f` on a field that holds a function must be refused; so must an accessor over an abstract field, which TypeScript takes and which a struct here cannot mean.

규칙 본문과 그 아래 항목은 설계 문서에 적힌 컴파일러 원문이라 한국어 페이지에서도 영어로 둡니다.

## 근거

`onHit = (d: f32): f32 => d * this.k` is how TypeScript code often writes a method, to keep `this` bound; a shader has no function value to hand anywhere, so the one thing such a field can be is the method it is written as, called as `o.onHit(d)`, and `this` is the object in both. A static one binds `this` to the class that declares it where a static method binds it to the class the call names ([Rule 8.13](https://typeshade.dev/ko/reference/rules/8-13/)), so it is written as the static method it means; type parameters need a generic function. TypeScript refuses a member that changes kind in a class that extends, and without the check each such program compiled to the derived class’s member where TypeScript’s object holds the base’s; a field is the object’s own, so `super` does not reach one. An abstract field is laid out in every struct below the class that declares it, so a body that class wrote reads the member and never an accessor a class below declares, 0 where TypeScript computes the getter; `abstract get f(): T` says the same thing and reaches the accessor.

## 출처

ECMAScript [class field definitions](https://tc39.es/ecma262/#sec-classfielddefinition-record-specification-type) and [arrow functions](https://tc39.es/ecma262/#sec-arrow-function-definitions) (`this` is the object the field initializer runs for); TypeScript’s override checks (TS2416, TS2423, TS2425, TS2426, TS2610, TS2611) and TS2855 (`super` on a field); [Rule 8.9](https://typeshade.dev/ko/reference/rules/8-9/); [Rule 8.13](https://typeshade.dev/ko/reference/rules/8-13/); surface §26.

## 검증 방식

테스트로 확인합니다. 테스트나 게이트 스크립트, CI 워크플로가 이 규칙을 가리키고, 아래 파일 가운데 하나라도 규칙을 더는 가리키지 않으면 추적 검사가 실패합니다.

컴파일러가 이 규칙을 적용하는 곳을 규칙이 직접 적은 내용입니다.

`TS8035 CLASS_MEMBER` for each refusal (`A static field holding a function is a static method: write "static f(...) { ... }".`; `"B.f" is a method, and the "A.f" it overrides is a field that holds a function; TypeScript refuses an override of another kind. Declare it as a field that holds a function, or rename it.`; `"super.f" names a field that holds a function, and a field is the object's own, which "super" does not reach. Declare "A.f" as a method, or write "this.f".`), pinned by `src/compiler/ts/class-syntax.test.ts` and `src/compiler/ts/class-methods.test.ts`, which also hold the three CPU paths to one value for a field that holds a function, an override of one, and a method a field overrides; `examples/gallery/class-parts/class-parts.shade.ts` in the compile gate.

커밋 af54ddad5에서 이 규칙을 확인하는 파일입니다. 파일마다 규칙을 처음 가리키는 줄로 연결했습니다.

- [`examples/shade-examples.test.ts:27`](https://github.com/typeshade/typeshade/blob/af54ddad5/examples/shade-examples.test.ts#L27)
- [`src/compiler/ts/class-methods.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/class-methods.test.ts#L1)
- [`src/compiler/ts/class-syntax.test.ts:1627`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/class-syntax.test.ts#L1627)

## 설명하는 절

커밋 af54ddad5의 언어 문서에서 이 규칙을 설명하는 절입니다.

- [§26 Classes with methods, a constructor and static functions](https://github.com/typeshade/typeshade/blob/af54ddad5/docs/use-typeshade-surface.md#26-classes-with-methods-a-constructor-and-static-functions)

## 적용하는 오류 코드

규칙이 Enforced by 항목에서 가리키는 진단 코드와, 레지스트리 설명에서 이 규칙을 가리키는 진단 코드입니다.

**[`TS8035`](https://typeshade.dev/ko/reference/errors/ts8035/) `CLASS_MEMBER`**

표면이 받지 않는 클래스 멤버 모양, 클래스 규칙이 거부하는 멤버 사용, 클래스를 만들지 않는 `new`입니다([규칙 8.13](https://typeshade.dev/ko/reference/rules/8-13/)). getter와 setter, static 필드와 메서드, 오버로드 시그니처, abstract 멤버, `#` 비공개 이름, 객체를 바꾸는 메서드는 모두 컴파일됩니다. 메시지가 멤버나 대상과 고칠 방법을 알려 줍니다.

## 함께 보기

- [규칙 8.15](https://typeshade.dev/ko/reference/rules/8-15/) 테스트
- [규칙 8.17](https://typeshade.dev/ko/reference/rules/8-17/) 테스트
- [규칙 8.9](https://typeshade.dev/ko/reference/rules/8-9/)
- [규칙 8.13](https://typeshade.dev/ko/reference/rules/8-13/)
- [규칙 8.19](https://typeshade.dev/ko/reference/rules/8-19/)
- [설계 규칙](https://typeshade.dev/ko/reference/rules/)
- [오류 코드](https://typeshade.dev/ko/reference/errors/)

## 소스

커밋 af54ddad5의 규칙 원문:

- [`docs/language-design.md:972`](https://github.com/typeshade/typeshade/blob/af54ddad5/docs/language-design.md#L972) (설계 문서)
- [`reqs/rules/RULE-0816.md`](https://github.com/typeshade/typeshade/blob/af54ddad5/reqs/rules/RULE-0816.md) (추적 항목)
