type A = { type: "x", x: number } | { type: "y", y: number };
1.
type B<T, K> = T extends {type:K} ? T : never;
declare function f<K>(k: K, p: B<A, K>);
f("x", { type:"y", y: 3 }); //no error
2.
type B<T, K> = T extends {type:K} ? Identity<T> : never;
type Identity<T> = { [K in keyof T]: T[K] };
f("x", { type:"y", y: 3 }); //error
两种情况有什么区别,为什么打字稿会在这两种情况下推断出f中K的不同类型?