/** * find the Item in the Tuple that has the value of V for the key K * * @todo: assert rest is type of IndexType[] */ // export type Find = Tuple extends [ // infer First, // ...infer rest // ] // ? //@ts-ignore // Equal extends true // ? First // : //@ts-ignore // Find // : never; export type Find< K extends string | number | symbol, V, Tuple extends object[] | readonly object[] > = Extract; // type Tuple = [{ id: 1; name: "Alice" }, { id: 2; name: "Bob" }, { id: 3; name: "Charlie" }]; // type Result = Find<"name", "Bob", Tuple>;