tree: 80722ee54fff1c7bd82f81ff9346f783554dce17 [path history] [tgz]
  1. dist-node/
  2. dist-src/
  3. dist-types/
  4. dist-web/
  5. LICENSE
  6. package.json
  7. README.md
setup-maven/node_modules/@octokit/rest/node_modules/@octokit/types/README.md

types.ts

Shared TypeScript definitions for Octokit projects

@latest Build Status Greenkeeper

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 "./src";

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