Skip to content

Performance degradation in 8.1.0: @typescript-eslint/no-unsafe-return with high-cardinality unions #10196

Closed
@AaronMoat

Description

@AaronMoat

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.

Issue Description

I haven't exactly narrowed down why yet, but there appears to be a performance degradation in patterns like this:

type Alpha2Code =
  | "AF"
  ...
  | "XK";

type LanguageCode =
  | "aa"
  ...
  | "zu";

type Locale = `${LanguageCode}-${Alpha2Code}`;

export function getDefaultLocale() {
  return 'en-AU' as Locale;
}

In the example reproduction, it takes about 73 seconds on my machine.

Note that tsc takes 0.7s.

Reproduction Repository Link

https://github.com/AaronMoat/typescript-eslint-perf

Repro Steps

  1. clone the repo
  2. yarn install
  3. yarn lint

Versions

package version
typescript-eslint 8.11.0
TypeScript 5.6.3
ESLint 9.13.0
node v20.17.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issuelocked due to agePlease open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.performanceIssues regarding performance

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions