# no-shadow

Rule `typescript/no-shadow`. Disallow variable declarations from shadowing variables declared in the outer scope

- Source: typescript
- Technologies: TypeScript
- Kind: suspicious
- Needs type information: no
- Autofix: no
- Reach: 3.5M weekly downloads of presets that enable it
- Trend: +2.0% last quarter
- Rank: #1416 by reach, #1619 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `@typescript-eslint/no-shadow` | no | no | package `@typescript-eslint/eslint-plugin` | [docs](https://typescript-eslint.io/rules/no-shadow) |
| Biome | `suspicious/noShadow` | no | no | group suspicious, since 2.0.0 | [docs](https://biomejs.dev/linter/rules/no-shadow/) |

## Code examples

### Incorrect: the rule reports this

```ts
type Bar<Foo> = 1;
type Foo = 1;
```

```ts
// types
type Bar<Foo> = 1;
type Foo = 1;

// functions
if (true) {
  let b = 6;
}

function b() {}
```

### Correct: the rule accepts this

```ts
type Foo = number;
interface Bar {
  prop: number;
}

function f() {
  const Foo = 1;
  const Bar = 'test';
}
```

```ts
const test = 1;
type Func = (test: string) => typeof test;
```

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-shadow": "error",
    },
  },
];
```

### Biome: `biome.json`

```json
{
  "linter": {
    "rules": {
      "suspicious": {
        "noShadow": "error"
      }
    }
  }
}
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [Airbnb TypeScript](https://lintradar.dev/presets/airbnb-typescript.md) | ESLint | `eslint-config-airbnb-typescript` | 19 | 1.8M | +1.2% |
| [React Native](https://lintradar.dev/presets/react-native.md) | ESLint | `@react-native/eslint-config` | 79 | 1.2M | +5.8% |
| [XO](https://lintradar.dev/presets/xo.md) | ESLint | `eslint-config-xo` | 618 | 413K | −5.0% |

## Related rules

- [eslint/no-shadow](https://lintradar.dev/rules/eslint/no-shadow.md): Disallow variable declarations from shadowing variables declared in the outer scope
- [typescript/no-dupe-class-members](https://lintradar.dev/rules/typescript/no-dupe-class-members.md): Disallow duplicate class members
- [typescript/method-signature-style](https://lintradar.dev/rules/typescript/method-signature-style.md): Enforce using a particular method signature syntax
- [typescript/dot-notation](https://lintradar.dev/rules/typescript/dot-notation.md): Enforce dot notation whenever possible
- [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/prefer-find](https://lintradar.dev/rules/typescript/prefer-find.md): Enforce the use of Array.prototype.find() over Array.prototype.filter() followed by [0] when looking for a single result

---

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