Typescript remove first argument from a function
I think you can do that in a more generic way:
type OmitFirstArg<F> = F extends (x: any, ...args: infer P) => infer R ? (...args: P) => R : never;
and then:
type PostTransformationFn<F extends InitialFn> = OmitFirstArg<F>;
PG
You can use a conditional type to extract the rest of the parameters:
type State = { something: any }
type InitialFn = (state: State, ...args: string[]) => void
// this doesn't work, as F is unused, and args doesn't correspond to the previous arguments
type PostTransformationFn<F extends InitialFn> = F extends (state: State, ...args: infer P) => void ? (...args: P) => void : never
type X = PostTransformationFn<(state: State, someArg: string) => void> // (someArg: string) => void
Playground Link