Here is a new interface
declaration:
export interface ApiClientMetodOptions {
initialFilterSatement?: string;
fieldsMapping?: {
[K in keyof P]?: string;
};
requestParams?: IRequestParams<P>;
additionalParams?: {
[key: string]: unknown;
};
additionalHeaders?: {
[key: string]: string;
};
cancelOption?: IRequestCancelOption;
}
However, I encountered an error:
Property 'fieldsMapping' of exported interface has or is using private name 'P'.
I created this to encapsulate the type and use it in various methods. For example:
export interface IApiClient {
/**
* Generic function for fetching a list of a certain instances
* @param fieldsMapping function converting fields of `P`-type object to a query field names
*/
getEntities<P, T>(
url: string,
options: {
instanceToEntity?: (instance: unknown) => T;
} & ApiClientMetodOptions,
): Promise<T[]>;
I am not very familiar with "typescript"
. What mistake am I making and how can I resolve this issue?