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

Endpoints['PATCH /repos/{owner}/{repo}/check-runs/{check_run_id}']['parameters'] gives broken types in version newer than v6.3.2 #283

Closed
tlbdk opened this issue Mar 8, 2021 · 8 comments
Labels
Status: Blocked Blocked by GitHub's API or other external factors Type: Bug Something isn't working as documented, or is being fixed typescript Relevant to TypeScript users only

Comments

@tlbdk
Copy link

tlbdk commented Mar 8, 2021

How to recreate the issue

Exactly same issues as: #274

Create a test project:

npm init -y && npm install typescript @octokit/types

Generates this package.json file:

{
  "name": "test-repo",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@octokit/types": "^6.11.0",
    "typescript": "^4.2.2"
  }
}

Create test.ts:

import { Endpoints } from '@octokit/types'

type listUserReposParameters = Endpoints['PATCH /repos/{owner}/{repo}/check-runs/{check_run_id}']['parameters']

const test: listUserReposParameters = {
    name: '',
    head_sha: '',
    owner: '',
    repo: '',
    status: 'completed'
}
./node_modules/.bin/tsc test.ts

Gives the following error and the type that it constructed seems very broken:

test.ts:10:5 - error TS2322: Type 'string' is not assignable to type 'never'.

10     status: 'completed'
       ~~~~~~

  node_modules/@octokit/openapi-types/dist-types/generated/types.d.ts:19876:21
    19876                     status?: "completed";
                              ~~~~~~
    The expected type comes from property 'status' which is declared here on type '{ owner: string; repo: string; check_run_id: number; } & Partial<{ status?: "completed"; } & { [key: string]: any; }> & Partial<{ status?: "queued" | "in_progress"; } & { [key: string]: any; }> & { ...; }'


Found 1 error.

Trying with v6.3.2 works:

npm install @octokit/[email protected]
tsc test.ts

Diff is here:
v6.3.2...v6.4.0

@tlbdk tlbdk added the Type: Bug Something isn't working as documented, or is being fixed label Mar 8, 2021
@gr2m
Copy link
Contributor

gr2m commented Mar 8, 2021

hmm sorry for that, I thought we had the problem with the status parameter resolved. By the way you could have reopened #274 in this case, but either works

@gr2m gr2m self-assigned this Mar 8, 2021
@gr2m
Copy link
Contributor

gr2m commented Mar 8, 2021

By the way you could have reopened #274 in this case, but either works

ah sorry I see now it's a different path, I got it

@gr2m
Copy link
Contributor

gr2m commented Mar 9, 2021

reported the problem here: github/rest-api-description#228. Once resolved in https://github.com/github/rest-api-description, @octokit/types will get updated shortly after by our bots

@gr2m gr2m removed their assignment Mar 9, 2021
@gr2m gr2m added the Status: Blocked Blocked by GitHub's API or other external factors label Apr 22, 2021
@gr2m
Copy link
Contributor

gr2m commented Apr 22, 2021

The original problem was resolved at github/rest-api-description#228, but now status type is set to undefined. It's now likely a problem in how we transpile the OpenAPI spec to TypeScript, I'll have a look

@gr2m gr2m self-assigned this Apr 22, 2021
@gr2m gr2m added the typescript Relevant to TypeScript users only label Apr 22, 2021
@jamacku
Copy link

jamacku commented Jun 6, 2023

I'm also hitting this issue with "@octokit/core": "^4.2.1" and "@octokit/types": "^9.2.3".

import { Octokit } from '@octokit/core';
import { Endpoints } from '@octokit/types';

export async function updateStatusCheck(
  octokit: Octokit,
  checkID: number,
  status: Endpoints['POST /repos/{owner}/{repo}/check-runs']['parameters']['status'],
  conclusion: Endpoints['POST /repos/{owner}/{repo}/check-runs']['parameters']['conclusion'],
  message: string
) {
  await octokit.request(
    'PATCH /repos/{owner}/{repo}/check-runs/{check_run_id}',
    {
      check_run_id: checkID,
      status,
      completed_at: new Date().toISOString(),
      conclusion,
      output: {
        title: 'Validation Status',
        summary: message,
      },
    }
  );
}

Both status and conclusion has mismatched types.

Type '"queued" | "in_progress" | "completed" | undefined' is not assignable to type 'undefined'. Type '"queued"' is not assignable to type 'undefined'.ts(2322)

Type 'unknown' is not assignable to type '"action_required" | "cancelled" | "failure" | "neutral" | "success" | "skipped" | "stale" | "timed_out" | undefined'.ts(2322)

@gr2m gr2m removed their assignment Jun 8, 2023
@wolfy1339
Copy link
Member

@tlbdk @jamacku Can you reproduce this issue with the latest version?

@jamacku
Copy link

jamacku commented Sep 25, 2023

@wolfy1339 The status type is fixed, but the conclusion is still emitting the same error message.

Type 'unknown' is not assignable to type '"action_required" | "cancelled" | "failure" | "neutral" | "success" | "skipped" | "stale" | "timed_out" | undefined'.

@jamacku
Copy link

jamacku commented Oct 24, 2023

@wolfy1339, I can't reproduce this issue with the latest version: "@octokit/types": "^12.0.0". It's fixed for me. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Blocked Blocked by GitHub's API or other external factors Type: Bug Something isn't working as documented, or is being fixed typescript Relevant to TypeScript users only
Projects
None yet
Development

No branches or pull requests

4 participants