Describe the bug
I am trying to declare a variable of the type "octokit" but I can麓t get it working.
I have seen some code and also https://github.com/actions/toolkit/issues/365 which shows I could do like:
import { GitHub } from "@actions/github"
and then just declare my variable as: const octokit: GitHub
But this doesn麓t work. Typescript complains the variable is not exported.
Module '"../node_modules/@actions/github/lib/github"' declares 'GitHub' locally, but it is not exported
To Reproduce
import { GitHub } from "@actions/github"
const octokit = new GitHub("mytoken");
Expected behavior
The GitHub type should be exported, so I can specify the type of my variables
Additional context
Using version 4.0.0. It works with version 2.2.0. I guess the interface changed. Still I have to be able to declare my variable with correct type.
I believe this is due to an api change. I worked around this by doing the following (which is now the recommended way in the README):
import { getOctokit } from "@actions/github";
const octokit = getOctokit("mytoken");
in other modules that might need to know the type of octokit, I do:
import type { GitHub } from "@actions/github/lib/utils";
export async function createCheck(
octokit: InstanceType<typeof GitHub>
) {
// ...
}
Thanks. I saw the README, but I wanted to inject the Ocotkit into my service. I was missing how I could declare the type like this InstanceType<typeof GitHub>. Thanks.