TS8069
On this page

TS8069

Front-end code MISPLACED_DIRECTIVE

A "use typeshade" directive after another top-level statement (Rule 3.1). In ECMAScript a directive is only a leading string statement, so TypeScript reads a late one as an ordinary string. The fix is to move the directive, not to add one; a file with no directive at all is MISSING_DIRECTIVE.

The registry has no documentation comment for this constant, so the line above is written by this site from the messages the compiler raises it with.

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

Example

example.shade.ts
const width = 640
"use typeshade"
@fragment
export function main(uv: location<0, 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(uv: location<0, 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

Source

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

Edit this page Report a problem