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

# Rule 8.1

Chapter 8, Functions and entry points Test

An entry point is a function declaration at the top of the file or of a namespace, exported or not, with exactly one stage attribute written before the declaration: `@vertex export function vs(…)`, `@fragment …`, or `@compute([x, y?, z?]) …`. The order `export @vertex function` is accepted and means the same. An entry takes its declaration’s name, so `export default` on an entry must be refused with [`TS8028`](https://typeshade.dev/reference/errors/ts8028/) (“an entry takes its declaration’s name; write `export function k`”) (change 0130, D4, as amended by change 0140). A bare `@compute` and `@compute()` take the default size ([Rule 8.7](https://typeshade.dev/reference/rules/8-7/)). `@vertex` and `@fragment` take no argument list: `@vertex()` and an argument on either must be refused with `TS8028`. An entry written as a `const`, an arrow function or a function expression, and an entry method on a class, must be refused; the stage calls of change 0111 are refused ([Rule 6.7](https://typeshade.dev/reference/rules/6-7/)).

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

## Rationale

`this` is not a GPU instance, and an entry has no receiver. The stage marks the function, so it is the language’s attribute on the declaration ([Rule 1.8](https://typeshade.dev/reference/rules/1-8/)).

## Derives from

[Entry Points](https://gpuweb.github.io/gpuweb/wgsl/#entry-points); change `0111` (D1, replaced by change `0130`); change `0130`; change `0140`; surface §3 and §4.

## 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:

the front end’s entry reading in `src/compiler/ts/source-file.ts` and `decorated-form.ts`, pinned by `src/compiler/ts/stage3.test.ts` (both orders, a namespace entry, two stage attributes refused, an argument on `@vertex` or `@fragment` refused in both halves with [`TS8028`](https://typeshade.dev/reference/errors/ts8028/), `"@vertex" takes no argument: write "@vertex" and delete "(1)" (Rule 8.1).`, the empty argument list, `@vertex()` or `@fragment()`, refused with the same sentence and `delete "()"` while `@compute()` stays accepted (change 0130, amendment A1), a type argument on a stage attribute or on `@workgroup_size` refused as a decorator that is not a name is ([Rule 6.7](https://typeshade.dev/reference/rules/6-7/)), `export default` refused on `default` in both halves), `src/compiler/ts/stage-call.test.ts` (an entry written as a `const`, an arrow function or a function expression through a stage call, refused in both halves) and `src/language-service/new-entry-forms.test.ts`; [`TS8035`](https://typeshade.dev/reference/errors/ts8035/) (`A decorator has no place on "C.k"; an entry is a function declaration with a stage attribute, "@vertex export function vs(…) { … }".`), beside surface §7’s row “`@compute` method on a class”.

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

- [`src/compiler/ts/class-syntax-example.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/class-syntax-example.test.ts#L1)
- [`src/compiler/ts/class-syntax.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/class-syntax.test.ts#L1)
- [`src/compiler/ts/source-file.ts:2`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/source-file.ts#L2)
- [`src/compiler/ts/stage-call.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/stage-call.test.ts#L1)
- [`src/compiler/ts/stage-call.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/stage-call.ts#L1)
- [`src/compiler/ts/stage3.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/stage3.test.ts#L1)
- [`src/language-service/new-entry-forms.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/language-service/new-entry-forms.test.ts#L1)

## Explained in

The sections of the surface document that explain this rule, at commit af54ddad5:

- [§3 Entries — stage attributes and explicit builtins](https://github.com/typeshade/typeshade/blob/af54ddad5/docs/use-typeshade-surface.md#3-entries--stage-attributes-and-explicit-builtins)
- [§7 Diagnostics (required)](https://github.com/typeshade/typeshade/blob/af54ddad5/docs/use-typeshade-surface.md#7-diagnostics-required)

## Error codes that enforce it

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

**[`TS8028`](https://typeshade.dev/reference/errors/ts8028/) `ATTRIBUTE_NAME`**

A decorator or an entry form that this surface does not read: an identifier outside the attribute vocabulary (`@vertex`, `@fragment`, `@compute`, `@builtin`, `@location`), such as a misspelled `@vertx`; a WGSL attribute that the surface writes another way or does not borrow, such as a written `@diagnostic(…)`; a stage written as a call, such as `vertex(f)`; an entry that is written in a form that Rule 8.1 refuses, such as `export default`; or a decorator on a declaration or in a place that takes none ([Rule 6.7](https://typeshade.dev/reference/rules/6-7/)). Without this code the decorated function or field would silently stop being an entry point or an I/O field.

**[`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 7.10](https://typeshade.dev/reference/rules/7-10/) Test
- [Rule 8.2](https://typeshade.dev/reference/rules/8-2/) Test
- [Rule 1.8](https://typeshade.dev/reference/rules/1-8/)
- [Rule 6.7](https://typeshade.dev/reference/rules/6-7/)
- [Rule 8.7](https://typeshade.dev/reference/rules/8-7/)
- [Design rules](https://typeshade.dev/reference/rules/)
- [Error codes](https://typeshade.dev/reference/errors/)

## Source

The rule at commit af54ddad5:

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