【发布时间】:2019-07-12 05:03:18
【问题描述】:
我有这样的类型,
interface StyleProps {
display?: 'hide' | 'active'
}
并且该类型正在被下面的组件使用
<Section display={`${this.state.section !== 'chatbot' ? 'hide' : 'active'}`}>
display 只能是 hide 或 active 但我仍然收到此错误
TS2322: Type 'string' is not assignable to type '"hide" | "active" | undefined'.
有什么方法可以查看display 中的内容或我做错了什么?
【问题讨论】:
标签: reactjs typescript typescript-typings typescript2.0 styled-components