Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Bug: [@typescript-eslint/no-invalid-void-type] false positive on generics #7227

Closed as not planned
Labels
accepting prsGo ahead, send a pull request that resolves this issuebreaking changeThis change will require a new major version to be releasedbugSomething isn't workingpackage: eslint-pluginIssues related to @typescript-eslint/eslint-plugin
@G-Rath

Description

@G-Rath

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 havesearched for related issues and found none that matched my issue.
  • I haveread the FAQ and my problem is not listed.

Playground Link

https://typescript-eslint.io/play/#ts=5.1.6&fileType=.tsx&code=CYUwxgNghgTiAEAzArgOzAFwJYHtXwFsAPAHgBUA%2BACgEoAueMgbgFgAod4kgNxy2Go1WHNhBwBzAIKpgAJRAZkMVDz4CqaUIiyoQwIe3YQF8XvwAKMHASwBnEA0vW7IVfwrwAvPF0B3eE429m7qtF4eAN7wAL4GoiZmwACyUAAODCmpJLYYMDriADSmah7efvCZ2bn5RYmCTEA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6Jge1uYDcBDRgBNaPDpWFFS6KImjQO0SODABfECqA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA&tokens=false

Repro Code

declarefunctionmx<T>():T;mx<void>();logAndReturn<void>(undefined);letvoidPromise:Promise<void>=newPromise<void>(()=>{});letvoidMap:Map<string,void>=newMap<string,void>();

ESLint Config

module.exports={parser:"@typescript-eslint/parser",rules:{"@typescript-eslint/no-invalid-void-type":"error"},};

tsconfig

{"compilerOptions": {// ...  }}

Expected Result

I expected all of these to be considered valid uses ofvoid

Actual Result

Only the last two uses are considered valid.

Additional Info

Maybe I'm missing something but I've read the docs a couple of times and the issues, and I can't find anything explaining why this general use ofvoid is being flagged - or inversely, anything confirming that there is more logic than just "is this a generic?".

Importantly thelogAndReturn is taken from the documentation itself for showcasing

The following patterns are considered warnings with { allowInGenericTypeArguments: false }:

Which implies to me those patterns shouldnot be considered warnings ifallowInGenericTypeArguments is true. This seems to be happening from v5 onwards.

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issuebreaking changeThis change will require a new major version to be releasedbugSomething 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


      [8]ページ先頭

      ©2009-2025 Movatter.jp