Repository navigation
Description
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 repronpm 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 problemThe 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 allwith 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-tsgolint7.0.2006 (OXLINT_TSGOLINT_PATH=node_modules/.bin/tsgolint) with the same command: nothing, exit 0. tsc --noEmitfromtypescript7.1.0-beta: no errors.tsrs --noEmit --fast: no errors.- Code that really uses the type,
box.take({ a: 1 } as never);:tsrs --noEmitreportssrc/index.ts(13,1): error TS2590at 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)
- The rule builds the type.
NoUnsafeEnumAssignment::visit(VariableDeclaration) βcheck_assignmentβunsafe_assignmentβmismatchβdeep_mismatch, senderAnyBox, receiverBox<unknown>. For the receiver's propertytakeit recurses with the union of the 17takemethod types, andchecker.get_number_index_type(sender)resolves that union's members. - 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_parametersintersects the parameter types one signature at a time, and adding the 17th reachescheck_cross_product_unionwith 65,536 Γ 2.report_too_complexreports atcurrent_node, which isNoneduring a rule's query, soerror(None, β¦)adds it to the checker's global diagnostics. --type-checkreports it. Inrun_in_region,run_programrunslint_oneper file on its checker:get_semantic_diagnostics_with_checkerfirst, then the rules throughlint_file. Only after that doesprogram_ref.get_global_diagnostics()(CheckerPool::get_global_diagnosticsβ eachChecker::get_global_diagnostics) collect the global diagnostics, the rules' included, andreport_global_errorprints 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_fileand 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, oxlint1.92.0(usingnode_modules/.bin/tsrs-lint) - Reference:
typescript7.1.0-betatsc --noEmitreports no errors - Node.js 24.22.0, npm 11.19.1, macOS 27.2 (arm64)
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
oxc-captain commentedon Nov 7, 2026
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: