octokit.js: TypeScript definition missing methods

In 15.10.0 after merge of #948 the TypeScript definitions are generated using routes-for-api-docs.json instead of routes.json. But the file is not complete and is missing multiple methods including eg. repos.getById or the whole enterprise section: https://github.com/octokit/rest.js/pull/948/files#diff-70e044778205a59a14c885cb6804b03eR14

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 1
  • Comments: 17 (7 by maintainers)

Most upvoted comments

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

I suppose it’s automatically generated based on the official doc.

Basically yes, from what I can tell. @octokit/routes contains a data structure for routes that is generated based on the API, then @octokit/rest has scripts/generate-routes.js which takes that data, massages it and outputs both lib/routes.json and script/routes-for-api-docs.json.

This addLabels/replaceAllLabels issue seems to be a problem with all properties that use a mapTo workaround for cases when the official documentation does not specify data. I found some extra context in this comment and its replies: https://github.com/octokit/rest.js/issues/790#issuecomment-388844621

There are 16 instances where “mapTo” is used in routes.json. I’m not sure if the best solution here is work out a mechanism to expose those things within routes-for-api-docs.json or to see if @gr2m can pull faces at the GH apis/docs teams to make them update the things he requested in May.

I believe this is two separate issues:

The removal of repos.getById was an explicit decision to remove undocumented API endpoints in 66c627fa. This occured several months ago, prior to the TypeScript definition updates in #948. It also affects 15.9.4 - the last version before 15.10.0 which included the the return type updates.

The removal of the enterprise section and IssuesReplaceAllLabelsParams losing its labels attribute however IS related to the typescript definition updates.

You can recreate these issues by adding the following to the bottom of test/typescript-validate.ts and then running rm -rf index.d.ts && npm run validate:ts:

  await octokit.issues.addLabels({
    owner: 'octokit',
    repo: 'rest.js',
    number: 10,
    labels: ['label'],
  });

  await octokit.enterprise.stats({
    type: 'issues',
  });

/cc @gimenete