TypeScript Version: 2.6.2
Code
type A = {
foo?: number;
bar: string;
};
type B = {
foo?: number;
bar: string;
qux: boolean;
};
type JustOptionalFoo = Pick<A | B, 'foo'>;
// Type '{}' is not assignable to type 'Pick<A | B, "foo">'.
// Property 'foo' is missing in type '{}'.
const a: JustOptionalFoo = {};
Expected behavior:
The above code compiles, since foo is optional in both type A and type B.
Actual behavior:
foo is turned into a required parameter.