Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: Argument of type 'typeof requestLog' is not assignable to parameter of type 'OctokitPlugin'. #392

Closed
1 task done
brynary opened this issue Jun 18, 2024 · 9 comments
Labels
Status: Triage This is being looked at and prioritized Type: Bug Something isn't working as documented

Comments

@brynary
Copy link

brynary commented Jun 18, 2024

What happened?

After upgrading from Octokit 3 to Octokit 4, the following code fails to typecheck:

import { Octokit } from "octokit";
import { requestLog } from "@octokit/plugin-request-log";

const MyOctokit = Octokit.plugin(requestLog);

Versions

@octokit/plugin-request-log 4.0.1
Octokit 4.0.2
Node v20.11.1

Relevant log output

> typecheck
> tsc

app/.server/services/github/github.ts:15:36 - error TS2345: Argument of type 'typeof requestLog' is not assignable to parameter of type 'OctokitPlugin'.
  Types of parameters 'octokit' and 'octokit' are incompatible.
    Type 'import("/Users/bhelmkamp/p/qltyai/qlty/remix/node_modules/octokit/node_modules/@octokit/core/dist-types/index").Octokit' is not assignable to type 'import("/Users/bhelmkamp/p/qltyai/qlty/remix/node_modules/@octokit/core/dist-types/index").Octokit'.
      The types of 'hook.before' are incompatible between these types.
        Type '<Name extends keyof Hooks>(name: Name, beforeHook: BeforeHook<GetType<Hooks[Name], "Options">>) => void' is not assignable to type '<Name extends keyof Hooks>(name: Name, beforeHook: BeforeHook<GetType<Hooks[Name], "Options", "O">>) => void'.
          Types of parameters 'beforeHook' and 'beforeHook' are incompatible.
            Types of parameters 'options' and 'options' are incompatible.
              Type 'GetType<Hooks[Name], "Options">' is not assignable to type 'GetType<Hooks[Name], "Options", "O">'.
                Type 'Hooks[Name][keyof Hooks[Name] & "Options"]' is not assignable to type 'GetType<Hooks[Name], "Options", "O">'.
                  Type 'Hooks[Name]["Options"]' is not assignable to type 'GetType<Hooks[Name], "Options", "O">'.

15 const QltyOctokit = Octokit.plugin(requestLog);

Code of Conduct

  • I agree to follow this project's Code of Conduct
@brynary brynary added Status: Triage This is being looked at and prioritized Type: Bug Something isn't working as documented labels Jun 18, 2024
Copy link

👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labeled with Status: Up for grabs. You & others like you are the reason all of this works! So thank you & happy coding! 🚀

@wolfy1339
Copy link
Member

You need to upgrade this plugin as well. v4 of this plugin and v4 of Octokit are incompatible.

@wolfy1339 wolfy1339 closed this as not planned Won't fix, can't repro, duplicate, stale Jun 18, 2024
@github-project-automation github-project-automation bot moved this from 🆕 Triage to ✅ Done in 🧰 Octokit Active Jun 18, 2024
@brynary
Copy link
Author

brynary commented Jun 19, 2024

@wolfy1339 thanks. This issue also appears on v5.3.0 of @octokit/plugin-request-log.

Here is what I get:

> tsc

app/.server/services/github/github.ts:15:36 - error TS2345: Argument of type 'typeof requestLog' is not assignable to parameter of type 'OctokitPlugin'.
  Types of parameters 'octokit' and 'octokit' are incompatible.
    Type 'import("/Users/bhelmkamp/p/qltyai/qlty/remix/node_modules/octokit/node_modules/@octokit/core/dist-types/index").Octokit' is not assignable to type 'import("/Users/bhelmkamp/p/qltyai/qlty/remix/node_modules/@octokit/core/dist-types/index").Octokit'.
      The types of 'hook.before' are incompatible between these types.
        Type '<Name extends keyof Hooks>(name: Name, beforeHook: BeforeHook<GetType<Hooks[Name], "Options">>) => void' is not assignable to type '<Name extends keyof Hooks>(name: Name, beforeHook: BeforeHook<GetType<Hooks[Name], "Options", "O">>) => void'.
          Types of parameters 'beforeHook' and 'beforeHook' are incompatible.
            Types of parameters 'options' and 'options' are incompatible.
              Type 'GetType<Hooks[Name], "Options">' is not assignable to type 'GetType<Hooks[Name], "Options", "O">'.
                Type 'Hooks[Name][keyof Hooks[Name] & "Options"]' is not assignable to type 'GetType<Hooks[Name], "Options", "O">'.
                  Type 'Hooks[Name]["Options"]' is not assignable to type 'GetType<Hooks[Name], "Options", "O">'.

15 const QltyOctokit = Octokit.plugin(requestLog);
                                      ~~~~~~~~~~


