type Test<T extends string, V extends unknown> = {
[Key: T]: V;
}
type Test<T extends string, V extends unknown> = {
[Key in T]: V;
}
From the code above, T extends string,why T can not be used as Key's type and it output an error An index signature parameter type cannot be a literal type or generic type. Consider using a mapped object type instead.
But if replace Key: T
with Key in T
, it works.