const handleFooBar = (foobar: FooBar): string => foobar.foo + foobar.bar;
// TypeError: Property "bar" is missing
// Returns a version of handleFooBar ready for partialization
const curryRecordHandleFooBar = curryRecord(handleFooBar);
// Returns a function that only allows the missing properties
const handleFooBarWithFooProvided = curryRecordHandleFooBar({
// TypeError: "foo" is not assignable to Omit<FooBar, 'foo'>
handleFooBarWithFooProvided({ foo: "foo2" });
// TypeError: Property "bar" is missing
handleFooBarWithFooProvided({});
handleFooBarWithFooProvided({ bar: "bar" });
// There are no missing properties, hence this is called with an empty record
const handleFooBarWithAllKeysProvided = curryRecordHandleFooBar({
handleFooBarWithAllKeysProvided({});
// TypeError: rejects functions that do not take records
curryRecord((x: number) => 123);
// TypeError: rejects non-unary functions
curryRecord((x: Record<any, any>, y: Record<any, any>) => 123);