您将如何正确地为此声明类型?
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;
}, {});
acc[cur]
人抱怨是因为
Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{}'.
No index signature with a parameter of type 'string' was found on type '{}'
有没有什么方法可以不使用任何?