---
title: "Rule 6.7: Declarations and resources in TypeShade"
description: "Rule 6.7 of the TypeShade language design, in Declarations and resources."
url: https://typeshade.dev/reference/rules/6-7/
language: en
---

# Rule 6.7

Chapter 6, Declarations and resources Test

The attribute names the compiler reads are `vertex`, `fragment`, `compute`, `workgroup_size`, `builtin`, `location`, `interpolate`, `invariant` and `blend_src` (the last three since [#168](https://github.com/typeshade/typeshade/issues/168), surface §53). A stage is an attribute on the entry’s function declaration (`@vertex`, `@fragment`, `@compute([x, y?, z?])`, [Rule 8.1](https://typeshade.dev/reference/rules/8-1/)), and a kernel’s size the optional attribute `@workgroup_size([n])` ([Rule 8.22](https://typeshade.dev/reference/rules/8-22/)); `builtin` and `location` are types and `interpolate`, `invariant` and `blend_src` their options ([Rule 6.6](https://typeshade.dev/reference/rules/6-6/)). `@inout` and `@out` are no attributes: a parameter that writes one is [`TS8073`](https://typeshade.dev/reference/errors/ts8073/) ([Rule 8.25](https://typeshade.dev/reference/rules/8-25/), change 0142). Change 0131 removed `numerics`, and a leftover `numerics(...)` is an unknown function ([`TS8004`](https://typeshade.dev/reference/errors/ts8004/)); change 0132 removed `diagnostic`, whose work the compiler’s rewrite does ([Rule 8.5](https://typeshade.dev/reference/rules/8-5/)), and a leftover `@diagnostic(…)` decorator is [`TS8028`](https://typeshade.dev/reference/errors/ts8028/), which says to delete it; an option written on a stage call is named in the refusal of the call. Every other WGSL attribute is inferred by the compiler. The calls `vertex(f)`, `fragment(f)`, `compute([…], f)` and `workgroup_size([…], f)` must be refused with `TS8028`, whose text names the attribute and `tshc migrate` (change 0130, D4, as amended by change 0140); the decorators `@builtin`, `@location`, `@interpolate`, `@invariant` and `@blend_src` on a parameter or a field stay as change 0111 D5 says; a decorator outside the list must be refused.

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

## Rationale

a misspelled attribute or stage name would otherwise silently stop a function being an entry point. The attributes keep WGSL’s names (change 0100, change 0111 Amendment 1); a stage marks a function, so it is an attribute on the function’s declaration, and an input or an output is a value, so its attribute is part of its type ([Rule 1.8](https://typeshade.dev/reference/rules/1-8/)).

## Derives from

[Attributes](https://gpuweb.github.io/gpuweb/wgsl/#attributes); the fixture’s `attributes` list against the ambient library; change `0111` in `changes/`; change `0130`; change `0137`; change `0140`.

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

`src/compiler/ts/stage-call.ts` for the refusal of the stage calls: one [`TS8028`](https://typeshade.dev/reference/errors/ts8028/), an error, on the name called, in both halves (`a stage is an attribute on the function declaration: write "@vertex export function vs(…)", or run "tshc migrate" (change 0130)`), with an option named in the same diagnostic and what TypeScript says of the call’s arguments merged into it, and nothing else said about the refused entry ([Rule 12.4](https://typeshade.dev/reference/rules/12-4/)), pinned by `src/compiler/ts/stage-call.test.ts` (each of the four calls, a call with options, an arrow function and a function expression, a call in a namespace, a call that declares no entry, the file’s own declaration of such a name, which is not refused, and the file `tshc migrate` writes for each refused form, which compiles), `src/compiler/ts/numerics-removed.test.ts` and, for `diagnostic`, `src/compiler/ts/diagnostic-removed.test.ts`; and `src/compiler/ts/attribute-types.ts` for the attribute types, each read as the decorators it stands for, pinned by `src/compiler/ts/attribute-types.test.ts` and `src/language-service/new-entry-forms.test.ts` (the editor’s symbols, hover and completion on the attribute form, and no entry shown for a refused call); `TS8028 ATTRIBUTE_NAME` and `surface-names.test.ts`; a WGSL attribute the surface writes another way is named as WGSL’s, with where its intent goes (`"@workgroup_size" is WGSL's attribute, written here as @compute's argument: @compute([64]) or @compute([8, 8]); on a kernel function, @workgroup_size([n]).`), and not as an unknown one, `@size` anywhere but a field and `@align` anywhere but a field or a class as a struct field’s (`"@align" is WGSL's attribute for a struct field, not a function. Remove it.`), and `@std140` anywhere but a class as not applied; every decorator nothing reads is `TS8028`: on a declaration that takes none (a binding of any kind, an override, a `const` or `let` at any depth, an enum, an interface, a type alias, a namespace, a local function, a local class, a class expression, a `static` field), on a constructor, an overload signature, an abstract member, a mixin or an index signature, on a parameter of one of those, and one that is not a name, anywhere (`"@N.k" is not applied: an attribute is written "@name" or "@name(...)". Remove it.`); `@group` and `@binding` are named as not applied since `reflect()` reports the group and slot each binding gets, `@id` as not applied since the host sets an override by its name, and an attribute of the list written where the place does not apply it by what it marks (`"@location" does not apply to a parameter of a function that is not an entry: it marks an entry's input or output. Remove it.`, which Tint refuses too, [Rule 12.6](https://typeshade.dev/reference/rules/12-6/); on an overload signature, `Write it on the implementation.`); a method’s decorator, a function-valued field’s included ([Rule 8.16](https://typeshade.dev/reference/rules/8-16/)), is [`TS8035`](https://typeshade.dev/reference/errors/ts8035/) once, and the method is lowered, so a call of it says nothing more; the editor’s merge drops whatever TypeScript says inside a decorator the compiler refuses whole, its TS1206, TS1239, TS1249 and its TS2304 on a name the ambient library does not declare, and on a method its TS2318 for `TypedPropertyDescriptor` (Rule 12.4), and its TS1206 filter takes a stage attribute or `@workgroup_size` on a namespace’s function as it takes one on a top-level function, in every file ([Rule 1.7](https://typeshade.dev/reference/rules/1-7/)), a removed parameter qualifier `@inout` or `@out` on such a function’s parameter in every file, which the compiler refuses with [`TS8073`](https://typeshade.dev/reference/errors/ts8073/) ([Rule 8.25](https://typeshade.dev/reference/rules/8-25/)), and another decorator on such a function’s parameter only while `compile()` warns on it ([Rule 6.6](https://typeshade.dev/reference/rules/6-6/)), since the compiler reads both ([Rule 12.7](https://typeshade.dev/reference/rules/12-7/)); a static block, refused whole, keeps TypeScript’s TS1206 on its decorator; pinned by `src/compiler/ts/stage3.test.ts`, which also holds the attributes it answers for to the fixture’s WGSL list and reads the editor’s diagnostics on each case, and `src/language-service/service.test.ts`.

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

- [`src/compiler/ts/attribute-types.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/attribute-types.test.ts#L1)
- [`src/compiler/ts/attribute-types.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/attribute-types.ts#L1)
- [`src/compiler/ts/decorated-form.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/decorated-form.test.ts#L1)
- [`src/compiler/ts/decorated-form.ts:2`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/decorated-form.ts#L2)
- [`src/compiler/ts/diagnostic-removed.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/diagnostic-removed.test.ts#L1)
- [`src/compiler/ts/io-attribute-arguments.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/io-attribute-arguments.test.ts#L1)
- [`src/compiler/ts/kernel-workgroup.test.ts:2`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/kernel-workgroup.test.ts#L2)
- [`src/compiler/ts/numerics-removed.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/numerics-removed.test.ts#L1)
- [`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/core/spec-conformance/surface-names.test.ts:52`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/spec-conformance/surface-names.test.ts#L52)
- [`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)
- [`src/language-service/service-output-and-cache.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/language-service/service-output-and-cache.test.ts#L1)
- [`src/language-service/service.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/language-service/service.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)
- [§53 Entry IO: the interpolation an integer varying has no choice about](https://github.com/typeshade/typeshade/blob/af54ddad5/docs/use-typeshade-surface.md#53-entry-io-the-interpolation-an-integer-varying-has-no-choice-about)

## 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](https://typeshade.dev/reference/rules/8-1/) refuses, such as `export default`; or a decorator on a declaration or in a place that takes none (Rule 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.

**[`TS8073`](https://typeshade.dev/reference/errors/ts8073/) `REFERENCE`**

A reference form that is not supported yet ([Rule 8.8](https://typeshade.dev/reference/rules/8-8/), change 0142): `@inout` or `@out`, which are removed because an object parameter is the caller's object with no mark, and a call that may give back an object that has a name. The message names the edit.

## See also

- [Rule 6.6](https://typeshade.dev/reference/rules/6-6/) Test
- [Rule 6.8](https://typeshade.dev/reference/rules/6-8/) Test
- [Rule 1.7](https://typeshade.dev/reference/rules/1-7/)
- [Rule 1.8](https://typeshade.dev/reference/rules/1-8/)
- [Rule 8.1](https://typeshade.dev/reference/rules/8-1/)
- [Rule 8.5](https://typeshade.dev/reference/rules/8-5/)
- [Rule 8.16](https://typeshade.dev/reference/rules/8-16/)
- [Rule 8.22](https://typeshade.dev/reference/rules/8-22/)
- [Rule 8.25](https://typeshade.dev/reference/rules/8-25/)
- [Rule 12.4](https://typeshade.dev/reference/rules/12-4/)
- [Rule 12.6](https://typeshade.dev/reference/rules/12-6/)
- [Rule 12.7](https://typeshade.dev/reference/rules/12-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:559`](https://github.com/typeshade/typeshade/blob/af54ddad5/docs/language-design.md#L559) (the design document)
- [`reqs/rules/RULE-0607.md`](https://github.com/typeshade/typeshade/blob/af54ddad5/reqs/rules/RULE-0607.md) (its traceability item)
