TS8069
On this page

TS8069

Front-end code MISPLACED_DIRECTIVE

A "use typeshade" directive after another top-level statement (Rule 3.1).

The registry text and every compiler message on these pages are the compiler's own English.

When it fires

A "use typeshade" directive after another top-level statement (Rule 3.1). In ECMAScript a directive is only a leading string-literal statement, so TypeScript reads a late one as an ordinary string while TypeShade reads the file as a shader. Reported on the directive, and the rest of the file is still checked. Kept apart from MISSING_DIRECTIVE, which means that there is no directive, because the fix is different: move it, don't add one (proposal 0012).

Example

example.shade.ts
const width = 640
"use typeshade"
@fragment
export function main(@location(0) uv: vec2): vec4 {
return vec4(uv, 0., 1.)
}

Compiled at build time against the pinned compiler, this program gets:

TS8069 error, line 3: "use typeshade" must be the file's first statement: here it follows a variable declaration, so TypeScript reads it as an ordinary string and not as a directive. Move it to the top of the file.

How to fix it

The same program, corrected. It compiles with no diagnostic.

example.shade.ts
"use typeshade"
const width = 640
@fragment
export function main(@location(0) uv: vec2): vec4 {
return vec4(uv, 0., 1.)
}

The rule this enforces

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

See also

TS8001 MISSING_DIRECTIVE
A file compiled as TypeShade that has no "use typeshade" directive at all.

Source

Where the compiler raises this code at commit 26de7be8, one line per file:

Edit this page Report a problem