type-fest icon indicating copy to clipboard operation
type-fest copied to clipboard

Request: `Slice` or `Rest`

Open matthias-ccri opened this issue 1 year ago • 1 comments

Use case: writing a facade for a function, that supplies the first function parameter:

import { getVehicleFeatures } from './vehicle-utils';

declare const vehicle;

function getFeatures (...args: Slice<1, Parameters<typeof getVehicleFeatures>) {
    return getVehicleFeatures(vehicle, ...args);
}

So the getFeatures function has all of the parameters of getVehicleFeatures except for the first, which is the vehicle itself. This is a form of currying. It allows getFeatures to reference the parameter array type of getVehicleFeatures and get a type with all the params except the first.

Alternate suggestions welcome :slightly_smiling_face:

Upvote & Fund

  • We're using Polar.sh so you can upvote and help fund this issue.
  • The funding will be given to active contributors.
  • Thank you in advance for helping prioritize & fund our backlog.
Fund with Polar

matthias-ccri avatar Nov 14 '23 23:11 matthias-ccri

Related #734

Emiyaaaaa avatar Nov 15 '23 03:11 Emiyaaaaa

#734 completed

Emiyaaaaa avatar Apr 07 '24 02:04 Emiyaaaaa