Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: [no-invalid-void-type] Does not allow using void as a default type for a generic argument #5644

Closed
4 tasks done
bogdanb opened this issue Sep 13, 2022 · 2 comments
Closed
4 tasks done
Labels
accepting prs Go ahead, send a pull request that resolves this issue bug Something isn't working good first issue Good for newcomers package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@bogdanb
Copy link
Contributor

bogdanb commented Sep 13, 2022

Before You File a Bug Report Please Confirm You Have Done The Following...

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have searched for related issues and found none that matched my issue.
  • I have read the FAQ and my problem is not listed.

Playground Link

https://typescript-eslint.io/play/#ts=4.8.3&sourceType=module&code=KYDwDg9gTgLgBASwHY2FAZgQwMbDgUREwFswAbYAHgBU4BeOANwgQBMA+OAbwFgAoOHGLAYACwisAFAEoAXHGoBufgF9+QA&eslintrc=N4KABGBEAOCGBOBnApvSAuKABALgT2mUQGN4BLaHAWiIBsyA7HAejiVUgBpwp4BXWkQxhQECJFwEipCtTqMWDAPZVGAN1j0AJlTVKyO-IWEBtSKnhK03MWOBRNtJQHcAkgwDiyBqjLEAKlIAgvAA5nwAtt44iMI4-MgAvjwQALo8yclAA&tsconfig=N4KAvkA

Repro Code

export interface Example<T = void> {
  method(): T;
}

ESLint Config

{
  "parser": "@typescript-eslint/parser",
  "rules": {
    "@typescript-eslint/no-invalid-void-type": ["error",
      { "allowInGenericTypeArguments": true}
    ]
  }
}

tsconfig

{}

Expected Result

I expected the example code to pass linting without warnings or errors.

Actual Result

On the first line we get the error void is only valid as a return type or generic type variable.

Additional Info

No response

Versions

package version
TypeScript 4.8.3
ESLint 8.15.0
@bogdanb bogdanb added bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for maintainers to take a look labels Sep 13, 2022
@JoshuaKGoldberg
Copy link
Member

I think it makes sense that if allowInGenericTypeArguments is specified, we should allow the default for a generic type variable to be void too. 👍

@JoshuaKGoldberg JoshuaKGoldberg added accepting prs Go ahead, send a pull request that resolves this issue good first issue Good for newcomers and removed triage Waiting for maintainers to take a look labels Sep 14, 2022
@kazizi55
Copy link
Contributor

I would like to work on this issue!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepting prs Go ahead, send a pull request that resolves this issue bug Something isn't working good first issue Good for newcomers package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
Development

No branches or pull requests

4 participants