Complete worked example
typescript
function labels(values: readonly string[], transform: (value: string) => string): string[] {
return values.map(transform);
}
const names = labels(["qa", "pm"], value => value.toUpperCase());- Reasoning
- Context supplies the callback parameter type; the returned array is newly allocated.