When it comes to object properties, the key point to remember is that they are not ordered. On the other hand, function arguments are ordered, making it impossible to directly convert an object with multiple properties into a list of ordered arguments.
Therefore, if you require a function signature with 4 distinct arguments, sticking to what you currently have is your most viable option.
If you find yourself frequently needing to use the same order of parameters, consider creating a tuple type for your functions:
type ColorParameters = [r: number, g: number, b: number, a: number]
function setColor(...[r, g, b, a]: ColorParameters) {
//...
}
setColor(64, 192, 255, 0.1)
View playground
If you are open to modifying your function to accept an object, you can implement something like this:
interface Color {
r:number;
g:number;
b:number;
a:number;
}
function setColor({ r, g, b, a }: Color) {
//...
}
setColor({ r: 64, g: 192, b: 255, a: 0.1 })
View playground