Repository navigation
Compatibility: TS2536 for T[number][K] inside Array<infer X> conditional (matches upstream pin) #24
Description
Summary
Inside T extends Array<infer X>, a mapped key K in keyof X cannot index T[number] in the nested object branch. TypeScript 7.0.2 accepts it; tsc-rs and its exact upstream pin report TS2536. This caused one diagnostic in an API-schema type helper.
This is a compatibility report against TypeScript 7.0.2, not evidence of a Rust-only bug. The exact upstream version documented by this project, typescript@7.1.0-dev.20260929.1 / 673a5f17d713, produces the same diagnostic. I am filing this to record a real-world upgrade difference in this repository.
Versions and platform
- tsc-rs npm release: 0.1.0.
- Baseline: TypeScript 7.0.2.
- Upstream comparison: TypeScript 7.1.0-dev.20260929.1.
- macOS:
Darwin 25.6.0 arm64 arm.
Standalone reproduction
No application source or external library is needed for this small repro; the package.json only installs comparison compilers.
package.json
{
"private": true,
"devDependencies": {
"tsc7": "npm:typescript@7.0.2",
"upstream": "npm:typescript@7.1.0-dev.20260929.1",
"tsc-rs": "0.1.0"
}
}tsconfig.json
{
"compilerOptions": {
"target": "es2022",
"module": "preserve",
"moduleResolution": "bundler",
"lib": [
"esnext",
"dom",
"dom.iterable"
],
"strict": true,
"skipLibCheck": true,
"noEmit": true,
"types": []
},
"files": [
"case.ts"
]
}case.ts
export type Item<T> =
T extends Array<infer X>
? X extends Record<string, unknown>
? { [K in keyof X]: T[number][K] }
: never
: never;bun install --ignore-scripts
bun node_modules/tsc-rs/bin/tsc-rs -p tsconfig.json --pretty false
bun node_modules/tsc7/bin/tsc -p tsconfig.json --pretty false
bun node_modules/upstream/bin/tsc -p tsconfig.json --pretty falseResults
| Checker | Result |
|---|---|
| TypeScript 7.0.2 | Pass |
| tsc-rs 0.1.0 | Fail, exit 2 |
| TypeScript 7.1.0-dev.20260929.1 (exact upstream pin) | Fail, exit 2 |
| Bun 1.4.3-canary.1+43a42a836 | Pass |
tsc-rs output (upstream reports the same failure):
case.ts(4,24): error TS2536: Type 'K' cannot be used to index type 'T[number]'.
Expected behavior / attribution
Record the compatibility difference from 7.0.2. Since the pin reproduces it, the remaining upstream question is whether the rejected relationship is an intentional constraint change or a regression; this report does not assume a Rust-only fix is needed.
Controls and upstream context
Changing only T[number][K] to X[K] makes the same type pass tsc-rs, pinned upstream, TypeScript 7.0.2, and both Bun canaries:
export type Item<T> = T extends Array<infer X>
? X extends Record<string, unknown> ? { [K in keyof X]: X[K] } : never
: never;Closed #12 also has TS2536, but its repro is ts-proto's Exact<P, I> helper with different distributed parameter constraints. I have not established that the two patterns have the same root cause, so this records the exact Array/infer/indexing pattern separately. No exact matching upstream issue was found in the open/closed search.
Activity
t3dotgg commentedon Oct 8, 2026
Note
🤖 Claude Opus 5.5 responding on behalf of Theo
Thanks for the report and the minimal repro, @jakeleventhal.
Confirmed: tsc-rs and
tscbuilt at the pinned revision, microsoft/TypeScript673a5f17d713, give the same TS2536, byte for byte, so it is upstream behavior and not a port bug. tsc-rs output follows the pin, and an upstream change reaches tsc-rs with a later pin bump.We are labeling this
upstream issueand keeping it open while we look for the upstream change and any upstream issue; we will link them here. If you open one in microsoft/TypeScript, please link it too.t3dotgg commentedon Oct 8, 2026
Note
🤖 Claude Opus 5.5 responding on behalf of Theo
We found the upstream change.
typescript@7.1.0-dev.20260917.1.7.1.0-dev.20260916.1and 7.0.2 pass.X extends Record<string, unknown> ? ...distributesX, soKis a key of one member ofX.T[number]is still all ofX. A key of one member is not always a key of the union, and #64237 now checks this. It is the same cause as False TS2344/TS2536 on ts-proto's generatedExact<P, I>helper type #12.X[K]instead ofT[number][K], as in your control. It gives the same type whenXis not a union, and it passes on 7.0.2, the pin, upstream main and tsc-rs.tsc-rs follows the pin, so it keeps this error while upstream keeps it. We will close this as upstream behavior, like #12. If you open an upstream issue and upstream changes the rule, link it here and we will reopen.