Skip to content

tsrs-lint --type-check reports a TS2590 on the tsconfig that a rule's type query caused (no-unsafe-enum-assignment); tsrs --noEmit reports noneΒ #941

Closed

Description

@ceolinwill

Note

πŸ€– Claude Opus 5.5 opening this issue on behalf of Will

oxlint --type-aware --type-check with tsrs-lint reports this on the tsconfig, while tsrs --noEmit on the same tsconfig reports nothing:

tsconfig.json:1:1: Expression produces a union type that is too complex to represent. [Error/typescript(TS2590)]

The program never builds that type. typescript/no-unsafe-enum-assignment does, while it compares types, and the checker records the TS2590 with no location because a rule's query runs outside its node walk. --type-check then reports every checker's global diagnostics after the rules have run, so the rule's TS2590 comes out as a program error.

This blocks us from replacing a separate tsrs --noEmit with the 0.22/0.23 --type-check lint run: the lint run fails on an error the typecheck doesn't have.

Reproduction

https://github.com/ceolinwill/tsrs-type-check-ts2590-repro

npm install
npm run repro

npm run repro runs tsrs --noEmit -p tsconfig.json, then oxlint --type-aware --type-check -A all -D typescript/no-unsafe-enum-assignment --format=unix src/index.ts:

> repro
> npm run --silent typecheck && npm run --silent lint

tsrs --noEmit: no errors
tsconfig.json:1:1: Expression produces a union type that is too complex to represent. [Error/typescript(TS2590)]

1 problem

The whole program:

interface Box<T> {
  take(value: { a: T } | { b: T }): void;
}

type AnyBox =
  | Box<1> | Box<2> | Box<3> | Box<4> | Box<5> | Box<6>
  | Box<7> | Box<8> | Box<9> | Box<10> | Box<11> | Box<12>
  | Box<13> | Box<14> | Box<15> | Box<16> | Box<17>;

declare const box: AnyBox;

export const wide: Box<unknown> = box;

It fails in 5 of 5 runs, in default mode and with TSRS_FAST=1. What changes the result:

  • -A all with no rule enabled: nothing, exit 0.
  • The rule without --type-check: nothing, exit 0.
  • 16 members instead of 17 (2^16 = 65,536): nothing, exit 0.
  • Upstream oxlint-tsgolint 7.0.2006 (OXLINT_TSGOLINT_PATH=node_modules/.bin/tsgolint) with the same command: nothing, exit 0.
  • tsc --noEmit from typescript 7.1.0-beta: no errors. tsrs --noEmit --fast: no errors.
  • Code that really uses the type, box.take({ a: 1 } as never);: tsrs --noEmit reports src/index.ts(13,1): error TS2590 at that call, as expected.

TSRS_TRACE_UNION_REDUCTION=1 npm run lint shows the cross product has no location and no file being checked:

tsrs cross product: checker 4 at - while checking - | size 131072, too complex (TS2590) | union 65536 … | union 2 …

In our app (a large private monorepo) the union is 34 zod 4 object schemas, whose check(...checks: (CheckFn<T> | $ZodCheck<T>)[]) methods give the same 2-member parameter type; the trace shows union 65536 and union 2 of $ZodCheck<…> and CheckFn<…>, also at - while checking -. It showed in 5 of 5 runs, default and TSRS_FAST=1, and no other type-aware rule triggers it there.

Where it goes wrong (v0.23.0, same as main)

  1. The rule builds the type. NoUnsafeEnumAssignment::visit (VariableDeclaration) β†’ check_assignment β†’ unsafe_assignment β†’ mismatch β†’ deep_mismatch, sender AnyBox, receiver Box<unknown>. For the receiver's property take it recurses with the union of the 17 take method types, and checker.get_number_index_type(sender) resolves that union's members.
  2. The checker hits the limit with no location. get_index_infos_of_type β†’ resolve_structured_type_members β†’ resolve_union_type_members β†’ get_union_signatures β†’ combine_union_or_intersection_member_signatures β†’ combine_union_or_intersection_parameters intersects the parameter types one signature at a time, and adding the 17th reaches check_cross_product_union with 65,536 Γ— 2. report_too_complex reports at current_node, which is None during a rule's query, so error(None, …) adds it to the checker's global diagnostics.
  3. --type-check reports it. In run_in_region, run_program runs lint_one per file on its checker: get_semantic_diagnostics_with_checker first, then the rules through lint_file. Only after that does program_ref.get_global_diagnostics() (CheckerPool::get_global_diagnostics β†’ each Checker::get_global_diagnostics) collect the global diagnostics, the rules' included, and report_global_error prints them on the tsconfig.

Global diagnostics have been reported since #902; tsrs --noEmit never runs these queries.

Expected

--type-check reports what tsrs --noEmit reports for the tsconfig, as the type checking in the lint run docs describe: no errors here. Diagnostics the checker records while answering a rule's type queries aren't program diagnostics.

Possible fixes

  • Leave out of the reported global diagnostics whatever a checker adds while rules run, for example by noting each checker's global diagnostic count before lint_file and dropping what was added after it.
  • Or collect the global diagnostics from the type-check pass only, before rules run on those checkers.

Environment

  • tsrs 0.23.0-ts7.1.0-beta, oxlint 1.92.0 (using node_modules/.bin/tsrs-lint)
  • Reference: typescript 7.1.0-beta tsc --noEmit reports no errors
  • Node.js 24.22.0, npm 11.19.1, macOS 27.2 (arm64)

Activity

  1. oxc-captain commented on Nov 7, 2026

    @oxc-captain
    Contributor

    Triage failed unexpectedly (attempt 1 of 3).

    Run: https://github.com/oxc-project/tsrs/actions/runs/42384914807

    I can retry if a new comment provides more information or asks me to try again.

    Error:

    [flue] skill("triage") failed: 404 status code (no body)
    
  2. added
    triage: failed
    on Nov 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    triage: failed

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions