Skip to content

Auto-import feature not working #1344

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

Closed
gsoldevila opened this issue Sep 21, 2017 · 12 comments
Closed

Auto-import feature not working #1344

gsoldevila opened this issue Sep 21, 2017 · 12 comments
Labels

Comments

@gsoldevila
Copy link

Hello,

A couple of key functionalities of atom-typescript are not working at all for me:

  • Automatically adding import statements (neither Angular classes or my own exported classes within the project)
  • Auto-completing type names for external types

I have a project with a tsconfig.json, and I tried installing the atom-typescript both from Atom package manager and command line. I also tried uninstalling and re-installing atom-typescript, linter and autocomplete-plus, as suggested in another post, without any success.

I did not see any message of the form:

AtomTS: Dependencies installed correctly. Enjoy TypeScript

I'm on Elementary OS (Ubuntu 16.04), using Atom 1.19.3 x64 and atom-typescript-11.0.9

Any clues or logs that I can check?

Thanks and kind regards

@lierdakil
Copy link
Collaborator

Automatically adding import statements (neither Angular classes or my own exported classes within the project)

Uh... did we ever have that? Readme doesn't seem to suggest we do now at least.
/cc @guncha

Auto-completing type names for external types

What's external types?

AtomTS: Dependencies installed correctly. Enjoy TypeScript

Wait, what?

@gsoldevila
Copy link
Author

Automatically adding import statements (neither Angular classes or my own exported classes within the project)
Uh... did we ever have that? Readme doesn't seem to suggest we do now at least.
/cc @guncha

Oops, my bad then. I thought this feature would be present. Indeed no mention about it on the list of features. I believe it would be a very nice addition.

Auto-completing type names for external types
What's external types?

For example, if I define a class export class MyClassA { ... } in a file a.ts.
Then I intend to use this class on another file, say b.ts.
In order for autocomplete to work, I noticed I must manually add an import statement in b.ts.
Isn't there such thing as folder scanning to detect the available types?

AtomTS: Dependencies installed correctly. Enjoy TypeScript
Wait, what?

Stated here, after successful installation a couple of notification messages should appear, which I do not have when installing atom-typescript. Some people reported they experienced better autocompletion after fixing this problem. Unfortunately the proposed fix did not work for me. That's why I thought my installation was perhaps faulty and some features were missing.

Thanks and kind regards

@lierdakil
Copy link
Collaborator

Oops, my bad then. I thought this feature would be present. Indeed no mention about it on the list of features. I believe it would be a very nice addition.

Actually, we do have that feature, I just wasn't aware of it. You need intentions package in addition to atom-typescript, then run 'intentions:show' command on an error with unknown import, kinda like this:
image

Isn't there such thing as folder scanning to detect the available types?

Uhh... we're using tsserver for autocompletion suggestions, and I don't think it does that. More than that, I don't think I'd want local autocompletion scope to be polluted by every possible definition from whole project, I imagine that'd easily turn into a mess for anything larger than "hello world"-type application.

Atom will, however, automatically include identifiers from all currently-open buffers. Those have lowest priority, so expect to find them way down in the suggestions list.

Stated here (#549)

That's old. Two years old in fact. We don't do that message anymore.

@gsoldevila
Copy link
Author

I have intentions installed. However, such a suggestion does not appear in my list:
image

And in the same folder, I have a sample.ts, of the form:
image

@lierdakil
Copy link
Collaborator

However, such a suggestion does not appear in my list

I don't see the list at all. Um. Maybe a gif will help?
intentions
you need to run 'intentions:show' command when text cursor is on the error (which is underlined in dotted red)

@gsoldevila
Copy link
Author

Correct, don't have a list at all, just the tooltip from the TS compiler / linter. Any clues of what could be wrong?
intentions-show

@teristam
Copy link

teristam commented Oct 26, 2017

Hi, I am also having the same problem. Tried everything but the list just doesn't show up. I am on Windows 10, atom-typescript 11.0.10, Typescript 2.3.4. I also tried to force update the Typescript to the latest version but still didn't work.

@gsoldevila
Copy link
Author

gsoldevila commented Oct 29, 2017

@teristam I have the auto-import feature working now, but I believe it's provided by some other package I installed afterwards. Here's the list of packages I have currently installed:

  • angular-2-typeScript-snippets@0.7.0
  • atom-beautify@0.30.5
  • atom-bootstrap4@1.4.0
  • atom-npm-outdated@0.13.1
  • atom-ternjs@0.18.3
  • atom-typescript@11.0.10
  • autoclose-html@0.23.0
  • autocomplete-modules@1.7.3 ===> (I believe that's the one)
  • busy-signal@1.4.3
  • css-color-name@0.4.0
  • emmet@2.4.3
  • git-plus@7.10.0
  • hyperclick@0.1.5
  • intentions@1.1.5
  • jumpy@3.1.3
  • linter@2.2.0
  • linter-ui-default@1.6.10
  • minimap@4.29.7
  • minimap-find-and-replace@4.5.2
  • minimap-git-diff@4.3.1
  • npm-plus@0.4.0
  • refactor@0.11.5

@ghost
Copy link

ghost commented Nov 8, 2017

This keep me busy for over 1 hour :(
I've found the solution in this comment: #549 (comment)

Atom as a build-in Typescript support. If you install atom-typescript plugin there are 2 different kind of Typescript syntax. The solution is to switch to the one from atom-typescript. Done!

I will create another issue because I think atom-typescript should disable language-typescript to avoid this confusion.

@olee
Copy link

olee commented Mar 12, 2018

I also have no working auto-import feature (I had it once sometime in the past) but I already have language-typescript disabled.
...
After some investigation I found out this (probably) only affects Windows.
At this code

.getErrorsAt(filePath, pointToLocation(bufferPosition))
filePath is written using backslash, however errorPusher stores errors using normal slashes.

I don't know WHERE this should be fixed (I guess the filePaths should just always be OS dependent as textEditor.getPath() is also OS dependent.

What I did for now to fix it locally was this in codefixProvider.ts:

    async runCodeFix(textEditor, bufferPosition) {
        var filePath = textEditor.getPath();
        if (!filePath || !this.errorPusher || !this.clientResolver || !this.withTypescriptBuffer) {
            return [];
        }
        if (path.sep === "\\")
            filePath = filePath.replace(/\\/g, "/"); // Change windows path to unix path
/// ...
/// ...
    async applyFix(fix) {
        for (const f of fix.changes) {
            var fileName = f.fileName;
            if (path.sep === "\\")
                fileName = fileName.replace(/\//g, "\\"); // Change unix path to windows path

@lierdakil
Copy link
Collaborator

@olee, thanks for catching this. The tricky part here is tsserver only uses / as path separator on any platform. Which can actually mess with a lot of stuff.

Anyway, 12.3.7 should hopefully fix that particular bug, with any luck without introducing new ones.

... although bear in mind you need language-typescript enabled for 12.x, since we've decided it's pointless to try to fight with the bundled grammar and switched to it instead.

@github-actions
Copy link

This issue has been marked as stale because it did not have any activity for the last 90 days or more. Remove the stale label or comment or this will be closed in 14 days

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants