> 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-unsafe-declaration-merging

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

| Preset                              | Configured Value |
| ----------------------------------- | ---------------- |
| ✅ ts.configs.recommended            | `"error"`        |
| ✅ ts.configs.recommendedTypeChecked | `"error"`        |
| ✅ ts.configs.strict                 | `"error"`        |
| ✅ ts.configs.strictTypeChecked      | `"error"`        |


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

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

## Rule Details

Disallows unsafe declaration merging between a class and an interface. TypeScript allows a class and an interface that share the same name in the same scope to merge into a single declaration. Properties declared on the interface are added to the resulting type without forcing the class to actually initialize them, so accessing such a property on a class instance type-checks but throws `Cannot read properties of undefined` at runtime.

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

```typescript
interface Foo {}
class Foo {}
```

```typescript
class Foo {}
interface Foo {}
```

```typescript
declare global {
  interface Foo {}
  class Foo {}
}
```

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

```typescript
interface Foo {}
class Bar implements Foo {}
```

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

```typescript
enum Foo {}
namespace Foo {}
```

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

```typescript
const Foo = class {};
```

```typescript
interface Foo {
  props: string;
}

function bar() {
  return class Foo {};
}
```

```typescript
declare global {
  interface Foo {}
}

class Foo {}
```

## Original Documentation

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