#64495·TypeScript

Record<K1, T> & Record<K2, U> is assignable to Record<K1 | K2, T & U>

Author: ahmedajiz629Created Sep 28, 2026Updated Sep 28, 2026

Search Terms

Record<K1, T> & Record<K2, U>, generic Record intersection, mapped type intersection generic keys, K1 | K2, T & U

Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about unsoundness

⏯ Playground Link

https://www.typescriptlang.org/play/?#code/MYewdgzgLgBAZjAvDAPAaQIwwKYA8rZgAmEM0ATgJZgDmANDACoNoBMO+hJZUVtDAVQB8ACgBQMGLgBcMAErZQ5IugwNGQmADJ5ikMvStBQumICUshUpWYYAHxht12mMKSbcYsaEixqABwBXKEs9AwAiAENwhgBvGDBZMECAWwAjbHIYAF9NHSt9FXC0mJh4lNkKahoczWR4yNl4xJgsbIY0ppgKmHDccJyc73BoGBBgoNhkOBQo0uak1Iys9t6SuO7K3mrakQDgs2HfTZ4+GuRxqEmAOkjrlLEgA

Code

typescript
const f = <K1 extends string, T, K2 extends string, U>(
  x: Record<K1, T> & Record<K2, U>,
): Record<K1 | K2, T & U> => x

const input: Record<"a", { n: number }> & Record<"b", { m: string }> = { a: { n: 1 }, b: { m: "x" } }
const output = f<"a", { n: number }, "b", { m: string }>(input)
const m: string = output.a.m

Actual behavior

The return is accepted, and so is output.a.m. Key "a" is only present on Record<"a", { n: number }>, so its value is { n: 1 }. The return type claims it is { n: number } & { m: string }.

Expected behavior

The return should be an error. A key that belongs only to K1 has type T, and T is not assignable to T & U. output.a.m should be an error.

Additional information about the issue

No response