Skip to content

Regression: [no-redundant-type-constituents] is overridden by string in this intersection type #11790

@splincode

Description

@splincode

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=4.9.3&fileType=.tsx&code=KYDwDg9gTgLgBDAnmYcAqBXAlgGQhAZ2AFUA7LCUgHmID44BeAKDlbgB85iW3OAKYnFAxgpACYE4BGFCykA5jzZsA-HABKwAMbQxVUsABuwKABo4B41HoAyKTLmLlygFxchIEeMmkMAWwAjEyVnNU0dKD1LE3No6zg7X0Dg5zY3QWFRCSlEQIgAGxDlMO1dfSMYiwr4uwJcgIKitPdM7zgArHk5GCbWEoio6tjq23bO7t64NziASgBuJkXQSFghJPRsAGEMKChRLUQ4AG8eAEEoP1EsAENSABEoa79GOAByU4BZO9fTHgB6P5wAB0IKYAF8luBoPBRP4Nlhtrt9ohNhAxKgTqxzpdyLcHk8Xq8AAwAVgAjD9wZCVvAkCh4Yi9qQDqcMDAIDo-GB8sAYBRSIweJwANbARAQABmGlKkSomAROyZB3M0lkCloQrgovFUvCZXljORqPRKoc6oWTGW0IQyFQBsVyIAatdZLcYJJmKxOPakczEKz2Zzubz%2BZq%2BD6lYdvVsHX7jahOEkglAOPY1fJU758vl5kwgA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6Jge1ukQBNYmvAIYtaRUrTIcmyfJXyxELVBkiJo0DtEjgwAXxB6gA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA&tokens=false

Repro Code

export type TuiLooseUnion<U> =
    | U
    | (U extends string
        ? Record<never, never> & string
        : U extends number
        ? Record<never, never> & number
        : U extends symbol
        ? Record<never, never> & symbol
        : U extends bigint
        ? Record<never, never> & bigint
        : never);


export enum TuiCurrency {
  ArmenianDram = 'AMD',
  // ...
}

export enum TuiCurrencyCode {
  ArmenianDram = '051',
}

export type TuiCurrencyAutocompletion =
  | keyof Record<TuiCurrency, string>
  | keyof Record<TuiCurrencyCode, string>;

export type TuiCurrencyVariants =
  | TuiCurrencyAutocompletion
  | (TuiCurrency | TuiCurrencyCode | number | string | null);

or string is overridden by SafeResourceUrl in this union type.

Image
@Injectable()
export class TuiLazyLoadingService extends Observable<SafeResourceUrl | string> {}

ESLint Config

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

tsconfig

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

Expected Result

No error here

Actual Result

Image

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