面试题答案
一键面试// 创建泛型接口Mapper
interface Mapper<T, U> {
(arr: T[]): U[];
}
// 创建类型别名StringifyMapper
type StringifyMapper<T> = Mapper<T, string>;
// 示例实现
const numberToStringMapper: StringifyMapper<number> = (nums) => nums.map(num => num.toString());
const result = numberToStringMapper([1, 2, 3]);
console.log(result);