no-redeclare
Configuration
rslint.config.ts
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:
Examples of correct code for this rule:
Options
builtinGlobals (default: true)
When true, the rule reports redeclaring names that shadow ECMAScript built-in globals such as Object, Array, or Number.
ignoreDeclarationMerge (default: true)
When true, the rule ignores redeclarations that are legal TypeScript declaration merges:
interface+interfacenamespace+namespaceclass+interface/class+namespace/class+interface+namespace(at most one class)function+namespace(at most one function)enum+namespace(at most one enum)
Differences from ESLint
builtinGlobalscovers every global visible through the project'stsconfig.jsonlibsetting — including DOM (top,self,HTMLElement, …) and ES-extension names (Promise,WeakRef, …). ESLint only flags globals the activeenv/globalsoptions declare.- A file counts as a module when it has a top-level
importorexport. Declarations in a module do not collide with lib globals, sovar Object = 0;inside a module is not reported. type Foo = ...is not reported as shadowing a lib interface namedFoo— type aliases and interfaces live in different declaration spaces, and the collision is not a real one.