Skip to content

[no-invalid-void-type] Should allow this: void #2148

@ghost

Description

Repro

{
  "rules": {
    "@typescript-eslint/no-invalid-void-type": ["error"]
  }
}
interface ClassWithStaticMethod {
    method(this: void): void;
}

Expected Result: Should not return an error here, as this: void clarifies that the method is static.

Actual Result: Throws an error saying that void is only valid as a return type or generic type variable.

Additional Info: TypeScript specially refers to "this in void context" which clarifies that void is the right type here, not undefined.

Versions

package version
@typescript-eslint/eslint-plugin 2.34.0
@typescript-eslint/parser 2.34.0
TypeScript 3.9.3
ESLint 7.0.0
node 12.16.3
yarn 1.22.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestpackage: 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

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy