Skip to content

Bug: [no-base-in-string] generic classes don't check for ignored superclasses #11758

@joshkel

Description

@joshkel

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.2.2&fileType=.tsx&code=MYGwhgzhAEBCYDsDm0CmAPALqhATGAogE5ED2R0A3gFDUC%2B1okMsppAtgDwAqAfGlhz5oxMhRrRouVJjABLEBABc0bgG56tAGYBXBMExzSCaFrYAKVCXIr4yAJRVqk4MYikQqAHQhSSS9ZEXpikAMqYRHLI5vb2Ggy6%2BobG0ABGYEQ8vAFitmxcfI4S0K4I7p4%2BfjnkwWERUf6x8UA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6Jge1oCMBDZRLXxdk%2BKkwDm6KImjQO0SODABfECqA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA&tokens=false

Repro Code

class Boom<T> extends Error {
  details: T;
}

function bar<T>(error: Boom<T>) {
  console.log(error.toString());
}

ESLint Config

module.exports = {
  parser: "@typescript-eslint/parser",
  rules: {
    "@typescript-eslint/no-base-to-string": "error,
  },
};

tsconfig

{
  "compilerOptions": {
    "strictNullChecks": true
  }
}

Expected Result

Since no-base-to-string checks whether a plain class's supertypes are ignored (see #11520), I expect it to also check whether a generic class's supertypes are ignored.

Actual Result

'error' will use Object's default stringification format ('[object Object]') when stringified. 12:15 - 12:20

Additional Info

No response

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

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions