如何将样式化组件作为 属性 添加到 TypeScript 中的另一个样式化组件?

How can I add a StyledComponent as a property to a another StyledComponent in TypeScript?

This is what I'm trying to do. It works just fine in JavaScript but not in TS

export const Container = styled.View`
    align-items: center;
`;

Container.Title = styled.Text`
    font-family: Poppins-Regular;
    color: #000000;
    font-size: 20px;
`;
Property 'Title' does not exist on type 'StyledComponent<typeof View, DefaultTheme, {}, never>'.

来自文档:

To prevent TypeScript errors on the css prop on arbitrary elements, install
@types/styled-components and add the following import once in your project:

import {} from 'styled-components/cssprop'

所以尝试 运行 npm install --save-dev @types/styled-components 并在某处添加该导入。

来源:https://styled-components.com/docs/api#usage-with-typescript