我有这样的类型,
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
中的内容或任何我做错的事情?