# TS8012: Parameter modifiers can only be used in TypeScript files.

> A constructor parameter in a JavaScript file has a modifier like `private` or `readonly`. Assign the field in the body instead.

## What it means

Parameter properties (`constructor(private name)`) 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
class User {
  constructor(public name) {}
}
```

## How to fix

- Declare the field and assign it: `constructor(name) { this.name = name; }`.
- Rename the file to `.ts` if it's meant to be TypeScript.

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