Rule 3.1
On this page

Rule 3.1

Chapter 3, Textual structure and names Test

A shader file must begin with the directive "use typeshade" as its first statement.

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

Rationale

the directive is what tells the compiler and the language service that the file is a shader and not host code; the bundler and a host program’s tsconfig read the file’s name first, which Rule 3.8 fixes as *.shade.ts, and the directive is what they check it against.

Derives from

surface §1 and src/compiler/ts/source-file.ts.

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:

TS8001 MISSING_DIRECTIVE, which yields an otherwise empty result, for a file with no directive at all; TS8069 MISPLACED_DIRECTIVE on a directive after another top-level statement, another string directive included, with the rest of the file still checked (#200, proposal 0012), pinned by src/compiler/ts/directive-placement.test.ts.

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

Explained in

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

Error codes that enforce it

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

TS8001 MISSING_DIRECTIVE
A file compiled as TypeShade that has no "use typeshade" directive at all.
TS8069 MISPLACED_DIRECTIVE
A "use typeshade" directive after another top-level statement (Rule 3.1).

See also

Source

The rule at commit 26de7be8:

Edit this page Report a problem