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

Require options #4

Open
Ismael-Oliv opened this issue Jul 25, 2020 · 18 comments
Open

Require options #4

Ismael-Oliv opened this issue Jul 25, 2020 · 18 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@Ismael-Oliv
Copy link

When I try to import using javascript like this way "const fs = require('fs') and typescript with "import", it doesn't show all the "require" options that it used to do.
I'm using the 1.2.0 atom-ide-javascript version

video.zip

@aminya
Copy link
Member

aminya commented Jul 25, 2020

Does it show any other autocomplete? Something like:

["1"].conc

should suggest concat.

@Ismael-Oliv
Copy link
Author

yeah, It does

Captura de tela de 2020-07-25 14-18-37

@aminya aminya added bug Something isn't working can't reproduce labels Jul 25, 2020
@aminya
Copy link
Member

aminya commented Jul 25, 2020

@lierdakil Any idea about this? Has anything changed from the TypeScript side?

@aminya
Copy link
Member

aminya commented Jul 25, 2020

@Ismael-Oliv Please try with v1.2.1 and see if this fixes it.

@Ismael-Oliv
Copy link
Author

Not yet, but it worked when I installed the express types' => @types/express.

Captura de tela de 2020-07-25 14-58-47

And I think it's because of autocomplete-paths package , its showing so many stuffs .

Captura de tela de 2020-07-25 15-04-01

@aminya
Copy link
Member

aminya commented Jul 25, 2020

If you type

const fs = require('f

doesn't it offer 'fs'?

It offers all the installed dependencies and Node libraries to me:
image

If you want a specific library you should install it inside package.json, otherwise, it will only show the Node libraries.

@Ismael-Oliv
Copy link
Author

yeah, But it just shows the "require" options because I had installed the express types of typescript

Captura de tela de 2020-07-25 15-11-13

When I try to import anything without installing any library, it's not showing ...

Captura de tela de 2020-07-25 15-18-48

But I'm gonna remove atom and Install again with all packages. to see if it work

@aminya
Copy link
Member

aminya commented Jul 25, 2020

OK. Now I understand the problem better. When you do not have any library installed, it does not show it. Although I cannot reproduce it, I will take a closer look.
image

I do not think reinstalling Atom helps much. If you install atom-ide-javascript only, it will install all the deps automatically.

@aminya
Copy link
Member

aminya commented Jul 25, 2020

I can confirm that sometimes the autocomplete is not fast/intelligent enough here. It might be because of the TypeScript server. @lierdakil and I will take a look into this.

image

@Ismael-Oliv
Copy link
Author

I installed it again and it's not working yet

Captura de tela de 2020-07-25 15-56-38

if is there something that I can do to help you, just tell me.

@aminya
Copy link
Member

aminya commented Jul 25, 2020

Try installing @types/node for now, which you should always do when writing Node programs, until we see if we can reproduce this.

@Ismael-Oliv
Copy link
Author

Alright, no problem. 👍

@aminya
Copy link
Member

aminya commented Jul 25, 2020

I think I should add an option for automatic Nodejs completions. Maybe it works on my system out of the box because I have @types/node installed globally.

@Ismael-Oliv
Copy link
Author

Alright, I'm gonna try it ...

@lierdakil
Copy link

Without @types/* packages in scope, TypeScript server should generally recognize require, but only offers sub-directories of node_modules as "bare" import suggestions. If you add ./ to the argument, it switches to local files instead. Generally a good idea to add relevant @types to devDependencies in any case, although I appreciate it can be a bit of a hassle. Also, unless require is defined somewhere in the ambient declaration, tsserver doesn't assume require is even defined, so it doesn't offer it as a suggestion.

There is a caveat however, TypeScript will sometimes cache type definitions in $HOME/.cache/typescript and might use those even if there aren't any installed in the current project. There is very little information on when exactly this happens however, so I couldn't tell you how that works if my life depended on it.

Including/enabling Node definitions by default isn't the greatest idea, because some of us write code for the browser (shocking, I know), and we don't really want to see Node-specific suggestions that won't work.

@aminya
Copy link
Member

aminya commented Jul 26, 2020

I have a suggestion. We can add a command and a Tool-bar button to add Nodejs support by using that. People who need Node should click or run that command first, or should install the @types

@lierdakil
Copy link

Typing npm i --save-dev --only=dev @types/node once per project isn't that much of a chore I reckon, so I don't see much value in inventing new ways to add some definitions (which aren't even necessarily correct, because who knows what node version does the user intend to use) only for the sake of saving a couple keystrokes.

The "hassle" I was talking about above is tracking down and installing definitions for all the dependencies -- that is a bit of a chore.

@aminya
Copy link
Member

aminya commented Jul 26, 2020

I am planning to add a npm IDE which adds GUI and clickable buttons for running various operations. I think we can address installing the types in that package!

@aminya aminya added enhancement New feature or request good first issue Good for newcomers and removed bug Something isn't working can't reproduce labels Jul 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants