Here are the functions I am working with:
const transitionGroup = (
propertyName: string,
durationMultiple = 1,
timingFunction = 'linear',
delayMultiple = 0,
): string => {
// ...more logic here
return [propertyName, duration, timingFunction, delay].join(' ');
};
const transition = (
...properties: (string | [string, number?, string?, number?])[]
): string => {
const values = properties.map(property => {
const propertyGroup = typeof property === 'string' ? [property] : property;
return transitionGroup(...propertyGroup);
});
return `transition: ${values.join(', ')};`;
};
I encountered a type error specifically on this line:
return transitionGroup(...propertyGroup);
const propertyGroup: [string, (number | undefined)?, (string | undefined)?, (number | undefined)?] | string[]
Expected 1-4 arguments, but got 0 or more.ts(2556)
index.ts(6, 3): An argument for 'propertyName' was not provided.
I am trying to figure out what's missing in my code, but it seems that propertyGroup
always results in an array where the first value is a string. This should fulfill the requirement of providing a string value for the propertyName
parameter when it is spread into the transitionGroup
. Any suggestions?