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

# Rule 8.21

Chapter 8, Functions and entry points Test

A host call passes and returns host values: an `f32`, `f64`, `i32` or `u32` is a `number`, a `bool` a `boolean`, a vector a tuple of its components, `readonly` in the host view as an argument and as a result (change 0116, decision D1), a matrix a flat column-major array of its components, an `array<T, N>` an array of `N` host values of `T`, a struct an object of its fields, an instance of its exported class among them (change 0109), an `enum` member its number, and a value of a key type ([Rule 4.1](https://typeshade.dev/reference/rules/4-1/)), as a parameter or a result, one of its members as a string, which the call refuses when it is none of them, and a `Record` over a key type, as a parameter or a result, an object with one property for each member, which the call refuses when one is missing or another is there (change 0081); in a binding and in an array with no size, a key is its id, a number, and a `Record` the array of its values in id order. A parameter or a result written as an object type literal is a host value of the same form as an alias of that literal. The host view spells each host value with the name the shader writes, from the host type family that `typeshade/runtime` exports as types (change 0116): `f32`, `f64`, `i32` and `u32` are each a `number`, and `bool` a `boolean`, with the name as an optional phantom property, so that a plain literal is a value of each and no name is another; a vector is a `readonly` tuple of its scalar (`vec3`, `vec3u`), and a matrix a `readonly` tuple of its components, column-major, with its name as a scalar has its name (`mat4x4`, `mat4x4<f64>`, decision D9); `array<T, N>` is a `readonly T[]`; and an array with no size, which a kernel function and an entry’s binding take, is `array<T>`, its typed array or its array of objects below, and for a scalar or a vector `T` a `Buffer` of it, and for a vector also a `Buffer` of its scalar ([Rule 11.8](https://typeshade.dev/reference/rules/11-8/), decision D3; change 0138, Amendments A10, Q-I, and A11, Q5). A struct is spelled with the name the view declares for it, as an argument and as a result (decision D7): the object of its fields for an `interface` or a `type`, and the class for an exported class, whose instance a host builds with `new`, while the call still takes a plain object of the fields, a struct with a private field apart (below); a struct is spelled by its fields where the view declares no name for it, in a result of an abstract class’s struct, which is an object of its fields, in a constant, which is a frozen object of its fields, and in a binding and an array with no size where it holds a key or a `Record`, which they hold as ids; a binding of a struct type in the manifest’s `Pack` is the struct’s name, where the view declares one, beside the packed forms the runtime takes (decision D8). An enum, a key type and a `Record` keep the spelling the view gives them. The view imports the names it writes from the runtime it imports `Pack` from, and the family has one name for each value type the ambient library declares, and no other ([Rule 12.7](https://typeshade.dev/reference/rules/12-7/)). Null-only and three-state optionals, nullable classes and nested nullable fields also have no host representation (change 0098); optional storage cannot cross a host or entry boundary. A struct is checked by the fields it declares, wherever its object is taken (a parameter, a field, an element of an `array<T, N>`, an element of a kernel function’s array or a binding of an entry), and the check ignores the prototype; a struct a result holds is an instance of its class when the module exports the class as a value and the class is not abstract ([Rule 8.20](https://typeshade.dev/reference/rules/8-20/), change 0109, decision D1), with the fields its own properties and its constructor not run, and a plain object of its fields otherwise. A method of an instance takes and returns host values as a helper call does, and one that changes its object ([Rule 8.10](https://typeshade.dev/reference/rules/8-10/)) writes the instance’s fields back in place. A field that a private name `#x` declares ([Rule 8.12](https://typeshade.dev/reference/rules/8-12/)) is held under the key `"#x"` in the host value of its struct (change 0109, Amendment 2, decision D6). An instance has it as an own property, and every conversion of the call layer reads and writes it there, so an accessor or a method of the name `x` on the prototype answers for `x`. A plain object of the fields has no such key, and the check refuses it with the reason, which says to build the value with `new`, as surface §26 says of an object literal. A fieldless class is `{}` on the host and CPU. Its reflected memory footprint accounts for the GPU’s internal carrier: four bytes under natural layout, sixteen under std140, with no visible fields. Nested fields and array strides follow that footprint. Each argument is checked and converted: an `ArrayLike` of the right length becomes a fresh array, an `f32` is rounded as a buffer write rounds it, and a value that does not fit is refused with a `TypeError` naming the function, the parameter and its TypeShade type; the result aliases no argument and nothing the module keeps, and an exported constant is a frozen copy. A helper that writes an object parameter has no host call yet, and the host view says so with its reason (`parameter "p" is the caller's object, which the function writes, and a host call of it is not supported yet (change 0142, stage 2)`); a kernel function’s array with no size is the one object a host call writes in place ([Rule 8.23](https://typeshade.dev/reference/rules/8-23/)). A call of a function this rule and Rule 8.20 admit is synchronous, and no later tier changes that; as a helper’s parameter, a runtime-sized array, an atomic, a texture, a sampler and a binding have no host value, and neither has an optional value (`T | undefined`, [Rule 7.10](https://typeshade.dev/reference/rules/7-10/)), a struct with an optional field, an array of optionals or an optional parameter `x?: T`, as a parameter or as a result (change 0088, decision D4; change 0093, decision D7), the reason naming the parameter or the field (`field R.w: an optional value, f32 | undefined, has no host value yet (Rule 8.21)`): a host mapping such as `number | undefined` needs a later proposal.

A host call fills a trailing run of parameters that have a constant default, as a call inside a program does (surface §14, change 0164): the generated declaration writes each parameter of that run optional (`seed?: f32`), in the plain-data overload and in each `Buffer` overload, and the generated function uses the default when the argument is omitted or is `undefined`, as JavaScript does; `undefined` for a parameter that has no default is still a `TypeError`. A constant default is a literal, a module `const`, arithmetic of these, or a vector or a struct built of these, passed to the program as a tuple of its components or an object of its fields. A default that reads a binding, an `override` or a module variable, or that calls a function, is not filled by a host call yet: its parameter stays required, the doc comment of the declaration says `"k" has a default that reads a binding or calls a function, which a host call does not fill yet; pass it.`, and a call that omits it throws `scale() takes 2 arguments; got 1: "k" has a default that a host call does not fill yet.` (staged work, `docs/gap-register.md` G-43). An entry point’s parameters are not changed ([Rule 8.24](https://typeshade.dev/reference/rules/8-24/)). A binding of an entry a host calls (Rule 8.24) takes a host value too: a `uniform<T>` or a sized `storage<T>` takes `T`’s, a runtime-sized `storage<array<T>>` of scalars or vectors takes the scalar’s typed array (`Float32Array`, `Int32Array`, `Uint32Array`, or `Float64Array` for an `f64` and a `vecNf64`) with the vector’s components one after another, which the call pads to the element’s stride, one of structs takes an array of objects, one of scalars or vectors may be a `Buffer` of the scalars (Rule 11.8; change 0138, Amendment A10, Q-I), an atomic takes its integer’s, a `texture_2d<f32>` takes an image source (`ImageBitmap`, `ImageData`, `HTMLImageElement`, `HTMLCanvasElement`, `HTMLVideoElement` or `OffscreenCanvas`), uploaded at the call, and a `sampler` takes `{ filter?, address? }` (`'nearest'` or `'linear'`; `'clamp'`, `'repeat'` or `'mirror'`), or nothing for linear and clamp. A `uniform<T>` of a class the module exports also takes a `Uniform<T>`, and a `storage<array<T>>` of one a `Buffer<T>`, an exported binding among them (below). An emulated `f64` (change 0013’s split) is held by the GPU as two `f32`s, `hi` and `lo`, and a `vecNf64` as a plane of each: the runtime splits a double into them and joins them back, and binds the `_fp64` guard of a module that emulates one, which the host never passes; a `matNxN<f64>` has no host value yet. A storage binding the entry writes is read back into the caller’s value in place, so a written binding whose type is one scalar is passed as a typed array of length one. A `Buffer` the entry writes is not read back: its values stay on the device until its `read()` (below). A buffer binding of a program runtime’s draw or dispatch ([Rule 11.11](https://typeshade.dev/reference/rules/11-11/)) takes the same host value, for a storage array with no size of scalars or vectors also a `Buffer` of the scalars, or the host’s own buffer, and the host view types the module’s default export, its manifest, with the bindings each entry reaches and those values (change 0030). A geometry’s vertices take a `Buffer<f32>`, `Buffer<i32>` or `Buffer<u32>`, and its indices a `Buffer<u32>` (change 0138, Amendment A11, Q3). A kernel function ([Rule 8.22](https://typeshade.dev/reference/rules/8-22/)) called with plain data is asynchronous: it returns `Promise<void>`, or `Promise<R>` for a result `R`, and for an array it makes and returns (Rule 8.23, change 0114, S5) the value an array parameter of the same element takes, in one form, which the caller owns: the scalar’s typed array for a scalar or a vector element, a vector’s components one after another (`Promise<Float32Array>` for `f32[]` and `vec4f[]`, `Promise<Int32Array>` for `i32[]` and `vec2i[]`, `Promise<Uint32Array>` for `u32[]` and `vec2u[]`), and an array of objects for a struct `T` (`Promise<T[]>`), whose elements share objects as JavaScript would (Rule 8.23, Amendment A8, item 4), or for an array it grows with `push` (S5d) of the elements pushed; such a function takes no argument for that array; called on a resource, it returns at once a new `Buffer` on the call’s device, which the caller owns and disposes (Rule 11.8): a `Buffer` of the scalar for a scalar or a vector element (a `Buffer<f32>` of `4n` elements for `vec4f[]`), and a `Buffer<C>` for an element of an exported class `C` (change 0114, A1 item 7); with a length of 0 such a call throws a `RangeError` that says a `Buffer` of length 0 is not supported yet; such a call throws a `TypeError` that says it is not supported yet for an array it grows with `push`, a struct fill whose unwritten elements share one object, a struct of no exported class, and a length or a fill value that reads a resource, whose parameter the host view gives no `Buffer`; a call on a resource that also writes a plain array waits, and its promise gives the array it makes as plain data, the typed array or the array of objects above, not a `Buffer` (change 0114, Amendment A13; change 0138, Amendment A11, Q7); a call inside `fuse()` throws one too ([Rule 11.13](https://typeshade.dev/reference/rules/11-13/)); it runs on each tier that would run it with an array parameter of the same element in its place (Rule 11.8; change 0114, Amendment A1, item 8), so on WebGL2 where each loop writes an array of `f32`, `i32` or `u32` at `i`, and with a length of 0 it returns an empty array; its value parameters take the host values above, its arrays with no size take the scalar’s typed array (`Float32Array`, `Int32Array`, `Uint32Array`, a vector’s components one after another) or, for a struct, an array of objects, and each array it writes is read back into the caller’s in place. Called on a resource (below), it has a second signature, which takes a `Buffer` of the scalars for an array with no size of scalars or vectors, a `Buffer<C>` for one of an exported class `C`, a `Uniform<C>` for a parameter of type `C`, and a `Buffer` of one element for a number or a vector parameter, and which returns nothing, or for a result the result’s `Buffer`s (below); and a third, for a call on a resource that writes a plain array, which returns a promise of its result as plain data (below). An array a loop pushes onto may come with its length, `{ array, length, offset? }`, the array and the element `offset` (a whole number, 0 when left out) of a `Buffer<u32>` that holds its length (Rule 8.23, change 0094; change 0138, Amendment A10, confirmation item 3), which the host view offers on such an array only (decision D5), and a call with one is a call on a resource; before anything runs, the call checks each array against the indices a loop writes or reads at `a*i + c` and refuses one too short with a `TypeError` naming the function, the parameter and both numbers, except for a loop whose range the device holds (Rule 8.22, change 0094), whose trip count the host does not know before the loop runs: a write such a loop makes past an array’s end is dropped on every tier (decision D2). The call validates every declared object field even when its private GPU input omits an unused field (change 0082). Projection changes no host type or refusal. A resource is a host value too (change 0138, R7 to R9 and R17): `uniform(C, init?)` from `typeshade/runtime` makes a `Uniform<C>` of a class `C` a shader module exports, laid out by the uniform rules of [Rule 6.8](https://typeshade.dev/reference/rules/6-8/), `zeros(C, n)` and `array(C, data)` make a `Buffer<C>` of `n` elements laid out as a storage array with no size, and an exported resource is one of them ([Rule 6.1](https://typeshade.dev/reference/rules/6-1/)). `array(xs)` of a `Float32Array`, an `Int32Array`, a `Uint32Array` or a `Float64Array` makes a `Buffer` of its scalars, a `Buffer<f32>`, `Buffer<i32>`, `Buffer<u32>` or `Buffer<f64>`, `array(xs)` of a `number[]` a `Buffer<number>` whose element its first use fixes (change 0138, Amendment A12, decision 3; OD-7), and `array(length, element)` a zeroed one of `'f32'`, `'i32'` or `'u32'` (change 0138, Amendment A10, Q-I); `array()` refuses, with a `TypeError`, a value that is no array, which the host keeps as `uniform(C, init)` or passes as plain data, and an array that holds anything but numbers, which is `array(C, data)` for structs or plain data (Amendment A11, Q3 and Q4). A `Buffer` of scalars holds a typed array of its own, which takes no range of the region (Amendment A11, open item on R17), and has the members of every `Buffer` (A11, Q1): `length`, which counts elements, a vector being one (A11, Q5); `set(data)` of numbers; `resize(n)`; `at(i)`, element `i`’s view, whose `get` gives a number, or for a vector a typed array of its components, and whose `set` writes one; `needsUpdate`; `dispose()`; and `read()`, which gives the typed array of its scalar, a vector’s components one after another (A11, Q2 and Q5). The element of a `Buffer<number>` is fixed by the first call, draw or dispatch that takes it, as the scalar it takes there (Amendment A12, decision 3, D1 and D3): an array with no size of numbers or vectors, a storage binding of an entry or of the program runtime, and a number or vector parameter by its scalar, an `f64` among them (the owner’s decision of 2026-11-11, recorded in Amendment A13); a matrix and an `array<matCxR>` as `f32`; a held length, an indirect workgroup count and a geometry’s indices as `u32`; and a geometry’s vertices as the scalar every vertex attribute has. That use checks each number as a plain argument of the scalar is checked, and refuses one that does not fit with a `TypeError` that names its index; a refused use fixes nothing (D2). A use that needs another element than the fixed one is a `TypeError` at the call that names the fixed element and the line of the first use, and changes nothing (Q10). Where nothing decides, the element is `f32` (OD-7). A use fixes the element from the numbers as given, so an `f64` place keeps their full precision (Amendment A13). Before the first use, `read()` gives the numbers rounded to `f32` and `at(i).get()` one of them, with the element still open, and `set(data)`, `resize(n)` and `at(i).set(x)` keep it open (Q9, Q11). A `Buffer` that `device.array()` hands out again starts open (D5). In the host view a `Buffer<number>` passes where a `Buffer<f32>`, `Buffer<i32>`, `Buffer<u32>` or `Buffer<f64>` is taken, which `number` is to TypeScript already, and its `read()` is typed `Float32Array | Int32Array | Uint32Array | Float64Array` (Q8; Amendment A13). Each is a byte range of one memory region, an `ArrayBuffer` that is resizable where the runtime has one, with an accessor for each field over a typed view of the region, made again after the region moves its ranges. `set` checks each number as a call checks it, writes only a changed number, marks its bytes dirty and allocates nothing: a uniform widens its one dirty byte range, and a buffer keeps a dirty range for each element written, joins two ranges that touch, and joins all its ranges into one when it holds more than 16 (change 0138, Amendment A5, D2); `get` returns a scalar field’s number, for an `f64` the number of its two halves, and the view of a vector, a matrix or an array field, `Readonly` (Amendment A5, D1); `needsUpdate = true` marks a write through a view; `buffer.at(i)` is element `i`’s accessor, and `await buffer.read()` returns the elements as instances of the class. The host sets a buffer’s length again (change 0138, Amendment A3): `buffer.resize(n)` gives it `n` elements, of which the ones that fit keep their values and a new one is zero, and `buffer.set(data)` gives it the length of `data` and its values, a field that `data` does not name being zero, and changes nothing when a value does not fit. Each gives the buffer another range of the region and marks the whole range dirty; an accessor made before reads the new range, and one of an element that is gone throws a `TypeError`. An exported `storage<array<T, N>>` keeps its `N` elements, so it refuses another length with a `TypeError`. A resource is freed by `dispose()`, by `using`, which calls its `[Symbol.dispose]()`, or when the garbage collector reclaims it, and an accessor of a freed one throws a `TypeError` that names it; the types of `Uniform` and `Buffer` declare `Disposable` where the host’s `lib` declares `Symbol.dispose` (Amendment A5, D4). An exported resource lives as long as its module, so its type has no `dispose()` and no `[Symbol.dispose]()`, and its `dispose()` throws a `TypeError` (Rule 6.1, Amendment A5, D7). A kernel function and a `@compute` entry take a resource (change 0138, R2): a `Buffer<C>` for an array with no size of `C` or a `storage<array<C>>` binding, a `Buffer` of the scalars for one of scalars or vectors, a `Uniform<C>` for a parameter of type `C` or a `uniform<C>` binding, an exported resource among them, and a `Buffer<u32>` as a held length or an indirect workgroup count. A call that takes one does not block. It returns nothing, or for a kernel function’s result `Buffer`s, made at the call on the call’s device (Amendment A10, Q-C): a `Buffer` of one element for a number, a vector, a `bool`, a key or a matrix of `f32`, a `Buffer` of `N` elements for an `array<T, N>` of them, one `Buffer<S>` of `N` elements for an `array<S, N>` of structs, and for a struct an object of them with the struct’s own fields and for a `Record` one with a `Buffer` for each member, a nested struct an object of its own (R1; Amendment A11, Q6; Amendment A12, decision 4, Q5 and Q6); `read()` gives each one’s values. A `Buffer<bool>` holds one `u32` word of 0 or 1 for each component, and its `read()` gives a `boolean[]`, a `vecN<bool>`’s components one after another (A12, Q1). A `Buffer<K>` of a key holds one id for each element, and its `read()` gives the members as strings; its `set(data)` and `at(i).set(x)` take members and refuse any other string (A12, Q4). A matrix `Buffer` reads a `Float32Array` of its components, column-major with no padding, one matrix after another, and its `length` counts matrices (A12, Q2). A `Buffer<S>` reads an `S[]`, instances of the class where the module exports `S` as a class that is not abstract and plain objects otherwise, and its `at(i)` is the struct accessor, whose matrix field’s `get()` gives the view with each column at its stride (A12, Q6). An `S` that holds a `bool` or a `vecN<bool>` is laid out as std430 lays out `S` with each as a `u32` or a `vecN<u32>`, a layout no shader shares, and no parameter takes it (A12, Q7). A number, vector, `bool` or key parameter takes a `Buffer` of one element of its type, and a matrix parameter a `Buffer` of one matrix or a `Buffer<f32>` of exactly its `C * R` components, column-major (A12, Q3); the call reads the element when it runs, so a result is another call’s argument (A10, Q-C). An array with no size takes a `Buffer` of its element: an `array<matCxR>` a `Buffer` of the matrix or a `Buffer<f32>` whose length is a multiple of `C * R`, column-major, which the call pads to the column stride (A12, B2-1 and B2-2); an `array<K>` a `Buffer<K>` of the same key, whose ids the call passes as they are (B2-2); and an `array<S>` a result’s `Buffer<S>` (Q6). No `array<bool>` exists, since a `bool` has no storage layout. It checks every argument at the call and records the call, and the runtime submits it later, in the order of calls (Rule 11.8). The call sees the values its arguments hold when it is made (Amendment A5, default 3): a `Uniform`’s value, and the dirty ranges of a `Buffer`, which the call copies out and marks clean. Those ranges are written to the device copy before the call runs. `await buffer.read()` submits the recorded calls, waits for those before it, and lands what they wrote in the buffer’s range of the region (R17). The window of a `Buffer` is the time from a call that writes it to its `read()`; in it, the region does not hold what the device holds. In the window, `set` of that buffer throws a `TypeError` that says to await `read()` first, as `get` does (the owner’s decision (a) of 2026-11-11). `set(data)`, `resize` and `needsUpdate` throw it too, which the owner accepted with the merge of the slice that added them (change 0138, Amendment A7). A `Buffer` of scalars has the same window: its element view’s `get` and `set`, `set(data)`, `resize` and `needsUpdate` throw it from a call that writes it until `read()` (Amendment A11, Q1). Beside the checks of a call with plain data, a call on a resource refuses, with a `TypeError` at the call: a result no `Buffer` holds (a matrix of `f64`, an `array<S, N>` whose `S` holds a `Record` or a matrix of `f64`, and a struct that holds one; an `array<Record<K, T>, N>` and a nested sized array, which [`TS8099`](https://typeshade.dev/reference/errors/ts8099/) refuses in the source already, Amendment A12, decision 4), naming the function; a collection or a sized binding the call writes that is no `Buffer`; a `Buffer` of another class; a `Buffer` where no array with no size is taken, a sized storage binding among them; a `Buffer` for a parameter that is no number, vector, `bool`, key or matrix of `f32`, or of another element or more than one element there; a `Buffer<bool>` for an array, a `Buffer<K>` for an array of another element, and a matrix `Buffer` for an array of another element (Amendment A12, decision 4); and a `Buffer` of scalars of another element, or one whose length is no whole number of the vector’s components (Amendment A11, Q5). Each refusal but the first names the function and the parameter or the binding, and a refused call changes no `Buffer`. A call on a resource that writes a plain array with no size waits: it returns a promise, fills the array in place when it has run, and gives its result as plain data (R2 as amended by Amendments A10 and A11, Q7). A call that takes no `Buffer` and no `Uniform` is the call this rule and Rule 11.8 give above. A recorded call that fails when it runs throws its error at the next `read()` or call, with the line of the failed call (Amendment A5, default 7). A `Buffer` that the failed call writes keeps the error: each later call that takes it, and its `read()`, throw it until `set(data)` or `resize()` gives it new values (the owner’s decision (b) of 2026-11-11), a `Buffer` of scalars as a `Buffer` of structs (Amendment A10, Q-I). The failed call leaves the window, so `get` reads the region again: what it held before the writing calls not yet read back. The error is also thrown once at the next `read()` or call, wherever it is, a call with plain data and a draw among them. So after a recovery with `set(data)` or `resize()`, that next `read()` or call throws it, unless one threw it since the failure, and the call after it works. A draw takes no resource yet.

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

## Rationale

the representation is the one the CPU tier already runs on (`src/core/cpu-runtime.ts`), typed precisely in the host view, so there is nothing to construct and a wrong shape is a type error before it is a `TypeError`. The view spells each type with the name the source writes, so a host developer reads the signature the shader declares, and an `f32` and a `u32` stay two types (`docs/dx.md` principle 2, change 0116). The check at the call is for the caller `tsc` did not read: an IR node passed as a vector gave `NaN` in silence, and a `Float32Array` added to another gave a string. A later tier takes new shapes (an entry point, a runtime-sized array parameter) that are asynchronous from the day they appear, so a helper’s call site never gains an `await` it does not need (`docs/dx.md` principle 4).

## Derives from

change `0009` in `changes/` (“Host values were undefined”); [Rule 8.8](https://typeshade.dev/reference/rules/8-8/); `docs/dx.md`; `changes/0088-optional-values.md` (decision D4), for the optional value; `changes/0093-optional-positions.md` (decision D7), for the struct, the array and the parameter that hold one; `changes/0109-host-classes.md` (decisions D1 and D6), for the instance of an exported class and the key of a private field; `changes/0116-host-type-family.md` (decisions D1 to D6), for the host type family the view spells with.

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

`toShader` and `fromShader` in `src/core/host-values.ts`, which the generated module calls at every argument and result, and in a module that exports a class `fromShaderIn` there, which builds a struct of an exported class as its instance, and `callMember`, which the class’s constructor and members call (change 0109); the view’s types, from `hostTypeOf` in `src/compiler/ts/host-face.ts`, which declares an export that takes or returns an optional value `never` with the reason (`parameter "v": an optional value, f32 | undefined, has no host value yet (Rule 8.21)`, or `its result: …`; through a struct’s field, `field R.w: an optional value, f32 | undefined, has no host value yet (Rule 8.21)`, change 0093), and the manifest’s binding types, from its `programType`, each spelled with the host type family of `src/runtime/host-types.ts` (change 0116) by `argType`, `resultType`, `bindingTsType` and `packHostType`, with the names a view writes imported by `viewImports`; the family held to the value types of the ambient library one for one, to the shape the compiler gives each name and to the behaviour of its flavor under `tsc` by `src/runtime/host-types.test.ts`; pinned by `src/compiler/ts/host-face.test.ts`, which checks every row in the view and the manifest’s type, a host program that writes the family’s names, a `Float32Array` vector, each refusal’s text, and that a result aliases no argument; the binding rows by `src/compiler/ts/host-entry.test.ts` and `src/compiler/ts/host-draw.test.ts`; the instance by `src/compiler/ts/host-class.test.ts`, which passes one to a helper, to a kernel function’s array and to an entry’s binding beside a plain object, and holds a result to an instance of its class; the key of a private field by `src/compiler/ts/host-private-class.test.ts`, which passes an instance and refuses a plain object of the fields in each of those places, by `src/compiler/ts/host-private-names.test.ts`, which holds the names the view and the byte layouts of the call layer carry, and by `src/core/host-private-key.test.ts`, which holds each conversion to the key (`shaderField` and `missingField` in `src/core/host-key.ts`, with `pack`, `readInto`, `toCpu` and `fromCpu` in `src/core/host-entry.ts` and, for the fields a kernel function reads, `projectInputLayout` in `src/core/host-input-projection.ts`), while `src/compiler/ts/host-face.ts` names the field by its key in each host type and in each byte layout of the call layer that applies to a host value, the pass program of a compute entry on WebGL2 among them, and by the field’s name in each that applies to the CPU tier’s value. The resources by `src/runtime/resource.ts` and `src/runtime/region.ts`, and each class’s layouts by `resourceLayouts` in `src/compiler/ts/host-face.ts`; pinned by `src/runtime/resource.test.ts`, which reads each kind of field with `get`, the dirty ranges of a buffer joined past `DIRTY_RANGE_LIMIT` and the one range of a uniform, `src/runtime/exported-binding.test.ts` and `src/runtime/unsized-storage.test.ts`, which grows a buffer past the region’s capacity; `using` and the exported resource’s type with no `dispose()` under `tsc` by `src/runtime/exported-binding.test.ts` and `src/runtime/unsized-storage.test.ts`. A call that takes a resource (change 0138, R2) is pinned by `src/runtime/resource-call.test.ts`: it reads the shader with `compile()` and the language service, runs the generated module on the CPU tier with the window, each refusal at the call this rule lists and the recovery after a failed call, and type-checks a host program over the view with `tsc`. Private input packing retains logical validation and property-read order in `src/core/host-entry.ts`; pinned by `src/compiler/ts/kernel-project.test.ts`.

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

- [`src/compiler/ts/fieldless-classes.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/fieldless-classes.test.ts#L1)
- [`src/compiler/ts/host-class.test.ts:2`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/host-class.test.ts#L2)
- [`src/compiler/ts/host-draw.test.ts:2`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/host-draw.test.ts#L2)
- [`src/compiler/ts/host-entry.test.ts:2`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/host-entry.test.ts#L2)
- [`src/compiler/ts/host-face-cpu-tier.test.ts:2`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/host-face-cpu-tier.test.ts#L2)
- [`src/compiler/ts/host-face-default-param.test.ts:2`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/host-face-default-param.test.ts#L2)
- [`src/compiler/ts/host-face.test.ts:2`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/host-face.test.ts#L2)
- [`src/compiler/ts/host-face.ts:82`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/host-face.ts#L82)
- [`src/compiler/ts/host-kernel-grown.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/host-kernel-grown.test.ts#L1)
- [`src/compiler/ts/host-kernel-made-elements.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/host-kernel-made-elements.test.ts#L1)
- [`src/compiler/ts/host-kernel-made-resource.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/host-kernel-made-resource.test.ts#L1)
- [`src/compiler/ts/host-kernel-made-shared.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/host-kernel-made-shared.test.ts#L1)
- [`src/compiler/ts/host-kernel-made-waiting.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/host-kernel-made-waiting.test.ts#L1)
- [`src/compiler/ts/host-kernel-made.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/host-kernel-made.test.ts#L1)
- [`src/compiler/ts/host-kernel-push.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/host-kernel-push.test.ts#L1)
- [`src/compiler/ts/host-kernel.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/host-kernel.test.ts#L1)
- [`src/compiler/ts/host-private-class.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/host-private-class.test.ts#L1)
- [`src/compiler/ts/host-private-names.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/host-private-names.test.ts#L1)
- [`src/compiler/ts/host-private-shader.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/host-private-shader.test.ts#L1)
- [`src/compiler/ts/kernel-project.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/kernel-project.test.ts#L1)
- [`src/compiler/ts/key-types.test.ts:4`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/key-types.test.ts#L4)
- [`src/compiler/ts/optional-values.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/optional-values.test.ts#L1)
- [`src/compiler/ts/typed-bindings.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/typed-bindings.test.ts#L1)
- [`src/core/host-defaults.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/host-defaults.ts#L1)
- [`src/core/host-entry.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/host-entry.ts#L1)
- [`src/core/host-input-projection.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/host-input-projection.ts#L1)
- [`src/core/host-kernel-made/on-resource.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/host-kernel-made/on-resource.ts#L1)
- [`src/core/host-key.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/host-key.ts#L1)
- [`src/core/host-private-key.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/host-private-key.test.ts#L1)
- [`src/core/host-values.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/host-values.ts#L1)
- [`src/core/passes/empty-struct.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/passes/empty-struct.test.ts#L1)
- [`src/runtime/buffer-kinds.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/runtime/buffer-kinds.test.ts#L1)
- [`src/runtime/buffer-scalar.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/runtime/buffer-scalar.test.ts#L1)
- [`src/runtime/exported-binding.test.ts:255`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/runtime/exported-binding.test.ts#L255)
- [`src/runtime/host-types.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/runtime/host-types.test.ts#L1)
- [`src/runtime/host-types.ts:4`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/runtime/host-types.ts#L4)
- [`src/runtime/region.ts:4`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/runtime/region.ts#L4)
- [`src/runtime/resource-call.test.ts:10`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/runtime/resource-call.test.ts#L10)
- [`src/runtime/resource.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/runtime/resource.test.ts#L1)
- [`src/runtime/resource.ts:650`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/runtime/resource.ts#L650)
- [`src/runtime/unsized-storage.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/runtime/unsized-storage.test.ts#L1)

## Explained in

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

- [§14 TypeScript shapes the parser already had](https://github.com/typeshade/typeshade/blob/af54ddad5/docs/use-typeshade-surface.md#14-typescript-shapes-the-parser-already-had)
- [§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)
- [§64 Calling a module from host code](https://github.com/typeshade/typeshade/blob/af54ddad5/docs/use-typeshade-surface.md#64-calling-a-module-from-host-code)
- [§65 A loop that runs as a kernel](https://github.com/typeshade/typeshade/blob/af54ddad5/docs/use-typeshade-surface.md#65-a-loop-that-runs-as-a-kernel)
- [§67 Calling an entry point from host code](https://github.com/typeshade/typeshade/blob/af54ddad5/docs/use-typeshade-surface.md#67-calling-an-entry-point-from-host-code)
- [§69 Running a compiled program](https://github.com/typeshade/typeshade/blob/af54ddad5/docs/use-typeshade-surface.md#69-running-a-compiled-program)
- [§75 String keys and Record](https://github.com/typeshade/typeshade/blob/af54ddad5/docs/use-typeshade-surface.md#75-string-keys-and-record)
- [§76 Optional values: `T | undefined`, `T | null` and three states](https://github.com/typeshade/typeshade/blob/af54ddad5/docs/use-typeshade-surface.md#76-optional-values-t--undefined-t--null-and-three-states)

## See also

- [Rule 8.20](https://typeshade.dev/reference/rules/8-20/) Test
- [Rule 8.22](https://typeshade.dev/reference/rules/8-22/) Test
- [Rule 4.1](https://typeshade.dev/reference/rules/4-1/)
- [Rule 6.1](https://typeshade.dev/reference/rules/6-1/)
- [Rule 6.8](https://typeshade.dev/reference/rules/6-8/)
- [Rule 7.10](https://typeshade.dev/reference/rules/7-10/)
- [Rule 8.8](https://typeshade.dev/reference/rules/8-8/)
- [Rule 8.10](https://typeshade.dev/reference/rules/8-10/)
- [Rule 8.12](https://typeshade.dev/reference/rules/8-12/)
- [Rule 8.23](https://typeshade.dev/reference/rules/8-23/)
- [Rule 8.24](https://typeshade.dev/reference/rules/8-24/)
- [Rule 11.8](https://typeshade.dev/reference/rules/11-8/)
- [Rule 11.11](https://typeshade.dev/reference/rules/11-11/)
- [Rule 11.13](https://typeshade.dev/reference/rules/11-13/)
- [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:1060`](https://github.com/typeshade/typeshade/blob/af54ddad5/docs/language-design.md#L1060) (the design document)
- [`reqs/rules/RULE-0821.md`](https://github.com/typeshade/typeshade/blob/af54ddad5/reqs/rules/RULE-0821.md) (its traceability item)
