> For AI agents: the complete documentation index is available at https://rslint.rs/llms.txt, the full documentation bundle is available at https://rslint.rs/llms-full.txt.

# no-redeclare

[Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0)
## Configuration


```ts title=rslint.config.ts
import { defineConfig, ts } from '@rslint/core';

export default defineConfig([
  ts.configs.recommended,
  {
    rules: {
      '@typescript-eslint/no-redeclare': 'error',
    },
  },
]);
```

## Rule Details

This rule disallows redeclaring variables. It extends ESLint's base `no-redeclare` to understand TypeScript constructs such as type aliases, interfaces, namespaces, and declaration merging.

Examples of **incorrect** code for this rule:

```javascript
var a = 3;
var a = 10;
```

```javascript
function a() {}
function a() {}
```

```typescript
type T = 1;
type T = 2;
```

Examples of **correct** code for this rule:

```javascript
var a = 3;
var b = function () {
  var a = 10;
};
```

```typescript
interface A {
  prop1: 1;
}
interface A {
  prop2: 2;
}
```

```typescript
class Foo {}
namespace Foo {}
```

## Options

### `builtinGlobals` (default: `true`)

When `true`, the rule reports redeclaring ECMAScript built-in globals and names
provided by TypeScript's active lib type definitions, such as `Object`,
`Promise`, or `HTMLElement`. Configured
[`languageOptions.globals`](https://rslint.rs/config/language-options.md#languageoptionsglobals) also participate as
built-ins; use the `globals` catalog exported by `@rslint/core` to select a
runtime environment. Active `/* global */` directives participate as
declarations in either mode; a final `:off` setting removes that inline global.
Turning off a value global does not remove a same-named TypeScript type global.

```json
{ "@typescript-eslint/no-redeclare": ["error", { "builtinGlobals": true }] }
```

```javascript
var Object = 0;
```

### `ignoreDeclarationMerge` (default: `true`)

When `true`, the rule ignores redeclarations that are legal TypeScript declaration merges:

- `interface` + `interface`
- `namespace` + `namespace`
- `class` + `interface` / `class` + `namespace` / `class` + `interface` + `namespace` (at most one class)
- `function` + `namespace` (at most one function)
- `enum` + `namespace` (at most one enum)

```json
{ "@typescript-eslint/no-redeclare": ["error", { "ignoreDeclarationMerge": true }] }
```

```typescript
function A() {}
namespace A {}
```

## Original Documentation

- [typescript-eslint: no-redeclare](https://typescript-eslint.io/rules/no-redeclare)
- [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/no-redeclare.ts)
