我的目标是将泛型函数的参数类型
提取到一个新的泛型类型中,以便稍后使用:
// we have a given function like this:
function genericFunction<T>(a: T) {
return a;
}
type genericParamsType = Parameters<typeof genericFunction>; // this will resolve to a type of [unknown]
// I would like to achieve something like this:
// type genericParamsType<PassDownType> = Parameters<typeof genericFunction<PassDownType>>;
// but that is a syntax error
// if it would work, I could the following:
// const newparams: genericParamsType<string> = ["hello"] // correct
// const newparams2: genericParamsType<number> = ["hello"] // error because its not a string