我希望声明一个通用函数,该函数可以解析为值类型,而不是所传递参数的完整类型集。
getProp<V>(value :V) : V
{ return value; }
// This has return type <string>, but I want return type <"test">
getProp("test");
// This has correct return type, but require explicit generic parameter.
// Also, I have several generic parameters, and then I have to state them all...
getProp<"test">("test");