reactjs - styled-components personalizados breakpoint `Elemento de vinculação 'theme' tem implicitamente um tipo 'any'`
Eu criei funções auxiliares de "breakpoints" com styled-components que ficam assim:
type Props = Record<string, unknown>
type Interpolators<P extends Props> =
| SimpleInterpolation[]
| Array<Interpolation<ThemedStyledProps<Props, Theme>>>
| Array<Interpolation<ThemedStyledProps<P, Theme>>>
export const xs = <T extends Props>(
strings: TemplateStringsArray,
...values: Interpolators<T>
) => css`
@media screen and (min-width: ${breakpoints.xs}px) {
${css(strings, ...values)}
}`
Isso costumava funcionar muito bem, mas com o TS v4.1x estou recebendo o seguinte erro quando tento acessar o tema ou qualquer outra propriedade dentro da função xs:
Binding element 'theme' implicitly has an 'any' type. TS7031É assim que estou usando:
export const Container = styled.div`
height: ${NAVBAR_HEIGHT}px;
border-bottom: 2px solid ${({ theme }) => theme.colors.borderSecondary};
padding: 0px 1rem;
box-sizing: border-box;
display: flex;
justify-content: space-between;
align-items: center;
background-color: ${({ theme }) => theme.colors.containerPrimary};
${xs`
background-color: ${({ theme }) => theme.colors.borderSecondary}; // This is where it fails
`}
`