Skip to content

Auto imports does not work for extensions #19629

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
mjbvz opened this issue Oct 31, 2017 · 3 comments · Fixed by #19664
Closed

Auto imports does not work for extensions #19629

mjbvz opened this issue Oct 31, 2017 · 3 comments · Fixed by #19664
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue VS Code Tracked There is a VS Code equivalent to this issue

Comments

@mjbvz
Copy link
Contributor

mjbvz commented Oct 31, 2017

From @bpasero on October 31, 2017 13:37

Testing: microsoft/vscode#37177

  1. create a hello world JS extension
  2. open extension.js
  3. start to type RelativePattern
  4. complete it

=> no import is added

Imho if there is no import action after accepting a proposal, we should also not show it in the IntelliSense window.

Copied from original issue: microsoft/vscode#37282

@mjbvz mjbvz self-assigned this Oct 31, 2017
@mjbvz mjbvz removed their assignment Oct 31, 2017
@mjbvz mjbvz added the VS Code Tracked There is a VS Code equivalent to this issue label Oct 31, 2017
@mhegazy
Copy link
Contributor

mhegazy commented Oct 31, 2017

@mjbvz can you elaborate on the issue. i am not sure i understand

@mjbvz
Copy link
Contributor Author

mjbvz commented Oct 31, 2017

Repo

  1. Run yo code to create a vs code extension
  2. Select and generate a new js extension
  3. Open the generated extension in VS Code insiders and then open the extension.js file
  4. At the top of the file, type out Relative so that RelativePattern is shown as a completion item

Expected
Selecting this item should add an import for RelativePattern from 'vscode'

Bug
Selecting this item only does the completion. It does not add the import

With TS 2.6.1 I see this for the error being printed when we request the details:

[Trace  - 4:56:58 PM] Sending request: completionEntryDetails (33). Response expected: yes. Current queue length: 0
Arguments: {
    "file": "/Users/matb/projects/test/test-js-ext/extension.js",
    "line": 4,
    "offset": 9,
    "entryNames": [
        {
            "name": "RelativePattern",
            "source": "vscode"
        }
    ]
}
[Trace  - 4:56:58 PM] Response received: completionEntryDetails (33). Request took 6 ms. Success: false . Message: Error processing request. Debug Failure. False expression.
Error: Debug Failure. False expression.
    at getImportDeclaration (/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:75926:30)
    at /Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:75913:98
    at Object.mapDefined (/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:1610:30)
    at getImportDeclarations (/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:75912:72)
    at Object.getCodeActionForImport (/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:75882:32)
    at getCompletionEntryCodeActions (/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:65309:31)
    at Object.getCompletionEntryDetails (/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:65283:35)
    at Object.getCompletionEntryDetails (/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:79782:35)
    at Object.proxy.(anonymous function) [as getCompletionEntryDetails] (/Users/matb/.vscode-oss-dev/extensions/eg2.vscode-ts-tslint-0.0.1/node_modules/tslint-language-service/out/src/index.js:42:33)
    at /Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:86221:64
    at Object.mapDefined (/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:1610:30)
    at IOSession.Session.getCompletionEntryDetails (/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:86219:27)
    at Session.handlers.ts.createMapFromTemplate._a.(anonymous function) (/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:85317:61)
    at /Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:86669:88
    at IOSession.Session.executeWithRequestId (/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:86660:28)
    at IOSession.Session.executeCommand (/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:86669:33)
    at IOSession.Session.onMessage (/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:86689:35)
    at Interface.<anonymous> (/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:87881:27)
    at emitOne (events.js:96:13)
    at Interface.emit (events.js:191:7)
    at Interface._onLine (readline.js:241:10)
    at Interface._normalWrite (readline.js:384:12)
    at Socket.ondata (readline.js:101:10)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:191:7)
    at readableAddChunk (_stream_readable.js:178:18)
    at Socket.Readable.push (_stream_readable.js:136:10)
    at Pipe.onread (net.js:560:20)

@mhegazy mhegazy added the Bug A bug in TypeScript label Nov 1, 2017
@mhegazy mhegazy assigned ghost Nov 1, 2017
@mhegazy mhegazy added this to the TypeScript 2.6.2 milestone Nov 1, 2017
@ghost
Copy link

ghost commented Nov 1, 2017

This also isn't working in an empty TS project with two files a.ts and b.ts where b.ts contains export const bbb = 0;.
It looks like the list of entryNames we're getting from vscode doesn't have source properties set.

Info 105  [12:59:34.526] request:
    {"seq":17,"type":"request","command":"completionEntryDetails","arguments":{"file":"/home/andy/sample/ts/src/a.ts","line":1,"offset":3,"entryNames":["bbb"]}}

Should be: "entryNames": [{ "name": "bbb", "source": "/home/andy/sample/ts/src/b.ts" }]

EDIT: Never mind, just needed to install the new update. 🎊 Will investigate more.

@ghost ghost closed this as completed in #19664 Nov 2, 2017
@mhegazy mhegazy reopened this Nov 2, 2017
@ghost ghost closed this as completed in #19667 Nov 7, 2017
@mhegazy mhegazy added the Fixed A PR has been merged for this issue label Nov 7, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue VS Code Tracked There is a VS Code equivalent to this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants