Title: Go checker: finite indexed-access constraint loses its explicit bound depending on prior file checking · Issue #65508 · microsoft/TypeScript · GitHub
Open Graph Title: Go checker: finite indexed-access constraint loses its explicit bound depending on prior file checking · Issue #65508 · microsoft/TypeScript
X Title: Go checker: finite indexed-access constraint loses its explicit bound depending on prior file checking · Issue #65508 · microsoft/TypeScript
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...
Open Graph 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...
X Description: Note🤖 GPT-6.1 Sol responding on behalf of BleedingDev 🔎 Search Terms "base constraint" "cache", "TS2339" "order" "constraint", "constraint&quo...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/65508
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Go checker: finite indexed-access constraint loses its explicit bound depending on prior file checking","articleBody":"> [!NOTE]\n> 🤖 **GPT-6.1 Sol responding on behalf of BleedingDev**\n\n### 🔎 Search Terms\n\n`\"base constraint\" \"cache\"`, `\"TS2339\" \"order\" \"constraint\"`, `\"constraint\" \"history\"`, `\"indexed access\" \"order\" \"constraint\"`.\n\nRelated broad experiments: #65064 and #65367. I have not verified whether either draft fixes this specific regression.\n\n### 🕗 Version & Regression Information\n\nReproduced 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.\n\nI 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.\n\nThe same sequential retained-checker test also reproduces in the Rust port. Its maintainers' triage found CLI parity rather than a tsrs-specific defect: https://github.com/oxc-project/tsrs/issues/996.\n\n### ⏯ Playground Link\n\nThis 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.\n\n### 💻 Code\n\n```ts\n// a.ts\nconst f: typeof victim = \u003cU extends Box>(x: U, y: { b: string }) => x.b;\n\n// b.ts\ninterface Box { a: Box; b: string }\nfunction victim\u003cT extends Box>(\n x: T,\n y: T[\"a\"][\"a\"][\"a\"][\"a\"][\"a\"][\"a\"][\"a\"][\"a\"][\"a\"][\"a\"]\n): string {\n return x.b;\n}\n```\n\n```json\n{\"compilerOptions\":{\"strict\":true,\"noEmit\":true,\"target\":\"es2020\",\"types\":[]},\"files\":[\"a.ts\",\"b.ts\"]}\n```\n\n### 🙁 Actual behavior\n\nWith a fresh program and one retained checker per history, individual sequential `GetSemanticDiagnostics(ctx, file)` calls give:\n\n| Checked files, in order | Pinned Go result |\n|---|---|\n| `a.ts → b.ts` | TS2339 on `b` in `return x.b` (offsets 156–157) |\n| `b.ts → a.ts` | No diagnostics |\n| `b.ts` alone, with only `b.ts` configured as a root | No diagnostics |\n\nChanging the return to `x.b + y.b` gives two false TS2339 errors in `a → b` and none in the other histories.\n\n**All controls passed in the same run:**\n\n- Replace only `b.ts`'s `x.b` with `x.missing`: TS2339 on `missing` in every history, offsets 156–163.\n- A lone function taking the same ten-level `U[\"a\"]…` chain and returning `y.b: string`: no diagnostics.\n- Change that lone function's return annotation to `number`: TS2322 at the `return` keyword, offsets 134–140.\n- `function cycle\u003cT extends T>(x: T) { return x; }`: TS2313 on the constraint `T`, offsets 25–26; terminates.\n\nThis 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.\n\n### 🙂 Expected behavior\n\nNo 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`.\n\nThe negative controls must retain their real errors; replacing constraint loss with `any` would not be a valid correction.\n\n### Additional information about the issue\n\n**Direct hosted evidence:** [run 43651919628](https://github.com/BleedingDev/tsrs/actions/runs/43651919628), research commit [`9b5aabd1b2a510f9347f48bb713166af93c38366`](https://github.com/BleedingDev/tsrs/commit/9b5aabd1b2a510f9347f48bb713166af93c38366).\n\n- [Exact Go integration test](https://github.com/BleedingDev/tsrs/blob/9b5aabd1b2a510f9347f48bb713166af93c38366/tools/oracle/base-constraint-history/history_test.go)\n- [Overlay runner](https://github.com/BleedingDev/tsrs/blob/9b5aabd1b2a510f9347f48bb713166af93c38366/tools/oracle/base-constraint-history/run.mjs)\n- [Shared fixtures](https://github.com/BleedingDev/tsrs/tree/9b5aabd1b2a510f9347f48bb713166af93c38366/crates/tsrs_compiler/testdata/base_constraint_history)\n\nWith 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.\n\nThe repository's [archived investigation](https://github.com/oxc-project/tsrs/blob/38931a58019107ba31581791e26a7aa414c9e015/notes/determinism-base-constraint-depth.md) 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.\n\nWe 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.\n\nSeparately, 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.\n\n\n### Follow-up: current main and existing order-independence draft\n\nA second [hosted native run](https://github.com/BleedingDev/tsrs/actions/runs/43652972419), 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.\n\n- **Current main `6bdcb54d23f41bc7098c1f3488ac599c75b852ca`:** reproduces the original false TS2339 for both positive `a → b` cases. Other histories and all controls pass.\n- **Draft #65064 at `bf061ab866a8b8ecd13238247f2601a052dc6e2a`:** the original `return x.b` fixture passes every history, but `return x.b + y.b` emits false TS2339 on `y.b` in **all three histories**. The lone finite-chain function also emits false TS2339 on `y.b`; the wrong-return control emits TS2339 instead of the required TS2322. Missing-property and exact-cycle controls pass.\n\nThese results do not establish a generally sound correction in that draft. No production adoption is proposed. Raw artifacts: main `14136339720`, draft `14136703255`.\n\n\n### Narrow candidate validated for this regression\n\n[Run 43655580941](https://github.com/BleedingDev/tsrs/actions/runs/43655580941), research head `b2655bf774ecd6ae51cea37615a81d92c07a3825`, validates a [small source patch](https://github.com/BleedingDev/tsrs/blob/b2655bf774ecd6ae51cea37615a81d92c07a3825/tools/oracle/base-constraint-history/indexed-access-identity.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.\n\nThe 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.\n\nThis 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.\n","author":{"url":"https://github.com/BleedingDev","@type":"Person","name":"BleedingDev"},"datePublished":"2026-11-14T23:16:42Z","url":"https://github.com/microsoft/TypeScript/issues/65508"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:b09a8977-c506-54f9-e976-df24aab9d7ed |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | EB10:11EACE:818943:AEFD51:6B00E0FF |
| html-safe-nonce | 4340599262b75fd1b829c7b0db174e07e2eea90f11bb03539002df7dd9720296 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQjEwOjExRUFDRTo4MTg5NDM6QUVGRDUxOjZCMDBFMEZGIiwidmlzaXRvcl9pZCI6IjQ3NzAyMjc3NTg2MzI1OTE2MTUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | d43ba505c4a580fadcad354cb1782789133c49e901c9cd00546691e45be3471f |
| hovercard-subject-tag | issue:6397291149 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/microsoft/TypeScript/65508/issue_layout |
| twitter:image | https://opengraph.githubassets.com/44d8c500efc24c90cbd1fd8476798d81e44eefbcc839649feb48d6b698441934/microsoft/TypeScript/issues/65508 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/44d8c500efc24c90cbd1fd8476798d81e44eefbcc839649feb48d6b698441934/microsoft/TypeScript/issues/65508 |
| og:image:alt | 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... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | BleedingDev |
| hostname | github.com |
| expected-hostname | github.com |
| None | 043c3f30fbcbe2c6c8e729e10cbbbc90c406546f9fbbb67c648d38f6b7d16daf |
| turbo-cache-control | no-preview |
| go-import | github.com/microsoft/TypeScript git https://github.com/microsoft/TypeScript.git |
| octolytics-dimension-user_id | 6154722 |
| octolytics-dimension-user_login | microsoft |
| octolytics-dimension-repository_id | 20929025 |
| octolytics-dimension-repository_nwo | microsoft/TypeScript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 20929025 |
| octolytics-dimension-repository_network_root_nwo | microsoft/TypeScript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 5425dc24e8bd8d6fca9641a12afc984825a43875 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width