Answer the question
In order to leave comments, you need to log in
How to write types correctly?
Initially it was like this:
export enum SelectSize {
medium = 'medium',
large = 'large',
}
export const selectSizeValues: { [key in SelectSize]: string } = {
[SelectSize.medium]: '24px 56px 8px 16px',
[SelectSize.large]: '32px 64px 8px 24px',
};
export enum SelectSize {
medium = 'medium',
large = 'large',
}
export enum SelectSize1 {
bottom = 'bottom',
left = 'left',
right = 'right',
top = 'top',
}
export const selectSizeValues: { [key in SelectSize]: /* Какой тип прописать тут? */ } = {
[SelectSize.medium]: {
bottom: '8px',
left: '16px',
right: '56px',
top: '24px',
},
[SelectSize.large]: {
bottom: '8px',
left: '24px',
right: '64px',
top: '32px',
},
};
Answer the question
In order to leave comments, you need to log in
export enum SelectSize {
medium = "medium",
large = "large",
}
// создай тип
type PositionProps = {
bottom: string;
left: string;
right: string;
top: string;
};
// или интерфейс
interface PositionProps {
bottom: string;
left: string;
right: string;
top: string;
};
export const selectSizeValues: { [key in SelectSize]: PositionProps } = {
[SelectSize.medium]: {
bottom: "8px",
left: "16px",
right: "56px",
top: "24px",
},
[SelectSize.large]: {
bottom: "8px",
left: "24px",
right: "64px",
top: "32px",
},
};
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question