# no-use-before-define

Rule `typescript/no-use-before-define`. Disallow the use of variables before they are defined

- Source: typescript
- Technologies: TypeScript
- Kind: correctness
- Needs type information: no
- Autofix: no
- Reach: 6.4M weekly downloads of presets that enable it
- Trend: +5.7% last quarter
- Rank: #1160 by reach, #1488 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `@typescript-eslint/no-use-before-define` | no | no | package `@typescript-eslint/eslint-plugin` | [docs](https://typescript-eslint.io/rules/no-use-before-define) |
| Biome | `correctness/noInvalidUseBeforeDeclaration` | yes | no | group correctness, since 1.5.0 | [docs](https://biomejs.dev/linter/rules/no-invalid-use-before-declaration/) |

## Code examples

### Incorrect: the rule reports this

```ts
const x = Foo.FOO;

enum Foo {
  FOO,
}
```

### Correct: the rule accepts this

```ts
function foo() {
  return Foo.FOO;
}

enum Foo {
  FOO,
}
```

```ts
let myVar: StringOrNumber;
type StringOrNumber = string | number;
```

```ts
let var1: StringOrNumber;
type StringOrNumber = string | number;

let var2: Enum;
enum Enum {}
```

Examples from the ESLint documentation.

## Enable it

### ESLint: `eslint.config.js`

```js
import tseslint from "typescript-eslint";

export default [
  {
    plugins: { "@typescript-eslint": tseslint.plugin },
    rules: {
      "@typescript-eslint/no-use-before-define": "error",
    },
  },
];
```

### Biome: `biome.json`

```json
{
  "linter": {
    "rules": {
      "correctness": {
        "noInvalidUseBeforeDeclaration": "error"
      }
    }
  }
}
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [Create React App](https://lintradar.dev/presets/react-app.md) | ESLint | `eslint-config-react-app` | 109 | 4.1M | +4.3% |
| [Airbnb TypeScript](https://lintradar.dev/presets/airbnb-typescript.md) | ESLint | `eslint-config-airbnb-typescript` | 19 | 1.8M | +1.2% |
| [neostandard](https://lintradar.dev/presets/neostandard.md) | ESLint | `neostandard` | 95 | 317.6K | +50.2% |
| [eslint-config-love](https://lintradar.dev/presets/love.md) | ESLint | `eslint-config-love` | 258 | 171.7K | +39.3% |

## Related rules

- [eslint/no-use-before-define](https://lintradar.dev/rules/eslint/no-use-before-define.md): Disallow the use of variables before they are defined
- [typescript/no-redeclare](https://lintradar.dev/rules/typescript/no-redeclare.md): Disallow variable redeclaration
- [typescript/no-import-type-side-effects](https://lintradar.dev/rules/typescript/no-import-type-side-effects.md): Enforce the use of top-level import type qualifier when an import only has specifiers with inline type qualifiers
- [typescript/dot-notation](https://lintradar.dev/rules/typescript/dot-notation.md): Enforce dot notation whenever possible
- [typescript/no-dupe-class-members](https://lintradar.dev/rules/typescript/no-dupe-class-members.md): Disallow duplicate class members
- [typescript/no-shadow](https://lintradar.dev/rules/typescript/no-shadow.md): Disallow variable declarations from shadowing variables declared in the outer scope

---

Web page: https://lintradar.dev/rules/typescript/no-use-before-define. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
