How can I define a type for a css color in TypeScript?

type RGB = `rgb(${number}, ${number}, ${number})`;
type RGBA = `rgba(${number}, ${number}, ${number}, ${number})`;
type HEX = `#${string}`;

type Color = RGB | RGBA | HEX;

`${…}` notation is available on new (^4.1) ts versions.

https://www.typescriptlang.org/docs/handbook/2/template-literal-types.html

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)