TypeScript: Why can’t I assign a valid field of an object with type { a: “a”, b: “b” }

I believe this is because objects are contravariant in their key types. For more information see this answer. Likewise, multiple candidates for the same type variable in contra-variant positions causes an intersection type to be inferred. const paths = [‘a’, ‘b’] as const type Path = typeof paths[number] type PathMap = { [path in Path]: … Read more