2797. Partial Function with Placeholders¶ TypeScript 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18type JSONValue = | null | boolean | number | string | JSONValue[] | { [key: string]: JSONValue }; type Fn = (...args: JSONValue[]) => JSONValue; function partial(fn: Fn, args: JSONValue[]): Fn { return function (...restArgs) { return fn( ...args .map((arg) => (arg === '_' ? restArgs.shift() : arg)) .concat(restArgs) ); }; }