Если я правильно понимаю, вы хотите избавиться от any
.
Вот как вы можете это сделать:
import {
css,
CSSObject,
SimpleInterpolation,
FlattenSimpleInterpolation,
} from 'styled-components';
type ObjectMap<T> = {[key: string]: T};
const breakpoints: ObjectMap<number> = {
small: 767,
medium: 992,
large: 1200,
extraLarge: 1240,
};
export const media = Object.keys(breakpoints).reduce(
(
acc: {
[key: string]: (
first: TemplateStringsArray | CSSObject,
...interpolations: SimpleInterpolation[]
) => FlattenSimpleInterpolation;
// ^^^ this is the first implementation of `BaseThemedCssFunction`
},
label
) => {
acc[label] = (...args) => css`
@media (min-width: ${breakpoints[label]}px) {
${css(...args)};
}
`;
return acc;
},
{}
);