I have the following reasonably straight-forward code:
export async function getAllRepos({
token,
}: {
token: string;
}): Promise<ReposListForOrgResponseData> {
const octokit = buildOctokit(token);
const repos = await octokit.paginate(octokit.repos.listForOrg, {
org: OWNER,
});
return repos;
}
Typescript does not like this and gives me the error:
src/lib/github.ts:130:3 - error TS2322: Type '{ id: number; node_id: string; name: string; full_name: string; owner: { name?: string | null | undefined; email?: string | null | undefined; login: string; id: number; node_id: string; avatar_url: string; ... 14 more ...; starred_at?: string | undefined; }; ... 79 more ...; allow_forking?: boolean | undefined; }[]' is not assignable to type 'ReposListForOrgResponseData'.
Type '{ id: number; node_id: string; name: string; full_name: string; owner: { name?: string | null | undefined; email?: string | null | undefined; login: string; id: number; node_id: string; avatar_url: string; ... 14 more ...; starred_at?: string | undefined; }; ... 79 more ...; allow_forking?: boolean | undefined; }' is not assignable to type '{ id: number; node_id: string; name: string; full_name: string; owner: { login: string; id: number; node_id: string; avatar_url: string; gravatar_id: string; url: string; html_url: string; followers_url: string; ... 9 more ...; site_admin: boolean; }; ... 73 more ...; license: { ...; }; }'.
The types of 'owner.gravatar_id' are incompatible between these types.
Type 'string | null' is not assignable to type 'string'.
Type 'null' is not assignable to type 'string'.
130 return repos;
~~~~~~
I'm not sure why the types don't match up but it's impossible to figure this out following the definitions or looking at the octokit website. @octokit/rest
and @octokit/types
don't seem to have anything to do with each other.
Octokit/rest is at 18.12.0 and the types are at 5.5.0.