期望下图get函数根据传入的url自动推导出返回值类型
//源码
type Api = {
a: () => { x: string, y: string },
b: () => number,
};
const api: Api = {
a() {
return { x: "xxx", y: "yyy" }
},
b() {
return 222
},
}
function get<K extends keyof Api>(key: K) {
return api[key]();
}
const foo = get("a")