Skip to content

[BUG]: Octokit is just an alias for any, when using TypeScript and CommonJS. #2865

@codiophile

Description

@codiophile

What happened?

I use Octokit in a NestJS project, meaning that I have no choice but to use CommonJS. Now that you can simply require ES modules, the experience has improved, but it's still not great. My biggest issue right now is that

import { Octokit, App } from "octokit";

just makes Octokit an alias for any. I do get a full Octokit instance from the App that is fully usable, but I get no auto-completion and I can't assign it to anything without the linter complaining (no-unsafe-assignment).

I found one workaround that makes the linter happy, but makes the compiler block me from using most of its APIs:

import { Octokit } from "@octokit/core";

octokit.rest does not exist in core, so the compiler will not let you use any of the convenience APIs, which seems like a higher cost than disabling the linting rule.

I haven't tried it in ESM and I'm assuming that it has to do with CommonJS compatibility, but I don't know.

Versions

Octokit v5.0.3, Node v22.17.0, TypeScript v5.7.3, NestJS v11.0.1

Relevant log output

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: SupportAny questions, information, or general needs around the SDK or GitHub APIs

    Type

    No type

    Projects

    Status

    ✅ Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions