Simplified, styled.hr
is typed to accept either a template string interpolation, or a valid style object.
In this case, a valid style object is that which borderTopStyle
can only be one of many possible strings, specifically, the type 'solid' | '...'
However, TS' default behavior is to infer any objects' properties as string
, and string
is not assignable to 'solid' | '...'
.
// obj.a is type "string" not type "'hello'"
const obj = { a: 'hello' }