github-script icon indicating copy to clipboard operation
github-script copied to clipboard

Typing issue with octokit on global github object

Open DavidWells opened this issue 6 months ago • 1 comments

Its nice that octokit gets automagically added to the github object but it appears the types don't recognize it.

Property 'rest' does not exist on type 'typeof import("/node_modules/@actions/github/lib/github")'.ts(2339)

Any ideas on how we can fix?

Image

Thanks!

DavidWells avatar Jun 24 '25 21:06 DavidWells

Looks like this works

/** 
 * @typedef {ReturnType<import('@actions/github').getOctokit>} Octokit
 */

/**
 * @typedef {import('@actions/github/lib/context').Context} Context 
 */

/**
 * @typedef {Object} ExtendedGitHub
 * @property {Context} context
 */

/** @type {ExtendedGitHub & Partial<Octokit>} */
const github = require('@actions/github')
const core = require('@actions/core')

But was a pain to setup 😅

Would be nice if the core lib has the corrected types with the injected octokit kits already in place

DavidWells avatar Jun 24 '25 22:06 DavidWells