Answer the question
In order to leave comments, you need to log in
Why is the type formed incorrectly?
Hello! I ran into a problem with component typing
Typing component props:
// Основная проблема в этом типе
type FunctionParams<U> = U extends undefined
? {
page: number;
limit: number;
}
: {
page: number;
limit: number;
} & U;
interface IProps<T, U> {
queries?: U;
getList: (
props: FunctionParams<U>
) => AxiosPromise<IAxiosPaginatedResponse<T>>;
...
}
const filters = {
search: '';
city: 1;
};
<Pagination
getList={getList}
queries={filters}
...
/>
export const getList = (props: {
page: number;
limit: number;
search: string;
city: number;
}): AxiosPromise<IAxiosPaginatedResponse<IListItem>> => {
return ...
};
(props: ({page: number, limit: number} & {page: number, limit: number, search: string, city: number}) => ...
(props: ({page: number, limit: number} & {newProp: string, search: string, city: number}) => ...
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question