What is the best way to properly declare a type for this scenario?
interface MediaQueryProps {
[key: string]: number;
}
const size: MediaQueryProps = {
small: 576,
medium: 768,
large: 992,
extra: 1200
};
export default Object.keys(size).reduce((acc, cur) => {
acc[cur] = `(min-width: ${size[cur]}px)`;
return acc;
}, {});
The issue arises with acc[cur]
due to
An element implicitly has an 'any' type because an expression of type 'string' cannot be used to index type '{}'. No index signature with a parameter of type 'string' was found on type '{}'
Is there a method to define a type for this situation without resorting to using any?