atom-community / atom-ide-javascript

JavaScript support for Atom IDE
https://atom.io/packages/atom-ide-javascript
Other
17 stars 5 forks source link

Require options #4

Open Ismael-Oliv opened 4 years ago

Ismael-Oliv commented 4 years ago

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 commented 4 years ago

Does it show any other autocomplete? Something like:

["1"].conc

should suggest concat.

Ismael-Oliv commented 4 years ago

yeah, It does

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

aminya commented 4 years ago

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

aminya commented 4 years ago

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

Ismael-Oliv commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

Alright, no problem. :+1:

aminya commented 4 years ago

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 commented 4 years ago

Alright, I'm gonna try it ...

lierdakil commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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!