Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TypeScript] REST API route completion is not triggered #469

Closed
ghost opened this issue Jun 18, 2022 · 9 comments · Fixed by octokit/types.ts#399
Closed

[TypeScript] REST API route completion is not triggered #469

ghost opened this issue Jun 18, 2022 · 9 comments · Fixed by octokit/types.ts#399
Labels
Type: Bug Something isn't working as documented typescript Relevant to TypeScript users only

Comments

@ghost
Copy link

ghost commented Jun 18, 2022

What happened?

API route completion is not triggered when I use the octokit.request()

What did you expect to happen?

When starting to write the API route, I was expecting to have an API route completion but I don't.
I found (unexpectedly) that using a new pair of parenthesis when calling the method, I do get an API route completion.

How it should be ;

const octokit = new Octokit({ auth: `personal-access-token123` });

const response = await octokit.request(
    "GET /orgs/{org}/repos",
    {
          org: "octokit",
          type: "private",
    }
);

What I have to do ;

const octokit = new Octokit({ auth: `personal-access-token123` });

const response = await octokit.request(
    ("GET /orgs/{org}/repos"),
    {
         org: "octokit",
         type: "private",
    }
);
@ghost ghost added the Type: Bug Something isn't working as documented label Jun 18, 2022
@wolfy1339
Copy link
Member

Can you share some more details regarding your setup?
Editor and editor version, OS, NodeJS version

@wolfy1339
Copy link
Member

I'm not sure this a bug with our code. This simply looks like an oddity with how the typescript types are processed and auto complete

@ghost
Copy link
Author

ghost commented Jun 19, 2022

I'm using the latest version of Vscode (v1.68.1) on Windows 10.

I'm using NodeJS version 18.3.0.

@gr2m
Copy link
Contributor

gr2m commented Jun 20, 2022

I observed the same problem myself, it's very odd! And i was able to confirm that your mention workaround using () as in ("GET /orgs/{org}/repos") works! It feels to me like a bug with VS Code, but I thought it was still working a few days back and suddenly the behavior began.

I'd very much appreciate any help with digging into this

@gr2m gr2m added the typescript Relevant to TypeScript users only label Jun 20, 2022
@gr2m gr2m changed the title REST API route completion is not triggered [TypeScript] REST API route completion is not triggered Jun 20, 2022
@wolfy1339
Copy link
Member

It feels to me like a bug with VS Code

The same problem happens on the Typescript Playground, I don't think it's limited to VS Code

@gr2m
Copy link
Contributor

gr2m commented Jun 21, 2022

This is so funky. Here is the TypeScript playground link to experiment, and a video recording to showcase the problem

Screen.Recording.2022-06-21.at.4.11.14.PM.mov

@gr2m
Copy link
Contributor

gr2m commented Jun 24, 2022

Some insights by @levenleven

it works if you switch to earlier TypeScript version
Playground

and

It seems to work if you split https://github.com/octokit/types.ts/blob/master/src/RequestInterface.ts#L26-L33 to two overloads: one for known routes (keyof Endpoints) and another one for "catch" all string
Playground

@ghost
Copy link
Author

ghost commented Jun 26, 2022

While the PR has fixed the route completion, it looks like the PR has broke options completion

@timrogers
Copy link

@HoTKreeZy Oh dear! 😬 Would you mind creating a new issue so we can track what you’re seeing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Something isn't working as documented typescript Relevant to TypeScript users only
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants