# TS8002: 'import ... =' can only be used in TypeScript files.

> `import x = require(...)` appears in a JavaScript file. Use `import` or `require()` instead.

## What it means

`import name = require("module")` is 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
import fs = require("fs");
```

## How to fix

- Use an ES import: `import fs from "fs";`, or CommonJS: `const fs = require("fs");`.
- Rename the file to `.ts` if it's meant to be TypeScript.

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