Repository navigation
Description
Note
🤖 GPT-6.1 Sol responding on behalf of BleedingDev
🔎 Search Terms
"base constraint" "cache", "TS2339" "order" "constraint", "constraint" "history", "indexed access" "order" "constraint".
Related broad experiments: #65064 and #65367. I have not verified whether either draft fixes this specific regression.
🕗 Version & Regression Information
Reproduced in the Go compiler at 3e9236361fa97a9e6c685f4833ac457ae2d8c50a, the 7.1.0-beta reference pinned by tsrs 0.21.0. A hosted test checked that the reference checkout HEAD matched that pin and its tracked sources were unchanged, then used a Go build overlay to add the test.
I have not established the first affected commit or tested current nightly. This report is about the exact pinned native Go compiler, not an assertion about every current version.
The same sequential retained-checker test also reproduces in the Rust port. Its maintainers' triage found CLI parity rather than a tsrs-specific defect: oxc-project/tsrs#996.
⏯ Playground Link
This requires a native Go checker history, so no JavaScript Playground result is claimed. Exact test source and hosted logs are linked below; the sample has no dependencies.
💻 Code
// a.ts
const f: typeof victim = <U extends Box>(x: U, y: { b: string }) => x.b;
// b.ts
interface Box { a: Box; b: string }
function victim<T extends Box>(
x: T,
y: T["a"]["a"]["a"]["a"]["a"]["a"]["a"]["a"]["a"]["a"]
): string {
return x.b;
}{"compilerOptions":{"strict":true,"noEmit":true,"target":"es2020","types":[]},"files":["a.ts","b.ts"]}🙁 Actual behavior
With a fresh program and one retained checker per history, individual sequential GetSemanticDiagnostics(ctx, file) calls give:
| Checked files, in order | Pinned Go result |
|---|---|
a.ts → b.ts |
TS2339 on b in return x.b (offsets 156–157) |
b.ts → a.ts |
No diagnostics |
b.ts alone, with only b.ts configured as a root |
No diagnostics |
Changing the return to x.b + y.b gives two false TS2339 errors in a → b and none in the other histories.
All controls passed in the same run:
- Replace only
b.ts'sx.bwithx.missing: TS2339 onmissingin every history, offsets 156–163. - A lone function taking the same ten-level
U["a"]…chain and returningy.b: string: no diagnostics. - Change that lone function's return annotation to
number: TS2322 at thereturnkeyword, offsets 134–140. function cycle<T extends T>(x: T) { return x; }: TS2313 on the constraintT, offsets 25–26; terminates.
This is not a race-dependent repro: each history deliberately uses one checker, sequential file requests, and a fresh program/pool. There is no global/semantic diagnostic request before those visits.
🙂 Expected behavior
No diagnostic for the positive fixture in any history. T extends Box explicitly guarantees x.b: string. Box["a"] remains Box, so the finite projected chain also retains b: string.
The negative controls must retain their real errors; replacing constraint loss with any would not be a valid correction.
Additional information about the issue
Direct hosted evidence: run 43651919628, research commit 9b5aabd1b2a510f9347f48bb713166af93c38366.
With that research checkout and verified ts-ref at the pin, the command is node tools/oracle/base-constraint-history/run.mjs. It runs go test -overlay … ./internal/compiler -run '^TestBaseConstraintHistory$' -count=1 -v inside ts-ref/tsc. The run is intentionally red on the two positive a → b cases, not an accepted fix. Artifact 14136950058 retains raw Go/Rust logs and both source revisions.
The repository's archived investigation already describes this counterexample. The suspected first wrong decision is turning a recursion-context cutoff into a permanent per-type noConstraintType answer. Indexed-access recursion identity is unwrapped to its object; the ten-level chain can reach the explicit type parameter at the heuristic cutoff. Exact resolution-cycle detection is separate and must remain intact.
We do not have a sound small cache-only patch. Simply skipping one cache write can leave dependent cached results poisoned; canonical cold recomputation can introduce a false property error for the lone-chain control. A correction needs to distinguish incomplete computation from proven absence while preserving termination for truly expanding/circular constraints.
Separately, our application intermittently emits TanStack TS2536 errors with this compiler family. This minimal regression does not prove that it caused that application failure. No diagnostic suppression, production checking-order change, or workaround is proposed here.
Follow-up: current main and existing order-independence draft
A second hosted native run, research commit e975f674c7bee03df914f498718c6be9eeeb245f, used the same fixtures, retained checker, file histories, and diagnostic assertions. Only construction was adapted to the newer ParseConfigHost/cancellable NewProgram APIs.
- Current main
6bdcb54d23f41bc7098c1f3488ac599c75b852ca: reproduces the original false TS2339 for both positivea → bcases. Other histories and all controls pass. - Draft [experiment] fully order independent type checking #65064 at
bf061ab866a8b8ecd13238247f2601a052dc6e2a: the originalreturn x.bfixture passes every history, butreturn x.b + y.bemits false TS2339 ony.bin all three histories. The lone finite-chain function also emits false TS2339 ony.b; the wrong-return control emits TS2339 instead of the required TS2322. Missing-property and exact-cycle controls pass.
These results do not establish a generally sound correction in that draft. No production adoption is proposed. Raw artifacts: main 14136339720, draft 14136703255.
Narrow candidate validated for this regression
Run 43655580941, research head b2655bf774ecd6ae51cea37615a81d92c07a3825, validates a small source patch on main 6bdcb54d23f41bc7098c1f3488ac599c75b852ca. It changes only getResolvedBaseConstraint's stack identity for an indexed access whose existing mapped-type normalization resolves to a type parameter: use that normalized parameter's type identity, not its symbol. Shared relation/inference identities and matchers, non-parameter targets, cache policy, exact cycles and depth bounds are untouched.
The candidate passed nineteen history/control cases, existing native checker/compiler packages and full TestLocal compiler conformance. Unmodified main retains three false-positive histories (original pair, pair returning both properties, mapped-object variant). Research-only observation additionally confirmed that direct and mapped twenty-access controls still reach the repeated-identity cutoff at depth 10; the observer is excluded from the compiler patch and ordinary/full-suite builds. Three-round independent review approved the final narrow candidate after rejecting an earlier inconsistent shared-helper version.
This is not a general proof of cache soundness, generative-recursion coverage, or the separate live TS2536 cause. It is not a released fix or an upstream PR. The tests and exact source patch are retained for human review.
Activity