---
title: "Rule 8.12: Functions and entry points in TypeShade"
description: "Rule 8.12 of the TypeShade language design, in Functions and entry points."
url: https://typeshade.dev/reference/rules/8-12/
language: en
---

# Rule 8.12

Chapter 8, Functions and entry points Test

A private name `#x` must be emitted without its `#`: a field as the struct member `x`, a method as `Owner_x`, an accessor as `Owner_get_x` and `Owner_set_x`, a static field as `Owner_x`. It may be named only inside the body of the class that declares it, which is TypeScript’s rule and which the front end enforces because it does not run the checker; a public name never reaches a private member, and an object literal, a spread and a destructuring pattern do not reach one either. Two members of one class chain that would share an emitted name (`#x` beside `x`, a static field beside a function of its name, or `#x` declared by a class and again by one that extends it) must be refused.

The rule text and the parts under it are the compiler's own English, as the design document writes them.

## Rationale

WGSL and GLSL ES 3.00 have no private member and no `#` in a name, so privacy is a property of the source that the front end keeps, and it can keep it only while no emitted name stands for two members.

## Derives from

ECMAScript [private names](https://tc39.es/ecma262/#sec-private-names) as TypeScript spells them (TS18013 for an access from outside, TS2741 for a literal of such a class); [Rule 3.2](https://typeshade.dev/reference/rules/3-2/); surface §26.

## How it is verified

Checked by a test. A test, a gate script or a CI workflow names this rule, and the traceability check fails when a file listed below stops naming it.

Where the rule says the compiler enforces it:

`TS8035 CLASS_MEMBER` for an access from outside the class, for two members on one function name and for a static field and a function on one module name (`The static field "Base.#n" and the function "Base.n" would both be "Base_n": a private name is emitted without its "#". Rename one of them.`), `TS8010 STRUCT_FIELD` for two members on one struct member and for an object literal of a class with a private field, pinned by `src/compiler/ts/class-syntax.test.ts`; `examples/gallery/class-syntax/class-syntax.shade.ts`.

The files that verify it at commit af54ddad5, each at the first line that names the rule:

- [`examples/shade-examples.test.ts:27`](https://github.com/typeshade/typeshade/blob/af54ddad5/examples/shade-examples.test.ts#L27)
- [`src/compiler/ts/class-syntax.test.ts:300`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/class-syntax.test.ts#L300)

## Explained in

The sections of the surface document that explain this rule, at commit 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)

## Error codes that enforce it

The diagnostic codes the rule names under Enforced by, or whose registry text names the rule:

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

An invalid struct field or declaration shape. A class with no fields is accepted; this code covers an invalid field declaration, an empty struct that is not a class, an `@align` on a field, which is not applied, and a user-defined value whose uses give it two locations ([Rule 6.6](https://typeshade.dev/reference/rules/6-6/)).

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

A class member shape that the surface does not take, a use of a member that the class rules refuse, or a `new` that builds no class ([Rule 8.13](https://typeshade.dev/reference/rules/8-13/)). Getters and setters, static fields and methods, overload signatures, abstract members, `#` private names and methods that change their object all compile. The message names the member or the target and the edit.

## See also

- [Rule 8.11](https://typeshade.dev/reference/rules/8-11/) Test
- [Rule 8.13](https://typeshade.dev/reference/rules/8-13/) Test
- [Rule 3.2](https://typeshade.dev/reference/rules/3-2/)
- [Design rules](https://typeshade.dev/reference/rules/)
- [Error codes](https://typeshade.dev/reference/errors/)

## Source

The rule at commit af54ddad5:

- [`docs/language-design.md:938`](https://github.com/typeshade/typeshade/blob/af54ddad5/docs/language-design.md#L938) (the design document)
- [`reqs/rules/RULE-0812.md`](https://github.com/typeshade/typeshade/blob/af54ddad5/reqs/rules/RULE-0812.md) (its traceability item)
