如果我使用 @types/styled-components
4.4.1或更高版本,我的所有样式组件的类型从 StyledComponent
到 any
. 这是预期的行为吗?
我目前使用的是 [email protected]
但我在使用最新版本和类型声明时遇到了同样的问题。
import styled from "styled-components";
const ErrorMessage = styled.label`
color: red;
font-size: 16px;
font-weight: 600;
`; // any
如果有人遇到同样的问题,我想把我的发现公布出来。我安装的一个依赖项 hoist-non-react-statics@2
导致错误的 @types/styled-components
v4.1.1及以上。
运行 npm i --save-dev @types/hoist-non-react-statics@3
为我修好了。