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

Provide Intellisense for module import #10092

Closed
dbaeumer opened this issue Aug 2, 2016 · 11 comments
Closed

Provide Intellisense for module import #10092

dbaeumer opened this issue Aug 2, 2016 · 11 comments
Labels
Duplicate An existing issue was already created VS Code Tracked There is a VS Code equivalent to this issue

Comments

@dbaeumer
Copy link
Member

dbaeumer commented Aug 2, 2016

From @SetTrend on January 21, 2016 14:56

TypeScript module exports can be fairly opaque in regard to their exports. Particularly when modules grow bigger.

With bigger modules (particularly with modules exporting other modules' exports) it becomes very hard to see which entities a module actually is exporting.

So I suggest to provide an Intellisense feature for module imports, which
  1. provides a file browser dropdown box displaying valid module files
  2. provides a module browser dropdown box displaying an imported module's exported entities

#### The first part of the suggestion I propose to work like `LINQ`:

After entering the keyword from and hitting the [TAB] key, a file browser dropdown should be displayed, listing all valid module files. After confirming a file from the dropdown box, VS Code should automatically create a full import {} from "[...]" statement, move the cursor position between the curly braces and display a dropdown box listing all the exports of that module.

Here's a visualization:

provide intellisense for import


#### The second part of the suggestion I propose to work like common Intellisense:

Everytime when hitting [CTRL]+[SPACE] from within the curly braces of an import statement, dropdown box (2) should be displayed, listing the module's exported entities. Selecting an entry should then add the selected export entity to the list of already imported entities within the curly braces.

Copied from original issue: microsoft/vscode#2153

@dbaeumer
Copy link
Member Author

dbaeumer commented Aug 2, 2016

From @atifsyedali on March 2, 2016 20:39

We have around 25k lines of Typescript with hundreds of Typescript modules, and we use CommonJS style module imports.

Not having Intellisense for module import as described here is the main reason why we don't use VS Code. Would be really nice if you can add this (or push the Typescript team to provide it on a language service level :) )

@dbaeumer
Copy link
Member Author

dbaeumer commented Aug 2, 2016

From @Haemoglobin on July 16, 2016 8:58

👍

@dbaeumer
Copy link
Member Author

dbaeumer commented Aug 2, 2016

This is actually a feature that has to come from the tsserver.

@kitsonk
Copy link
Contributor

kitsonk commented Aug 2, 2016

Dupe of #2371? Which was declined at too complex.

(BTW, Search is a useful feature)

@SetTrend
Copy link

SetTrend commented Aug 2, 2016

Not quite a dupe, as #2371 is about changing the syntax, whereas this issue is about providing a list of exported symbols recursively.

Shouldn't be too complex. First implementation iteration:

  1. Load the .ts file mentioned in the from,
  2. enumerate and return all the exports,
  3. recursively enumerate all re-exports and execute (1.) on them.

@mhegazy
Copy link
Contributor

mhegazy commented Sep 29, 2016

#188 provides completions for module names and /// <reference path. We already have completions for module exports, i.e. import { | } from "someModule". Would these cover this request?

I am not too crazy about typing from first, since it is really a different syntax. and i do agree that this would have been a better module import syntax, but this is really a question to TC39 members.

@SetTrend
Copy link

SetTrend commented Sep 30, 2016

Thanks, Mohamed,

yes, the typescript-hero VS Code extension seems to be right the thing I've been looking for.

Thanks for sharing this link with me! 😀 👍

Cheers,
Axel

/cc: @dbaeumer

@waderyan waderyan added the VS Code Tracked There is a VS Code equivalent to this issue label Nov 18, 2016
@waderyan
Copy link

It seems like #188 covers this request. @dbaeumer can you check it out? If it does then we can close this issue.

@dbaeumer
Copy link
Member Author

@waderyan no not exactly the same. He has a nice suggestion of using snippets to create import statements. The major problem is that if write a new import statement then you do import {} from 'fs' and then you have to move the cursor back into {} to complete symbols. This is not very user friendly and I like his suggestion. But that might need a combination of work on our end (extend the snippet UI) and may be API on the tsserver.

@mhegazy
Copy link
Contributor

mhegazy commented Dec 15, 2016

this should be covered by #7849

@mhegazy mhegazy closed this as completed Dec 15, 2016
@mhegazy mhegazy added the Duplicate An existing issue was already created label Dec 15, 2016
@waderyan
Copy link

@mhegazy this actually looks like a duplicate of #12243

See my comment in that issue. I propose we reopen one of these.

@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created VS Code Tracked There is a VS Code equivalent to this issue
Projects
None yet
Development

No branches or pull requests

5 participants