Suppose i have these types
/** Types of a function's arguments */
export type ArgumentTypes<F extends Function> = F extends (...args: infer A) => any ? A : never;
export type ExcludeQueryParams<T> = { [P in keyof T]: T[P] extends PagingParameters ? never : T[P] }
Then i have this code to extract the types of the arguments for a function
function test(query: PagingParameters, as: number, f: string) {
return 1;
}
type argTypes = ArgumentTypes<typeof test>
type result = ExcludeQueryParams<argTypes>
Above, argTypes will equal [PagingParameters, number, string]
What i am trying to do is extract the PagingParameters
type from the array so result
is [number, string]
, however using ExcludeQueryParams
the result is [never, number, string]
.
How can achieve this properly without the final type array containing the never
type?