# TS8016: Type assertion expressions can only be used in TypeScript files.

> A type assertion (`x as T` or `<T>x`) appears in a JavaScript file. Use a JSDoc cast or rename the file to .ts.

## What it means

Type assertions are TypeScript syntax and can't appear in a `.js` file.

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
const input = document.querySelector("input") as HTMLInputElement;
```

## How to fix

- Use a JSDoc cast: `/** @type {HTMLInputElement} */ (document.querySelector("input"))`.
- Rename the file to `.ts` if it's meant to be TypeScript.

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