说我有
type TypeMsAnimationDuration =
| 75
| 100
| 150
| 200
| 250
| 300
| 350
| 500;
const cssInJs = css`transition: all ${999}ms;`
如何确保值“ 999”是TypeMsAnimationDuration的值?
答案 0 :(得分:0)
如果不将其放在变量中或创建需要调用以验证值的辅助函数,则无法执行此操作:
type TypeMsAnimationDuration =
| 75
| 100
| 150
| 200
| 250
| 300
| 350
| 500;
function animDuration(ms: TypeMsAnimationDuration) {
return ms;
}
const cssInJs = css`transition: all ${animDuration(999)}ms;` // Error
const cssInJs = css`transition: all ${animDuration(250)}ms;` // Ok