Closed ankon closed 3 years ago
You can cast the value and in that way you preserve type checking
{ fontWeight: 'bold !important' as 'bold' }
Thanks, this looks fairly ok to me (compared to the as any
alternative, definitely!)
As a slightly better work around you can use [string]
syntax:
css({
['z-index']: `3 !important`,
})
You lose the type safety (which you want to ignore anyway...), but you don't have to as
type-assertion :)
This works:
textDecoration
is effectively a string as per https://github.com/frenic/csstype/blob/1bb6cbb1f3e55220952caa52e6f37c54b4a50f54/index.d.ts#L18853-L18871But this one doesn't, because
fontWeight
really specifies a specific data model:https://github.com/frenic/csstype/blob/1bb6cbb1f3e55220952caa52e6f37c54b4a50f54/index.d.ts#L18430
There is also another
FontWeight
that does allow strings in theAtRule
namespace: https://github.com/frenic/csstype/blob/1bb6cbb1f3e55220952caa52e6f37c54b4a50f54/index.d.ts#L19641What is the best practice for defining "important" styles in TypeScript? Should I explicitly use the
[... as any]
syntax?