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

Compile error regarding rest endpoint method types #488

Closed
karmann-dm opened this issue Jun 21, 2022 · 12 comments
Closed

Compile error regarding rest endpoint method types #488

karmann-dm opened this issue Jun 21, 2022 · 12 comments
Labels
Type: Bug Something isn't working as documented typescript Relevant to TypeScript users only

Comments

@karmann-dm
Copy link

I am trying to compile the GH integration code with the following dependencies:

"dependencies": {
    "@octokit/types": "^6.37.0",
    "@octokit/rest": "^18.12.0",
    "@octokit/plugin-paginate-rest": "^2.19.0",
    "@octokit/plugin-rest-endpoint-methods": "^5.15.0"
  },
  "devDependencies": {
    "eslint": "^7.8.1",
    "typescript": "^3.9.7",
    "@zeit/ncc": "^0.22.3"
  }

NodeJS version 14.19.1, npm version 6.14.16

What happened?
An error is thrown on the compile stage

> tsc

node_modules/@octokit/rest/node_modules/@octokit/plugin-rest-endpoint-methods/dist-types/generated/parameters-and-response-types.d.ts:437:60 - error TS2339: Property 'POST /content_references/{content_reference_id}/attachments' does not exist on type 'Endpoints'.

437             parameters: RequestParameters & Omit<Endpoints["POST /content_references/{content_reference_id}/attachments"]["parameters"], "baseUrl" | "headers" | "mediaType">;
                                                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@octokit/rest/node_modules/@octokit/plugin-rest-endpoint-methods/dist-types/generated/parameters-and-response-types.d.ts:438:33 - error TS2339: Property 'POST /content_references/{content_reference_id}/attachments' does not exist on type 'Endpoints'.

438             response: Endpoints["POST /content_references/{content_reference_id}/attachments"]["response"];
                                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@octokit/rest/node_modules/@octokit/plugin-rest-endpoint-methods/dist-types/generated/parameters-and-response-types.d.ts:441:60 - error TS2339: Property 'POST /repos/{owner}/{repo}/content_references/{content_reference_id}/attachments' does not exist on type 'Endpoints'.

441             parameters: RequestParameters & Omit<Endpoints["POST /repos/{owner}/{repo}/content_references/{content_reference_id}/attachments"]["parameters"], "baseUrl" | "headers" | "mediaType">;
                                                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@octokit/rest/node_modules/@octokit/plugin-rest-endpoint-methods/dist-types/generated/parameters-and-response-types.d.ts:442:33 - error TS2339: Property 'POST /repos/{owner}/{repo}/content_references/{content_reference_id}/attachments' does not exist on type 'Endpoints'.

442             response: Endpoints["POST /repos/{owner}/{repo}/content_references/{content_reference_id}/attachments"]["response"];
                                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Found 4 errors.

What did you expect to happen?

Compilation without errors.

What the problem might be

I suspect that it is somehow related to this issue, but I have version that were issued much lated than the ones described in the fix of this issue.

@karmann-dm karmann-dm added the Type: Bug Something isn't working as documented label Jun 21, 2022
@wolfy1339 wolfy1339 added the typescript Relevant to TypeScript users only label Jun 21, 2022
@wolfy1339
Copy link
Member

wolfy1339 commented Jun 21, 2022

Can you please share your tsconfig.json as well? Also, can you share a snippet of code that reproduces the problem?

@timrogers
Copy link
Contributor

Could you also check what version of @octokit/plugin-rest-endpoint-methods is in node_modules/@octokit/rest/node_modules/@octokit/plugin-rest-endpoint-methods by checking node_modules/@octokit/rest/node_modules/@octokit/plugin-rest-endpoint-methods/package.json? Judging by the error, I think it isn't the current version (v5.15.0).

@karmann-dm
Copy link
Author

@timrogers

Could you also check what version of @octokit/plugin-rest-endpoint-methods

Yes, seems like, do you have an idea how to fix it?

$ cat node_modules/@octokit/rest/node_modules/@octokit/plugin-rest-endpoint-methods/package.json | grep \"version\":
  "version": "5.13.0"

@timrogers
Copy link
Contributor

@timrogers

Could you also check what version of @octokit/plugin-rest-endpoint-methods

Yes, seems like, do you have an idea how to fix it?

$ cat node_modules/@octokit/rest/node_modules/@octokit/plugin-rest-endpoint-methods/package.json | grep \"version\":
  "version": "5.13.0"

Interesting! I wonder if we need to update the dependency defined on @octokit/rest. The links between all of these packages are pretty tricky to understand.

@gr2m Can you point us in the right direction?

@karmann-dm
Copy link
Author

@wolfy1339

Can you please share your tsconfig.json as well? Also, can you share a snippet of code that reproduces the problem?

tsconfig.json

{
  "compilerOptions": {
    "target": "es2019",
    "module": "commonjs",
    "outDir": "./lib",
    "rootDir": "./src",
    "strict": true,
    "noImplicitAny": true,
    "esModuleInterop": true,
    "strictPropertyInitialization": false
  },
  "exclude": ["node_modules"]
}

About the snippet - there is nothing special, basically if I import

import { RestEndpointMethodTypes } from "@octokit/plugin-rest-endpoint-methods"

problem starts to appear.

In my case I just do this

export type CreatePullRequestParameters =
  RestEndpointMethodTypes["pulls"]["create"]["parameters"]

@gr2m
Copy link
Contributor

gr2m commented Jun 21, 2022

The POST /repos/{owner}/{repo}/content_references/{content_reference_id}/attachments endpoint has been removed, it no longer exists. This is an edge case, it happens very rarely. You likely have the latest version of @octokit/openapi-types, but not the latest version of @octokit/plugin-rest-endpoint-methods.

Try to delete the node_modules folder and whatever lock file you use (usually package-lock.json). Then run npm install again, that should fix it

@a-tarasyuk
Copy link

TypeScript uses the latest version of @octokit/rest., today I noticed that the CI build failed due to the following errors

Error: node_modules/@octokit/types/dist-types/generated/Endpoints.d.ts(903,48): error TS2344: Type '"/orgs/{org_id}/codespaces"' does not satisfy the constraint 'keyof paths'.
Error: node_modules/@octokit/types/dist-types/generated/Endpoints.d.ts(1612,70): error TS2344: Type '"/repos/{owner}/{repo}/community/code_of_conduct"' does not satisfy the constraint 'keyof paths'.
Error: node_modules/@octokit/plugin-paginate-rest/dist-types/generated/paginating-endpoints.d.ts(226,74): error TS2339: Property 'data' does not exist on type 'unknown'.

I'm not sure if this is related to this issue or should I create a new one?

@timrogers
Copy link
Contributor

@a-tarasyuk Can you try updating all of the Octokit packages? I think you'll find this is fixed now.

@a-tarasyuk
Copy link

It uses the latest version. Has it been updated recently?

"@octokit/rest": "latest",

@timrogers
Copy link
Contributor

Yep! I have just released updates to several Octokit packages. Can you tell me the versions of all of your Octokit-related packages in your lock file?

@a-tarasyuk
Copy link

@timrogers Thanks. The latest version seems to work fine.

@timrogers
Copy link
Contributor

Great - sorry about that! The packages have complicated dependencies and some of them still needed updates.

@gr2m gr2m closed this as completed Jul 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Something isn't working as documented typescript Relevant to TypeScript users only
Projects
None yet
Development

No branches or pull requests

5 participants