# TS8004: Type parameter declarations can only be used in TypeScript files.

> Type parameters (`<T>`) appear on a function or class in a JavaScript file. Use JSDoc `@template` or rename the file to .ts.

## What it means

Generic type parameter lists such as `function f<T>(x)` 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
function first<T>(xs) {
  return xs[0];
}
```

## How to fix

- Remove the type parameters and describe them in JSDoc: `/** @template T @param {T[]} xs */`.
- Rename the file to `.ts` if it's meant to be TypeScript.

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