Skip to content

typescript/no-unsafe-declaration-merging Correctness

This rule is turned on by default.

What it does

Disallow unsafe declaration merging.

Why is this bad?

Declaration merging between classes and interfaces is unsafe. The TypeScript compiler doesn't check whether properties are initialized, which can lead to TypeScript not detecting code that will cause runtime errors.

Examples

Examples of incorrect code for this rule:

ts
interface Foo {}
class Foo {}

Examples of correct code for this rule:

ts
interface Foo {}
class Bar {}

How to use

To enable this rule in the CLI or using the config file, you can use:

bash
oxlint --deny typescript/no-unsafe-declaration-merging
json
{
  "rules": {
    "typescript/no-unsafe-declaration-merging": "error"
  }
}

References

Released under the MIT License.