Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
function testGenerics<
P extends { stays: string; getsRemoved: string },
R = Omit<P, "getsRemoved">,
>(argumentP: P, argumentR: R) {
return null;
}
testGenerics({ stays: "foo", getsRemoved: "bar", test: 1 }, {}); // Why doesn't it complain about missign "stays" attribute?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment