---
title: "Rule 12.4: Diagnostics, a TypeShade design rule"
description: "Rule 12.4 of the TypeShade language design, in Diagnostics. One mistake reads as one diagnostic…"
url: https://typeshade.dev/reference/rules/12-4/
language: en
---

# Rule 12.4

Chapter 12, Diagnostics Test

One mistake reads as one diagnostic; a refusal must not be followed by further diagnostics about the same mistake.

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

## Rationale

a cascade hides the sentence that says what to do.

## Derives from

surface §28 (“and one mistake reads as one sentence”).

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

`honest-refusals.test.ts` (`one mistake reads as one sentence`), for the surface §28 shapes, and (`a refused declaration is the one diagnostic for its name`), for a refused declaration: a read of the name, an assignment to it or a write through it reports nothing more when an error stands inside the declaration the name resolves to or inside a declaration that one reads (`a local declared from a refused one`), while a name read out of its scope, read before its declaration or declared nowhere still reports [`TS8022`](https://typeshade.dev/reference/errors/ts8022/) (`src/compiler/ts/refused-names.ts`, [#171](https://github.com/typeshade/typeshade/issues/171)); and, across the language service’s two halves, `mergeDiagnostics` (`src/language-service/diagnostics.ts`), which keeps the compiler’s diagnostic where TypeScript and the compiler report one mistake, with no exception (a misspelled name included, since the compiler names the fix itself under [Rule 12.1](https://typeshade.dev/reference/rules/12-1/)), and drops TypeScript’s knock-on of a value it could not type itself (a call it failed to resolve, a name or a member it cannot find), reached directly, through a local declared with no type or through an operation, in `src/language-service/diagnostics.test.ts` (`one mistake reads as one diagnostic across the two halves`, among it a comparison of vectors of two sizes, the uses of a local whose product the compiler refused, a value from an unknown function used in an operation, and a return of the wrong type, which the compiler reports on the `return`, where TypeScript does). For the shapes two passes both refused (proposal 0008), `honest-refusals.test.ts` (`one mistake, one diagnostic, in compile() and in the editor`): `for…in` and `try`, and a `throw`, an `await`, a `yield`, a template string and a spread with what each holds, in a body and at the top level; `var` in a body, at the top level and in a namespace, one that declares a parameter again and one of a list with no type; `async` and generator functions as a declaration, a value, a class’s method, a mixin’s and an object literal’s, a body no call lowers included, with a call of each and a local declared from one; a spread in a list in a local, a module constant or variable, a field, a static field, a default and an argument, and a spread argument; a rest element in a list assigned to; a type inside a namespace, and a parameter that names it; a generic interface or object-type alias, directly and through an alias, typing a parameter, a return, a local, a module constant or variable, a binding and an array of them, a field of a class or an interface, a method’s, a static function’s or a constructor’s signature, and an `as`; each pinned whole in `compile()` and in the editor’s merged list, TypeScript’s entries included, with a use of what it declares, and the multi-file path’s in `compileTsSources`. `refused-names.ts` keeps more reads quiet there: a name whose declaration names a type refused at its declaration, or a class or interface that holds one; a `var` read outside the block it is written in; a local declared from a call of a function or a method refused where it is written, through the class it is called on; `N.x` and `N.M.x` where what a namespace declares was refused; and `C.K`, a static field refused where it is written (`staticFieldRefused`). A class whose `extends` names a base refused where it is written, `class D<T> extends B<T>` with its type parameter, is that one [`TS8002`](https://typeshade.dev/reference/errors/ts8002/): nothing more is said of the base it misses, of a `new` of it or of a read of what the base would have given it (`src/compiler/ts/generic-classes.test.ts`). `mergeDiagnostics` drops TypeScript’s report of what the compiler refused whole there (`repeatsRefusal`).

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

- [`src/compiler/ts/abstract-super.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/abstract-super.test.ts#L1)
- [`src/compiler/ts/array-minmax-types.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/array-minmax-types.test.ts#L1)
- [`src/compiler/ts/builtin-type-diagnostic.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/builtin-type-diagnostic.test.ts#L1)
- [`src/compiler/ts/class-member-diagnostics.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/class-member-diagnostics.test.ts#L1)
- [`src/compiler/ts/compute-stage-reachability.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/compute-stage-reachability.test.ts#L1)
- [`src/compiler/ts/generic-classes.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/generic-classes.test.ts#L1)
- [`src/compiler/ts/honest-refusals-tuples.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/honest-refusals-tuples.test.ts#L1)
- [`src/compiler/ts/honest-refusals.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/honest-refusals.test.ts#L1)
- [`src/compiler/ts/host-names.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/host-names.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/io-name-cascades.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/io-name-cascades.test.ts#L1)
- [`src/compiler/ts/module-vars-atomic.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/module-vars-atomic.test.ts#L1)
- [`src/compiler/ts/refused-names.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/refused-names.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/super-constructor-diagnostics.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/super-constructor-diagnostics.test.ts#L1)
- [`src/compiler/ts/switch-validation.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/switch-validation.test.ts#L1)
- [`src/language-service/diagnostics-brand-tags.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/language-service/diagnostics-brand-tags.test.ts#L1)
- [`src/language-service/diagnostics-glsl-hlsl-names.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/language-service/diagnostics-glsl-hlsl-names.test.ts#L1)
- [`src/language-service/diagnostics-module-variables.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/language-service/diagnostics-module-variables.test.ts#L1)
- [`src/language-service/diagnostics-one-mistake.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/language-service/diagnostics-one-mistake.test.ts#L1)
- [`src/language-service/diagnostics-vector-arithmetic.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/language-service/diagnostics-vector-arithmetic.test.ts#L1)
- [`src/language-service/diagnostics.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/language-service/diagnostics.test.ts#L1)
- [`src/language-service/diagnostics.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/language-service/diagnostics.ts#L1)
- [`src/language-service/generic-arity-diagnostics.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/language-service/generic-arity-diagnostics.test.ts#L1)
- [`src/language-service/loop-control-diagnostics.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/language-service/loop-control-diagnostics.test.ts#L1)
- [`src/language-service/module-variable-diagnostics.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/language-service/module-variable-diagnostics.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)
- [§13 Integer literals](https://github.com/typeshade/typeshade/blob/af54ddad5/docs/use-typeshade-surface.md#13-integer-literals)
- [§28 What TypeScript writes that the GPU has no word for](https://github.com/typeshade/typeshade/blob/af54ddad5/docs/use-typeshade-surface.md#28-what-typescript-writes-that-the-gpu-has-no-word-for)
- [§68 Importing another shader module](https://github.com/typeshade/typeshade/blob/af54ddad5/docs/use-typeshade-surface.md#68-importing-another-shader-module)

## Error codes that enforce it

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

**[`TS8002`](https://typeshade.dev/reference/errors/ts8002/) `UNKNOWN_TYPE`**

A type name that nothing declares, in a parameter, a type argument, an alias, an `implements` clause or a base class, or a type that this surface does not take where the mapper reads one ([Rule 2.1](https://typeshade.dev/reference/rules/2-1/)). A base that the file declares and does not collect as a struct is `STRUCT_FIELD`.

**[`TS8022`](https://typeshade.dev/reference/errors/ts8022/) `UNKNOWN_NAME`**

A reference to a name that TypeShade cannot resolve and that is not a function call (`UNKNOWN_FN`) or a type name (`UNKNOWN_TYPE`). A name that the library declares for TypeScript's own use (`Object`, `Math`, `Symbol`), or that the file declares as an enum, a namespace, a class or a type, and that is read as a value, says what it is.

## See also

- [Rule 12.3](https://typeshade.dev/reference/rules/12-3/) Test
- [Rule 12.5](https://typeshade.dev/reference/rules/12-5/) Test
- [Rule 12.1](https://typeshade.dev/reference/rules/12-1/)
- [Design rules](https://typeshade.dev/reference/rules/)
- [Error codes](https://typeshade.dev/reference/errors/)

## Source

The rule at commit af54ddad5:

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