TS2537
Type 'Promise<OctokitResponse<{ name?: string | null | undefined; email?: string | null | undefined; login: string; id: number; node_id: string; avatar_url: string; gravatar_id: string | null; url: string; html_url: string; ... 11 more ...; starred_at?: string | undefined; }[], 200>>' has no matching index signature for type 'number'.
Broken Code ❌
type UserProps = ReturnType<typeof getMaintainers>[number];
export async function getUser(user: Pick<UserProps, 'url'>) {}This error occurs because ReturnType<typeof getMaintainers> is a Promise, not an array, and indexing it with [number] is not valid.
Fixed Code ✔️
To fix this, you need to first resolve the Promise to access the array and then apply the [number] index signature:
type UserProps = Awaited<ReturnType<typeof getMaintainers>>[number];
export async function getUser(user: Pick<UserProps, 'url'>) {}Here, the Awaited utility type is used to extract the resolved type of the Promise, which allows us to safely index the result as an array.
