octokit / types.ts Goto Github PK
View Code? Open in Web Editor NEWShared TypeScript definitions for Octokit projects
Home Page: https://octokit.github.io/types.ts/
License: MIT License
Shared TypeScript definitions for Octokit projects
Home Page: https://octokit.github.io/types.ts/
License: MIT License
The way it currently works is this:
github-openapi-graphql-server
is using the de-referenced OpenAPI schema under the hood. And we don't read out the JSON Schemas for the response, instead we read out the examples and derive the types from that: https://github.com/gr2m/github-openapi-graphql-server/blob/c2cc33ce46a3ac870680cd889d106e51329b5e9f/lib/definition-to-endpoint.js#L124-L151. This has historical reasons, it's coming from a time where JSON Schemas were not available.All this results in incomplete types, especially for reponses. See for example:
The current setup also prevents us from taking advantage of the $ref
statements in GitHub's OpenAPI schema in order to greatly reduce duplications in the Type definitions for both endpoint parameters and responses.
Moving forward, I would do the following:
github-openapi-graphql-server
, add a way to query what version of the published OpenAPI spec was used, so that it can be loaded independently from the query response.scripts/update-endpoints/typescript.js
.I've yet do do a thorough research about turning JSON API / JSON Schema to TypeScript definition. I'm optimistic that there are options out there that can do the heavy lifting, but we shall see. I'm open to ideas.
I'm not yet sure how 3.
will work, exactly. I'll update this issue as soon as I have a clear picture on how it could work
🚨 Reminder! Less than one month left to migrate your repositories over to Snyk before Greenkeeper says goodbye on June 3rd! 💜 🚚💨 💚
Find out how to migrate to Snyk at greenkeeper.io
4.3.1
to 4.4.0
.This version is covered by your current version range and after updating it in your project the build failed.
@octokit/graphql is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot 🌴
This is a follow up to https://github.com/octokit/rest.js/issues/1624#issuecomment-590436498, octokit/plugin-rest-endpoint-methods.js#47
What’s missing?
Example
import { GetResponseDataType } from "@octokit/types"
import { Octokit } from "@octokit/core";
import { restEndpointMethods } from "./src";
const MyOctokit = Octokit.plugin(restEndpointMethods);
const octokit = new MyOctokit()
type CreateLabelResponseDataType = GetResponseDataType<typeof octokit.issues.createLabel>
Why?
@octokit/rest
v16 exported response types, v17 does not. There is a separate issue to export response types (#25). This issue is about exporting helper methods that allow to derive a response type from the REST API endpoint methods.
Alternatives you tried
Put the code inline, it's fairly trivial
type Unwrap<T> = T extends Promise<infer U> ? U : T;
type AnyFunction = (...args) => any
type GetResponseType<T extends AnyFunction> = Unwrap<ReturnType<T>>;
type GetResponseDataType<T extends AnyFunction> = Unwrap<ReturnType<T>>["data"];
@octokit/[email protected]
What happened?
> tsc --noEmit
node_modules/@octokit/types/src/generated/Endpoints.ts:4:1 - error TS6133: 'Url' is declared but its value is never read.
4 import { Url } from "../Url";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Found 1 error.
What did you expect to happen?
No error
What the problem might be
Generated unused import
Related to #36
master
branch failed. 🚨I recommend you give this issue a high priority, so other packages depending on you could benefit from your bug fixes and new features.
You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. I’m sure you can resolve this 💪.
Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.
Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the master
branch. You can also manually restart the failed CI job that runs semantic-release.
If you are not sure how to resolve this, here is some links that can help you:
If those don’t help, or if this issue is reporting something you think isn’t right, you can always ask the humans behind semantic-release.
An npm token must be created and set in the NPM_TOKEN
environment variable on your CI environment.
Please make sure to create an npm token and to set it in the NPM_TOKEN
environment variable on your CI environment. The token must allow to publish to the registry https://registry.npmjs.org/
.
Good luck with your project ✨
Your semantic-release bot 📦🚀
What’s missing?
This module doesn't take advantage of the TypeScript's Date
type and instead uses string
.
Why?
To be able to natively take advantage of all the methods that comes with the Date
type.
Alternatives you tried
If I wanted to use Date
methods I would have to some manual parsing.
What happened?
After upgrading to 2.11.0, my build started failing with:
> tsc --noEmit
node_modules/@octokit/types/src/RequestInterface.ts:2:1 - error TS6133: 'EndpointOptions' is declared but its value is never read.
2 import { EndpointOptions } from "./EndpointOptions";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
What did you expect to happen?
Pass type checking when imported from my project, even if my tsconfig.json
is strict.
What the problem might be
My tsconfig.json
file has the following 4 strict options turned on:
@octokit/types
is published as .ts
files, which causes my typescript to check it (using my tsconfig.json
) when imported via node_modules
.
Workaround: remove unused import and republish.
More permanent solutions (to avoid similar issues):
tsconfig.json
to repo with strict options all turned on. this way, you'd know code is compatible.Endpoints["PUT /repos/{owner}/{repo}/contents/{path}"]["response"]["data"]["content"] // can be undefined
This is a problem with the Official OpenAPI specs, see e.g.
Many response types seem to be affected, not all however. E.g. Endpoints["GET /repos/{owner}/{repo}"]["response"]["data"]
has the correct types.
Until this problem is resolved on GitHub's side, we could recursively make all response properties non-optional
The property items
in the type SearchIssuesAndPullRequestsResponseData
doesn't have it's own exported type. it would be nice to have that type defined and exported so we can use in some helpers methods.
For now I'm copy/pasting the code from 'generated/endpoints.ts` and creating the type in my code.
Maybe there is another workaround, but I couldn't find anything.
I'm trying to use the octokit rest, with my Angular app, but when compiling, the TypeScript compiler throws an error:
ERROR in node_modules/@octokit/types/src/RequestRequestOptions.ts:1:23 - error TS2307: Cannot find module 'http'.
1 import { Agent } from "http";
~~~~~~
I assume, it comes from the fact, that the RequestRequestOptions.ts file is trying to import from a node.js http module. The error comes off, when I manually remove the part of file, which causes the error.
What happened?
const workflow_run: OctokitResponse<ActionsGetWorkflowRunResponseData> = await octokit.actions.getWorkflowRun({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.runId
})
console.log(workflow_run.data.pull_requests[0].number) // => TS2571: Object is of type 'unknown'
What did you expect to happen?
It works!
What the problem might be
pull_requests: unknown[];
instead of
pull_requests: {
url: string;
id: number;
number: number;
head: {
ref: string;
sha: string;
repo: {
id: number;
url: string;
name: string;
};
};
base: {
ref: string;
sha: string;
repo: {
id: number;
url: string;
name: string;
};
};
as in ChecksCreateResponseData
, for example.
Probably will be fixed by #161, but I'm not sure.
Version
"@octokit/rest": "^18.0.14",
"@octokit/webhooks": "^7.21.0"
What happened?
Endpoints["GET /repos/{owner}/{repo}/commits"]["response"]
does not match what's actually returned in the endpoint. As an evidence, see: https://api.github.com/repos/octokit/types.ts/commits. For instance, it's missing the parents
field.
The correct type for the items looks like StatusEvent["commit"]
from https://github.com/octokit/webhooks/blob/fc8d5d284f936a5cddb952816f692fb4239edf7b/schema.d.ts#L7546.
What happened?
Docstring for OctokitResponse.data
contains broken link to https://developer.Octokit.com/v3/
types.ts/src/OctokitResponse.ts
Lines 14 to 17 in 8b02e89
What did you expect to happen?
I'm getting myself used to Octokit and Github API, please provide a correct link.
What the problem might be
N/A
This issue contains a list of Renovate updates and their statuses.
These updates are awaiting their schedule. Click on a checkbox to ignore the schedule.
These updates have all been created already. Click a checkbox below to force a retry/rebase of any.
const octokit = new Octokit(options)
const { data: pulls } = await octokit.pulls.list(options)
how can I extract types for the pulls
array?
@octokit/[email protected]
What happened?
> tsc --noEmit
node_modules/@octokit/types/src/GetResponseTypeFromEndpointMethod.ts(2,21): error TS7019: Rest parameter 'args' implicitly has an 'any[]' type.
$ npm ls @octokit/types
[email protected] /home/huan/git/osschat
└─┬ [email protected]
├─┬ @octokit/[email protected]
│ └── @octokit/[email protected]
├─┬ @octokit/[email protected]
│ ├─┬ @octokit/[email protected]
│ │ └── @octokit/[email protected] deduped
│ └── @octokit/[email protected] deduped
├─┬ @octokit/[email protected]
│ └── @octokit/[email protected] deduped
├─┬ @octokit/[email protected]
│ └── @octokit/[email protected] deduped
├─┬ @octokit/[email protected]
│ ├─┬ @octokit/[email protected]
│ │ └── @octokit/[email protected] deduped
│ └── @octokit/[email protected] deduped
└─┬ @octokit/[email protected]
├─┬ @octokit/[email protected]
│ └── @octokit/[email protected] deduped
├─┬ @octokit/[email protected]
│ └── @octokit/[email protected] deduped
├─┬ @octokit/[email protected]
│ └── @octokit/[email protected] deduped
└─┬ @octokit/[email protected]
└── @octokit/[email protected] deduped
What did you expect to happen?
No error
What the problem might be
Typing problem.
P.S. Could we add some unit tests to guard those problems? It's really annoying.
What happened?
The ActionsCreateWorkflowDispatchEndpoint type does not allow workflow_id
to be a string. This disallows specifying a filename as the workflow_id
as described in the documentation, preventing the following code from compiling:
octokit.actions.createWorkflowDispatch({
owner: ...
repo: ...
ref: ...
workflow_id: 'the-filename.yml'
})
What happened?
When upgrading from 2.7.1
to 2.8.0
starts throwing the following compile error:
> [email protected] compile /Users/bencoe/google/repo-automation-bots/packages/gcf-utils
> tsc -p .
node_modules/@octokit/request/node_modules/@octokit/types/src/GetResponseTypeFromEndpointMethod.ts:2:21 - error TS7019: Rest parameter 'args' implicitly has an 'any[]' type.
2 type AnyFunction = (...args) => any;
~~~~~~~
Found 1 error.
What did you expect to happen?
tsc
to compile the code 😆
What the problem might be
Computers 💻
What happened?
Endpoints["GET /repos/{owner}/{repo}/contributors"]["response"]["data"];
// returns "unknown",
What did you expect to happen?
Endpoints["GET /repos/{owner}/{repo}/contributors"]["response"]["data"]
should be the same as
import { paths } from "@octokit/openapi-types";
paths["/repos/{owner}/{repo}/contributors"]["get"]["responses"]["200"]["application/json"];
Similar issue as #219
This type is defined, but is not exported. It would be nice have it exported so we can use it to type some helper methods.
Right now I'm copy/pasting the type from generated/endpoints.ts
which is not the best solution.
What happened?
In Octokit v16 we were able to successfully use pkg
by zeit to create binaries of https://github.com/intuit/auto/.
After the v17 upgrade we started getting this error while trying to run pkg.
What did you expect to happen?
Pkg runs without complaining about uncompiled typescript files
What the problem might be
I'm pretty sure this is because this package publishes uncompiled typescript. I think pkg works by walking through the main
of each included module and does it's magic.
I think this package should follow the same structure as a definitely typed package.
What happened?
I have these types:
import * as github from '@actions/github'
export type Octokit = ReturnType<typeof github.getOctokit>
export type Review = GetResponseDataTypeFromEndpointMethod<Octokit['pulls']['getReview']>
The documentation (https://docs.github.com/en/free-pro-team@latest/rest/reference/pulls#get-a-review-for-a-pull-request) says there should be a author_association: string
field on this type.
The type Review
above contains all fields listed in the documentation up to commit_id
, as seen in this error:
Type '{ id: number; node_id: string; user: { login: string; id: number; node_id: string; avatar_url: string; gravatar_id: string; url: string; html_url: string; followers_url: string; following_url: string; gists_url: string; starred_url: string; subscriptions_url: string; organizations_url: string; repos_url: string; events_url: string; received_events_url: string; type: string; site_admin: boolean; }; body: string; state: string; html_url: string; pull_request_url: string; _links: { html: { href: string; }; pull_request: { href: string; }; }; submitted_at: string; commit_id: string; }' has no properties in common with type '{ author_association?: string | undefined; }'.
What did you expect to happen?
I expected this type to have a author_association: string
field.
What happened?
Endpoints["GET /repos/{owner}/{repo}/issues"]["response"]["data"];
// returns "unknown",
What did you expect to happen?
Endpoints["GET /repos/{owner}/{repo}/issues"]["response"]["data"]
should be the same as
import { paths } from "@octokit/openapi-types";
paths["/repos/{owner}/{repo}/issues"]["get"]["responses"]["200"]["application/json"];
What the problem might be
I'm investigating.
In the sample, shouldn't it use GetResponseDataTypeFromEndpointMethod
and GetResponseTypeFromEndpointMethod
instead of GetResponseType
and GetResponseDataType
?
Below is the current version:
import {
GetResponseTypeFromEndpointMethod,
GetResponseDataTypeFromEndpointMethod,
} from "@octokit/types";
import { Octokit } from "@octokit/rest";
const octokit = new Octokit();
type CreateLabelResponseType = GetResponseType<
typeof octokit.issues.createLabel
>;
type CreateLabelResponseDataType = GetResponseDataType<
typeof octokit.issues.createLabel
>;
What happened?
Endpoints["GET /repos/{owner}/{repo}/git/commits/{commit_sha}"]
has no files
field in response type.
What did you expect to happen?
It has files
field.
What the problem might be
Content in openapi-types is "application/json": components["schemas"]["git-commit"];
, I suppose it should be "application/json": components["schemas"]["commit"];
(which has files?
field).
What happened?
Incorrect type of status
in ActionsListWorkflowRunsEndpoint
.
types.ts/src/generated/Endpoints.ts
Lines 15794 to 15824 in 9185e05
status?: "completed" | "status" | "conclusion";
https://developer.github.com/v3/actions/workflow-runs/#list-workflow-runs
Returns workflow runs associated with the check run status or conclusion you specify. For example, a conclusion can be success or a status can be completed. For more information, see the status and conclusion options available in "Create a check run."
Create a check run
https://developer.github.com/v3/checks/runs/#create-a-check-run
Name | Type | Description |
---|---|---|
status | string | The current status. Can be one of queued, in_progress, or completed. Default: queued |
conclusion | string | Required if you provide completed_at or a status of completed. The final conclusion of the check. Can be one of success, failure, neutral, cancelled, skipped, timed_out, or action_required. When the conclusion is action_required, additional details should be provided on the site specified by details_url.Note: Providing conclusion will automatically set the status parameter to completed. Only GitHub can change a check run conclusion to stale. |
What did you expect to happen?
I think the status below should be included.
What the problem might be
I couldn't specify in_progress
status.
would love to do this for my company's backend. Was it auto-generated?
What’s missing?
Typings for the /user/repos
endpoint response.
Why?
It's currently missing and seems fitting for this project.
Alternatives you tried
Typing it myself, not that hard, but a little inconvenient, as most of my GH types depend on this package.
When this package gets imported on a project running with --isolatedModules
(e.g. all create-react-app
s), the index file's export syntax is causing a TS1205, No re-exporting names" error. I reproduced the issue in a plain create-react-app here ( https://github.com/john-osullivan/octokit-type-import-repro ) and will file a PR in a moment.
What happened?
Endpoints["GET /repos/{owner}/{repo}/tarball/{ref}"]["response"] // type: never
What did you expect to happen?
Endpoints["GET /repos/{owner}/{repo}/tarball/{ref}"]["response"] // type: OctokitResponse<unknown>
What the problem might be
We only set response types for success response types which currently are:
type SuccessStatusesMap = {
"200": 200;
"201": 201;
"204": 204;
};
We will need to update this code
type FirstSuccessResponse<
R,
S extends keyof R = keyof R
> = S extends keyof SuccessStatusesMap
? R[S] extends never
? Omit<OctokitResponse<unknown, SuccessStatusesMap[S]>, "data">
: OctokitResponse<DataType<R[S]>, SuccessStatusesMap[S]>
: never;
What’s missing?
Missing return types for listEventsForAuthenticatedUser
. Everything is any
.
Why?
Probably because there are many different events, and it might be annoying to type them all.
Alternatives you tried
Looking for sources of these events. Found that maybe webhook repo has types that can be re-used, but not directly.
What happened?
repos.getContents
has type ReposGetContentResponseData
.
What did you expect to happen?
In case we use it for directory repos.getContents
has type ReposGetContentResponseData[]
.
See docs: https://developer.github.com//v3/repos/contents/#response-if-content-is-a-directory
What the problem might be
N/A
What happened?
Incorrect type for template_repository
in ReposGetResponseData
endpoint.
types.ts/src/generated/Endpoints.ts
Line 14100 in 9185e05
It is currently string
but should be a repository object or null.
The sample response for /repos/{owner}/{repo} shows template_repository
as null. When a repository was created from a template, this field should hold the repository object for that template.
What did you expect to happen?
Instead of string
, type should be a repository object similar to owner
and to the template_repository
returned by /repos/{template_owner}/{template_repo}/generate
What happened?
It returns components["schemas"]["git-tree"]
which has tree
field defined as
tree: {
path?: string;
mode?: string;
type?: string;
sha?: string;
size?: number;
url?: string;
}[];
while operations["git/create-tree"]
has request params defined as
tree: {
path?: string;
mode?: "100644" | "100755" | "040000" | "160000" | "120000";
type?: "blob" | "tree" | "commit";
sha?: string | null;
content?: string;
}[];
so response type is not compatible with request one.
What did you expect to happen?
mode
& type
should be compatible.
What the problem might be
mode & type on components["schemas"]["git-tree"]
should be more strict.
What’s missing?
Octokit is currently not compatible with Deno. One promble is that https://cdn.pika.dev/@octokit/types returns an error
Why?
It's not build as module. Add a build setup using @pika/pack
like the other Ocotkit packages.
Alternatives you tried
I couldn't think of any alternative
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
How to recreate the issue
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['POST /repos/{owner}/{repo}/check-runs']['parameters']
const test: listUserReposParameters = {
name: '',
head_sha: '',
owner: '',
repo: '',
status: 'completed'
}
tsc test.ts
Gives the following error and the type that it constructed seems very broken:
test.ts:8:5 - error TS2322: Type 'string' is not assignable to type 'never'.
8 status: 'completed'
~~~~~~
node_modules/@octokit/openapi-types/dist-types/generated/types.d.ts:19740:21
19740 status?: "completed";
~~~~~~
The expected type comes from property 'status' which is declared here on type '{ owner: string; repo: string; } & 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
What happened?
Endpoints["PUT /user/starred/{owner}/{repo}"]["response"] // never
What did you expect to happen?
Endpoints["PUT /user/starred/{owner}/{repo}"]["response"] // { status, url, headers, data: never }
What the problem might be
Must have been a recent change, the problem surfaced via octokit/request.js#352
I'm trying to read the contents of a directory and the return type of octokit.repos.getContent
is a type union that has many possible values.
I'm trying to narrow the return value of getContent
to only one of those options, it looks like this:
"content-directory": {
type: string;
size: number;
name: string;
path: string;
content?: string;
sha: string;
url: string;
git_url: string | null;
html_url: string | null;
download_url: string | null;
_links: {
git: string | null;
html: string | null;
self: string;
};
}[]
I created a type
out of it:
type DirectoryItems = components["schemas"]["content-directory"];
and now I'm trying to use it in a type guard:
const { data } = await octokit.repos.getContent({
// ...
});
if(data instanceof DirectoryItems) {
}
but it says
'DirectoryItems' only refers to a type, but is being used as a value here.
How can I narrow the type of data
to make sure that it is indeed an array of "content-directory" items? Is there an example somewhere on how to use TypeScript with Octokit?
master
branch failed. 🚨I recommend you give this issue a high priority, so other packages depending on you could benefit from your bug fixes and new features.
You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. I’m sure you can resolve this 💪.
Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.
Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the master
branch. You can also manually restart the failed CI job that runs semantic-release.
If you are not sure how to resolve this, here is some links that can help you:
If those don’t help, or if this issue is reporting something you think isn’t right, you can always ask the humans behind semantic-release.
semantic-release cannot push the version tag to the branch master
on the remote Git repository with URL https://x-access-token:[secure]@github.com/octokit/types.ts
.
This can be caused by:
Good luck with your project ✨
Your semantic-release bot 📦🚀
What happened?
Example in src/generated/Endpoints.ts
export interface Endpoints {
/**
* @see https://developer.github.com/v3/apps/#delete-an-installation
*/
"DELETE /app/installations/:installation_id": {
parameters: AppsDeleteInstallationEndpoint;
request: AppsDeleteInstallationRequestOptions;
response: OctokitResponse<any>;
};
// ...
}
What did you expect to happen?
response: OctokitResponse<any>
suggests that there is a response body, but it could be of anytime. However, we know that there is no body at all.
What the problem might be
The way 204 responses are handled in generating src/generated/Endpoints.ts
?
What happened?
Property 'content' does not exist on type 'ReposGetContentsResponseData'.
Property 'content' does not exist on type 'ReposGetContentsResponseDataItem[]'.
after, I've migrated my code to "@octokit/rest": "^17.6.0"
. The issue is visible at
https://github.com/fogfish/code-build-bot/blob/github-error/apps/webhook/lib/codebuild.ts#L39
The type definition of your library is seemed to be correct but tsc
cannot see it
type ReposGetContentsResponseData =
| {
type: string;
encoding?: string;
size: number;
name: string;
path: string;
content?: string;
sha: string;
url: string;
git_url: string;
html_url: string;
download_url: string | null;
_links: ReposGetContentsResponseDataLinks;
target?: string;
submodule_git_url?: string;
}
| Array<ReposGetContentsResponseDataItem>;
What did you expect to happen?
I would expect that Property 'content' exists on type
It looks like because POST /repos/{owner}/{repo}/forks
only has a 202
successful response, and 202
isn't part of the SuccessStatuses
, it gets set to never.
See here:
What happened?
In octokit v16 repos.uploadReleaseAsset
accepted string | object
for the data
prop.
In octokit v17 it only accepts a string
. Running the code with as any
though providing a buffer is still valid.
https://github.com/intuit/auto/blob/master/plugins/upload-assets/src/index.ts#L70
What did you expect to happen?
This endpoint should still accept a Buffer
.
What the problem might be
I tried finding the place to contribute it but was unable since it is generated from somewhere else
I would like to import type ActivityListReposStarredByAuthenticatedUserResponseData
which is one of the response types for
await octokit.activity.listReposStarredByAuthenticatedUser()
rather than use any[].
response type is OctokitResponse<ActivityListReposStarredByAuthenticatedUserResponseData | ActivityListReposStarredByAuthenticatedUserResponse200Data>
What happened?
Incorrect type for SearchIssuesAndPullRequestsResponseData
(associated with RestEndpointMethodTypes["search"]["issuesAndPullRequests"]["response"]["data"]["items"]
)
What did you expect to happen?
Given the following minimal reproduction:
const { Octokit } = require("@octokit/rest");
async function run() {
const octokit = new Octokit();
try {
const searches = await octokit.search.issuesAndPullRequests({
q: "repo:test-organization-kkjeer/cliff-test+is:open"
});
console.dir(searches);
debugger;
} catch (e) {
debugger;
console.dir(e);
}
}
run();
The response includes "assignees" field while the type (see below) does not.
export interface SearchIssuesAndPullRequestsResponseData {
total_count: number;
incomplete_results: boolean;
items: {
url: string;
repository_url: string;
labels_url: string;
comments_url: string;
events_url: string;
html_url: string;
id: number;
node_id: string;
number: number;
title: string;
user: {
login: string;
id: number;
node_id: string;
avatar_url: string;
gravatar_id: string;
url: string;
html_url: string;
followers_url: string;
following_url: string;
gists_url: string;
starred_url: string;
subscriptions_url: string;
organizations_url: string;
repos_url: string;
events_url: string;
received_events_url: string;
type: string;
};
labels: {
id: number;
node_id: string;
url: string;
name: string;
color: string;
}[];
state: string;
assignee: string;
milestone: string;
comments: number;
created_at: string;
updated_at: string;
closed_at: string;
pull_request: {
html_url: string;
diff_url: string;
patch_url: string;
};
body: string;
score: number;
}[];
}
I'm new to typescript so I apologize if I'm missing something, and there seem to be no design-overview documentation.
I don't understand why I can't just rely on the return type of e.g. ocotokit.pulls.create
being automatically picked up by my editor than me having to refine it from any
to type X = Endpoints["POST /repos/{owner}/{repo}/pulls"]["response"]
or using GetResponseTypeFromEndpointMethod
Normally I wouldn't even have to worry about the types, and as long as I specify the right keys in the object literal that I use as the argument and I use the right properties on the returned object, I'm good to go.
I also have a less important second question: is there no parameter/argument type equivalent to GetResponseTypeFromEndpointMethod
?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.