I'm wondering how to define the type for the defaultEncoder parameter. It has the same parameters as the function itself.
const paramsSerializer = (params: Params) => {
const encoder = (
str: string,
defaultEncoder: any,
charset: string,
type: string
) => {
const encodedStr = defaultEncoder(str, defaultEncoder, charset, type);
return transformEncodedStr(encodedStr)
};
return transformParams(params, { encoder });
}
If I define the defaultEncoder every time it would be an infinite sequence of types.
defaultEncoder: (
str: string,
encoder: (
str: string,
encoder: // And so on...
charset: string,
type: "key" | "value"
) => any,
charset: string,
type: "key" | "value"
) => any,