Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
630 views
in Technique[技术] by (71.8m points)

reactjs - 样式化组件元素的静态属性类型(Types for static property of styled-components element)

How can I type a styled-component element that has a static property?

(如何键入具有静态属性的样式化组件元素?)

interface IMyList {
  Item: ThemedStyledFunction<"li", any>;
}

const MyList: IMyList = styled.ul`
  padding: 0;
  margin: 0;
`;

MyList.Item = styled.li`
  display: block;
  padding-left: 16px;
  color: rebeccapurple;
`;

The above throws me Property 'Item' is missing in type 'String & StyledComponentBase<"ul", any, {}, never>' but required in type 'IMyList'.ts(2741) for "MyList" and Property 'attrs' is missing in type 'String & StyledComponentBase<"li", any, {}, never>' but required in type 'ThemedStyledFunction<"li", any, {}, never>'.ts(2741) for "MyList.Item".

(上面让我感到Property 'Item' is missing in type 'String & StyledComponentBase<"ul", any, {}, never>' but required in type 'IMyList'.ts(2741)对于“ Property 'Item' is missing in type 'String & StyledComponentBase<"ul", any, {}, never>' but required in type 'IMyList'.ts(2741) ”和Property 'attrs' is missing in type 'String & StyledComponentBase<"li", any, {}, never>' but required in type 'ThemedStyledFunction<"li", any, {}, never>'.ts(2741)为“ MyList.Item”缺少”。)

  ask by darksoulsong translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...