---
title: "TS8069 MISPLACED_DIRECTIVE: a TypeShade compiler error code"
description: "TS8069 MISPLACED_DIRECTIVE, an error code of the TypeShade compiler. A \"use typeshade\" directive after another top-level statement (Rule 3.1)."
url: https://typeshade.dev/reference/errors/ts8069/
language: en
---

# `TS8069`

Front-end code `MISPLACED_DIRECTIVE`

A `"use typeshade"` directive after another top-level statement ([Rule 3.1](https://typeshade.dev/reference/rules/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

```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

```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](https://typeshade.dev/reference/rules/3-1/) Test**

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

## See also

- [Error codes](https://typeshade.dev/reference/errors/)

## Source

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

- [`src/compiler/ts/source-file.ts:779`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/source-file.ts#L779)
