Inconsistent interpretation of indexed generic types
07:18 13 Jan 2026

I've run into strange behavior when indexing generic types.

type Parent = {
  Child: unknown;
};

function generic() {
  const child: B["Child"] = 100; // no error – B["Child"] is treated as unknown

  type Test = unknown extends B["Child"] ? "yes" : "no";
  const check: Test = "yes"; // yes error – B["Child"] is not treated as unknown
}

Really, I'd like B["Child"] to be treated as a type that's not known, not as unknown. So I'm not happy about the first line in generic.

Is this expected? Is it a bug? Is there a good way around it?

typescript typescript-generics