Skip to content

Bug: [no-redundant-type-constituents] False-positive with Record intersections #11811

@silverwind

Description

@silverwind

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.9.3&fileType=.tsx&code=C4TwDgpgBAYg9nKBeKAlCBjOAnAJgHgGdhsBLAOwHMAaKAQ3JAD4BuAKFEigCE7tlYCKADIoAbwBGfAPwAuKMTJUAvu07ReALwG9%2BoyXU1yFJCpVVA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6Jge1ukQBNYmvAIYtaRUrTIcmyfJXyxELVBkiJo0DtEjgwAXxB6gA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA&tokens=false

Repro Code

type Foo = Record<string, any>;
type Bar = Foo & {bar?: string};
type Baz = Bar & {baz?: string};
//   ^ Bar is overridden by { baz?: string | undefined; } in this intersection type.

ESLint Config

module.exports = {
  "rules": {
    "@typescript-eslint/no-redundant-type-constituents": "error"
  }
};

tsconfig

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

Expected Result

No error, expected resulting type is {foo?: string, bar?: string, [other: string]: any}.

Actual Result

Error "Bar is overridden by { baz?: string | undefined; } in this intersection type.".

Additional Info

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpackage: eslint-pluginIssues related to @typescript-eslint/eslint-plugintriageWaiting for team members to take a look

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions