#Type that returns the shape of T, and makes props required if they are required in U?
12 messages · Page 1 of 1 (latest)
hum, I guess it works for the simple cases
ye, that's what I was about to say
type A = {
a: string;
b?: string;
};
type B = {
b: string;
c: number;
};
type Type<T, U> = T & Pick<U, keyof (T | U)>;
const x: Type<A, B> = {
// ^
// Type '{ a: string; }' is not assignable to type 'Type<A, B>'.
// Property 'b' is missing in type '{ a: string; }' but required in type 'Pick<B, "b">'.
// ^? - const x: Type<A, B>
a: "hello",
};
@stoic estuary