Skip to content

TypeScript performance #40

@gr2m

Description

@gr2m

I'm happy with the TypeScript IntelliSense we can provide for different REST API versions in the upcoming Octokit, however the current implementations seems to overwhelm the TypeScript engine. It gets very slow at times, you can see it in the videos I posted at octokit/octokit.js#2127 (comment)

I can understand that TypeScript gets slow, we do work with hundreds of REST API endpoints which are referenced and combined with new definitions for versions other than github.com. But I hope that we can find a way to optimize the speed of the TypeScript lookups to make it usable.

I could really use help with this, as I have no idea how to profile TypeScript when working with VS Code.

To see what I mean, try the following:

  1. In a new folder, run npm init -y && npm install @octokit-next/core
  2. Create an index.ts file with the following content
// import "@octokit-next/types-rest-api";

import { Octokit } from "@octokit-next/core";

export async function test() {
  const octokit = new Octokit({
    auth: "token 0000000000000000000000000000000000000001",
  });

  const responseRepo = await octokit.request("GET /repos/{owner}/{repo}", {
    owner: "octokit-fixture-org",
    repo: "hello-world",
  });
  expectType<string>(responseRepo.data.owner.login);
}

function expectType<T>(value: T): void {}

Now the import in first line and see how long it takes for TypeScript to catch up with the new types for the GET /repos/{owner}/{repo} endpoint.

There are other examples that can be seen in the video, but figuring out how we could improve the performance for this particular case would be a great start.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions