Skip to content

[init-declarations] It report Variable 'b' should be initialized on declaration. when I declare nested namespace in a index.d.ts file #4392

@drylint

Description

@drylint
  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have read the FAQ and my problem is not listed.

Repro

{
  "rules": {
    "init-declarations": [0],
    "@typescript-eslint/init-declarations": [2, "always"],
  }
}
// index.d.ts

// eg.1
declare namespace obj {
  const a: number
}

// eg.2
declare namespace obj1 {
  declare const a: number
  namespace obj1_1 {
    const b: string // Error info: Variable 'b' should be initialized on declaration.
  }
}

// eg.3
declare namespace obj2 {
  const a: number
  namespace obj2_2 {
    declare const b: string
  }
}

Expected Result

Expected that don't report error with const b: string in eg.2

Actual Result

eg.1 and eg.3 is OK, but eg.2 was reported Variable 'b' should be initialized on declaration.

image

Additional Info

Versions

package version
@typescript-eslint/eslint-plugin 5.8.1
@typescript-eslint/parser 5.8.1
TypeScript 4.5.4
ESLint 8.5.0
node 16.13.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issuebugSomething isn't workingpackage: eslint-pluginIssues related to @typescript-eslint/eslint-plugin

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions