8000 Bug: [consistent-generic-constructors] improper fix into `new Uint8Array<ArrayBufferLike>()` · Issue #10445 · typescript-eslint/typescript-eslint · GitHub
[go: up one dir, main page]

Skip to content
Bug: [consistent-generic-constructors] improper fix into new Uint8Array<ArrayBufferLike>() #10445
@yoursunny

Description

@yoursunny

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=5.7.2&fileType=.ts&code=DYUwLgBAhgXBCqBLAdmAHAQQE5agTwB5tc8AhAVwDNKQsAZRAaxAD4IBeCZEAdwRXTF8ACgCUAbgBQANwD2iACbQpQA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6MgeyeUuX0Ra0A5gMRUytTt3xwy%2BDtFQZIY6AsjgwAXxBagA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkqyARhWANqTokBMADJwMyQAugBpwNSPFgATAK4Zm7Lr06RRNKCTyZk0PADk5qAMIALdNADWZSlpno14vAENMAc3R4FHHv0hiAviD%2BQA&tokens=false

Repro Code

let a: Uint8Array<ArrayBufferLike> = new Uint8Array();
void a;

ESLint Config

{
  "rules": {
    "@typescript-eslint/consistent-generic-constructors": "error"
  }
}

tsconfig

{
  "compilerOptions": {
    "lib": ["es2023"],
    "module": "es2022",
    "strictNullChecks": true,
    "target": "es2023"
  }
}

Expected Result

Either don't report the error, or don't generate invalid code upon fix.

Actual Result

Rule reports error:

The generic type arguments should be specified as part of the constructor type arguments. 1:5 - 1:54

If I tap Fix, the code becomes:

let a = new Uint8Array<ArrayBufferLike>();
void a;

And then TypeScript reports error:

2554: Expected 1-3 arguments, but got 0. 1:9 - 1:42

Additional Info

If I enable two rules consistent-generic-constructors and no-unnecessary-type-arguments, playground, both rules would report errors.
The outcome depends on the order of fix.

  • If consistent-generic-constructors is fixed first, the above problem occurs.
  • If no-unnecessary-type-arguments is fixed first, the resulting code is well-formed.

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

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0