---
title: "규칙 8.15: 함수와 진입점, TypeShade 셰이더 언어 설계 규칙과 그 근거, 출처, 검증 방식"
description: "TypeShade 언어 설계 규칙 8.15(함수와 진입점)입니다. A member declared private may be named only inside the body of the class that declares it…"
url: https://typeshade.dev/ko/reference/rules/8-15/
language: ko
---

# 규칙 8.15

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

A member declared `private` may be named only inside the body of the class that declares it, and one declared `protected` only inside the bodies of that class and of the classes that extend it, on an object of the naming body’s own class or of one that extends it; a name either rule does not allow must be refused with the remedy. The declaration a name is checked against is the one the class whose body holds it sees, whichever class that body is compiled for ([Rule 8.9](https://typeshade.dev/ko/reference/rules/8-9/)), and a field a derived class declares again without a modifier is public, as TypeScript allows. An object literal cannot build a class with a `private` or `protected` field, and a spread and a destructuring pattern leave such a field out, as they leave out a private name ([Rule 8.12](https://typeshade.dev/ko/reference/rules/8-12/)).

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

## 근거

`private` and `protected` are TypeScript’s own access rules, and the front end does not run the checker that enforces them, so without this a program TypeScript refuses would compile; before this rule the two keywords were accepted and meant nothing.

## 출처

TypeScript’s [member visibility](https://www.typescriptlang.org/docs/handbook/2/classes.html#member-visibility) (TS2341, TS2445, TS2446; TS2322 for a literal of such a class); [Rule 8.12](https://typeshade.dev/ko/reference/rules/8-12/); surface §26.

## 검증 방식

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

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

`TS8035 CLASS_MEMBER` for each refusal (`"C.x" is private, so only the body of "C" may name it. Reach it through a public member of "C".`; `"C.p" is protected, and "D" may name it only on a "D"; this object is a "C". Reach it through a public member of "C".`), `TS8010 STRUCT_FIELD` for an object literal of such a class, pinned by `src/compiler/ts/class-syntax.test.ts`.

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

- [`src/compiler/ts/class-syntax.test.ts:1143`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/class-syntax.test.ts#L1143)

## 설명하는 절

커밋 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 항목에서 가리키는 진단 코드와, 레지스트리 설명에서 이 규칙을 가리키는 진단 코드입니다.

**[`TS8010`](https://typeshade.dev/ko/reference/errors/ts8010/) `STRUCT_FIELD`**

구조체 필드나 선언의 모양이 잘못되었습니다. 필드가 없는 클래스는 받아들입니다. 이 코드는 잘못된 필드 선언, 클래스가 아닌 빈 구조체, 적용되지 않는 필드의 `@align`, 사용처마다 location이 둘로 갈리는 사용자 정의 값을 다룹니다([규칙 6.6](https://typeshade.dev/ko/reference/rules/6-6/)).

**[`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.14](https://typeshade.dev/ko/reference/rules/8-14/) 테스트
- [규칙 8.16](https://typeshade.dev/ko/reference/rules/8-16/) 테스트
- [규칙 8.9](https://typeshade.dev/ko/reference/rules/8-9/)
- [규칙 8.12](https://typeshade.dev/ko/reference/rules/8-12/)
- [설계 규칙](https://typeshade.dev/ko/reference/rules/)
- [오류 코드](https://typeshade.dev/ko/reference/errors/)

## 소스

커밋 af54ddad5의 규칙 원문:

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