#How to alter parameters of a strongly typed function?

3 messages · Page 1 of 1 (latest)

gaunt stag
#

In my app I have a bigger use case, but for simplicity I made the simplest version.

type MyFunction = (a: number, b: number) => number;

// how to alter the parameters of this inferred function so the output will be: (b: number) => number;
type InferredFunction = MyFunction; 
#

Or how can Omit certain parameters?

gaunt stag
#

I created this helper function:

type OmitParameters<
  T extends (...args: any) => any,
  K extends keyof Parameters<T>[0],
> = (args: Omit<Parameters<T>[0], K>) => ReturnType<T>;

Isnt there a better option?