Found 1 error in app/.server/services/github/github.ts:15

Versions:

  • @octokit/plugin-request-log -- v5.3.0 (latest)
  • octokit -- 4.0.2 (latest)
  • @octokit/types -- 13.5.0 (latest)

@wolfy1339
Copy link
Member

Can you check the output of npm ls @octokit/core

@brynary
Copy link
Author

brynary commented Jun 19, 2024

Here is what I get:

npm ERR! code ELSPROBLEMS
npm ERR! invalid: @octokit/[email protected] /Users/bhelmkamp/p/qltyai/qlty/remix/node_modules/@octokit/core
npm ERR! invalid: @octokit/[email protected] /Users/bhelmkamp/p/qltyai/qlty/remix/node_modules/octokit/node_modules/@octokit/core
remix@ /Users/bhelmkamp/p/qltyai/qlty/remix
├─┬ @octokit/[email protected]
│ └── @octokit/[email protected] invalid: ">=6" from node_modules/@octokit/plugin-request-log
├─┬ @octokit/[email protected]
│ ├── @octokit/[email protected] deduped invalid: ">=6" from node_modules/@octokit/plugin-request-log
│ ├─┬ @octokit/[email protected]
│ │ └── @octokit/[email protected] deduped invalid: ">=6" from node_modules/@octokit/plugin-request-log
│ ├─┬ @octokit/[email protected]
│ │ └── @octokit/[email protected] deduped invalid: ">=6" from node_modules/@octokit/plugin-request-log
│ └─┬ @octokit/[email protected]
│   └── @octokit/[email protected] deduped invalid: ">=6" from node_modules/@octokit/plugin-request-log
└─┬ [email protected]
  ├─┬ @octokit/[email protected]
  │ ├── @octokit/[email protected]
  │ └─┬ @octokit/[email protected]
  │   └── @octokit/[email protected] deduped invalid: ">=6" from node_modules/@octokit/plugin-request-log, ">=6" from node_modules/@octokit/plugin-paginate-graphql, ">=6" from node_modules/@octokit/plugin-retry, "^6.0.0" from node_modules/@octokit/plugin-throttling, ">=6" from node_modules/@octokit/plugin-paginate-rest
  ├── @octokit/[email protected]
  ├─┬ @octokit/[email protected]
  │ └── @octokit/[email protected]
  ├─┬ @octokit/[email protected]
  │ └── @octokit/[email protected] deduped invalid: ">=6" from node_modules/@octokit/plugin-request-log, ">=6" from node_modules/@octokit/plugin-paginate-graphql
  ├─┬ @octokit/[email protected]
  │ └── @octokit/[email protected] deduped invalid: "5" from node_modules/octokit/node_modules/@octokit/plugin-paginate-rest
  ├─┬ @octokit/[email protected]
  │ └── @octokit/[email protected] deduped invalid: ">=6" from node_modules/@octokit/plugin-request-log, ">=6" from node_modules/@octokit/plugin-paginate-graphql, ">=6" from node_modules/@octokit/plugin-retry
  └─┬ @octokit/[email protected]
    └── @octokit/[email protected] deduped invalid: ">=6" from node_modules/@octokit/plugin-request-log, ">=6" from node_modules/@octokit/plugin-paginate-graphql, ">=6" from node_modules/@octokit/plugin-retry, "^6.0.0" from node_modules/@octokit/plugin-throttling```

@wolfy1339
Copy link
Member

I see the issue here. You have dupe versions of modules.

Uninstall @octokit/rest and simply use octokit, and try again

@brynary
Copy link
Author

brynary commented Jun 19, 2024

Thanks! I ran npm uninstall @octokit/rest and that indeed did resolve the Argument of type 'typeof requestLog' is not assignable to parameter of type 'OctokitPlugin'.

However, now I am getting these errors:

<path>:4:46 - error TS2307: Cannot find module '@octokit/rest' or its corresponding type declarations.

4 import type { RestEndpointMethodTypes } from '@octokit/rest';
                                               ~~~~~~~~~~~~~~~

<path>:5:38 - error TS2307: Cannot find module '@octokit/graphql' or its corresponding type declarations.

5 import { GraphqlResponseError } from "@octokit/graphql";
                                       ~~~~~~~~~~~~~~~~~~

@wolfy1339
Copy link
Member

replace @octokit/rest import with @octokit/plugin-rest-endpoint-methods

there currently is no export of GraphqlResponseError further up the chain in @octokit/core, and octokit

You could simply install it manually and it will fix your issue

@brynary
Copy link
Author

brynary commented Jun 19, 2024

That worked, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Triage This is being looked at and prioritized Type: Bug Something isn't working as documented
Projects
Archived in project
Development

No branches or pull requests

2 participants