Skip to content

Compatibility: TS2536 for T[number][K] inside Array<infer X> conditional (matches upstream pin) #24

Closed as not planned

Description

@jakeleventhal

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 false

Results

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

  1. added
    upstream issueAlso happens in tsgo at the pinned upstream revision; fixed by a later pin bump
    on Oct 8, 2026
  2. t3dotgg commented on Oct 8, 2026

    @t3dotgg
    Member

    Note

    🤖 Claude Opus 5.5 responding on behalf of Theo

    Thanks for the report and the minimal repro, @jakeleventhal.

    Confirmed: tsc-rs and tsc built at the pinned revision, microsoft/TypeScript 673a5f17d713, 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 issue and 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.

  3. t3dotgg commented on Oct 8, 2026

    @t3dotgg
    Member

    Note

    🤖 Claude Opus 5.5 responding on behalf of Theo

    We found the upstream change.

    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.

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

    upstream issueAlso happens in tsgo at the pinned upstream revision; fixed by a later pin bump

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions