Skip to content

Bug: [consistent-generic-constructors] Don't conflict with isolatedDeclarations if enabled #10571

@JoshuaKGoldberg

Description

@JoshuaKGoldberg

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=KYDwDg9gTgLgBAYwgOwM7wGZQgWwCoCeYwAgsshDAIYwCWKAXHAMrAwA86UtyA5gHxwAvHGTAA7izYAKANoByKvIC6ASgDcAKCA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6MgeyeUuX0Ra0A5gMRUytTt3xwy%2BDtFQZIY6AsjgwAXxBagA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkyJsqAhnugCYAi60zmLhpCmDyYArugA04GpBIjk0PADlRqVAGEAFtwDWZSiPHSAviGNA&tokens=false

Repro Code

export const fromTypeAnnotation: Set<string> = new Set(['a']);

ESLint Config

module.exports = {
  "rules": {
    "@typescript-eslint/consistent-generic-constructors": "error"
  }
}

tsconfig

{
  "compilerOptions": {
    "isolatedDeclarations": true,
    "strictNullChecks": true
  }
}

Expected Result

When isolatedDeclarations is enabled, there should be no lint rule report. ID requires that the exported variable has an explicit type annotation.

Actual Result

The generic type arguments should be specified as part of the constructor type arguments.

Additional Info

Pending #10570, TypeScript playground showing an ID type error: https://www.typescriptlang.org/play/?isolatedDeclarations=true#code/KYDwDg9gTgLgBAYwgOwM7wGZQgWwMIrpQCuCM0cAvHMsAO5wDKwMAFANoDkAhpwLoBKANwAoEaEixEhTNhwAVAJ5hgAQWTIIMbjACWKAFxMWAHiK7kAcwB8VGvWNsuvQaKA

💖

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

      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