Denis 346b78aee1 first commit 2 years ago
..
dist-node 346b78aee1 first commit 2 years ago
dist-src 346b78aee1 first commit 2 years ago
dist-types 346b78aee1 first commit 2 years ago
dist-web 346b78aee1 first commit 2 years ago
LICENSE 346b78aee1 first commit 2 years ago
README.md 346b78aee1 first commit 2 years ago
package.json 346b78aee1 first commit 2 years ago

README.md

types.ts

Shared TypeScript definitions for Octokit projects

Build Status

Usage

See all exported types at https://octokit.github.io/types.ts

Examples

Get parameter and response data types for a REST API endpoint

import { Endpoints } from "@octokit/types";

type listUserReposParameters =
  Endpoints["GET /repos/{owner}/{repo}"]["parameters"];
type listUserReposResponse = Endpoints["GET /repos/{owner}/{repo}"]["response"];

async function listRepos(
  options: listUserReposParameters
): listUserReposResponse["data"] {
  // ...
}

Get response types from endpoint methods

import {
  GetResponseTypeFromEndpointMethod,
  GetResponseDataTypeFromEndpointMethod,
} from "@octokit/types";
import { Octokit } from "@octokit/rest";

const octokit = new Octokit();
type CreateLabelResponseType = GetResponseTypeFromEndpointMethod<
  typeof octokit.issues.createLabel
>;
type CreateLabelResponseDataType = GetResponseDataTypeFromEndpointMethod<
  typeof octokit.issues.createLabel
>;

Contributing

See CONTRIBUTING.md

License

MIT