# TS8006: '…' declarations can only be used in TypeScript files.

> An `interface`, `enum`, `namespace` or `module` declaration appears in a JavaScript file. Move it to a .ts file.

## What it means

TypeScript-only declarations (interfaces, enums, namespaces, module declarations) can't appear
in a `.js` file. The message names the kind of declaration.

ts-r's parser reports this code when it reads `.js` files with tsc's rules for TypeScript syntax in JavaScript. `ts-r-check` doesn't report it yet: today it parses `.js` files with the plain JavaScript grammar and reports a syntax error at the same place instead.

## Example

```js
enum Color { Red, Green }
```

## How to fix

- Move the declaration to a `.ts` or `.d.ts` file and import it.
- Replace an enum with a frozen object: `const Color = Object.freeze({ Red: 0, Green: 1 });`.
- Describe interfaces with JSDoc `@typedef`.

Source: https://ts-r.dev/errors/TS8006/
