octokit / octokit.js

The all-batteries-included GitHub SDK for Browsers, Node.js, and Deno.
MIT License
6.84k stars 1k forks source link

[BUG]: Octokit Intellisense with Deno in VS Code #2595

Closed mcgear closed 6 months ago

mcgear commented 6 months ago

What happened?

We have setup a simple Deno Fresh project to recreate the issue inside this repo: https://github.com/fathym-deno/octokit-types-test

Specifically in this API route: https://github.com/fathym-deno/octokit-types-test/blob/integration/routes/api/octokit.ts

We are currently not getting any intellisense on the import of octokit. Everything comes back as an any type, so we have to dig through lots of docs to figure out the calls we are looking to make.

This start with the simple Octokit.plugin call, but is an issue for everything else in the .rest and .graphql sections of Octokit too.

Looking for help on how to get this intellisense on the octokit import and creation of a new octokit class (new Octokit({...})).

Thanks for the help.

Versions

Octokit: https://esm.sh/octokit@3.1.2?dts Deno: 1.38.2 Deno Fresh: 1.6.1

Relevant log output

No response

Code of Conduct

github-actions[bot] commented 6 months ago

👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labled with Status: Up for grabs. You & others like you are the reason all of this works! So thank you & happy coding! 🚀

wolfy1339 commented 6 months ago

Does VSCode support getting types over http?

Anyways, the paginate graphql plugin is already included in the Octokit package

mcgear commented 6 months ago

Thanks for the heads up on the paginate. I updated the example to better show other use cases. My hope is to have intellisense on the Octokit type so that the api can be explored, rather than always googling for the correct calls. I added a call to instantiate Octokit (which doesn't have intellisense) and a call to get authenticated user from the rest api (which has no intellisense).

Hoping to get some direction on how to get intellisense working in the Deno, typescript project.

Thanks for the help.

mcgear commented 6 months ago

I forgot to mention that this code is all on the integration branch. I added some clarifying comments and my assumptions on how @octokit/types should be used. So as a part two on this question/bug, do i have the right idea on how the sdk should work?

wolfy1339 commented 6 months ago

In most cases, you won't need to require @octokit/types yourself.

Everything is supposed to be strongly typed.

Using the package from NPM everything seems to work as expected for the typehints in vscode.

Can you try importing directly in your source file and not use import aliases?

If that doesn't work, can you try using npm: specifier imports?

mcgear commented 6 months ago

Thank you for the help. I noticed some "wonkyness" while switching between the types and got me thinking... I was able to get it working with the import alias after using deno cache --reload main.ts. After running that, everything worked. The only issue now is how slow it can be to pull up the intellisense, but that isn't a showstopper.

Thank you for the help.