Typescript: Code completion for import suggestion stopped working

Created on 9 Oct 2018  路  14Comments  路  Source: microsoft/TypeScript

_From @zfeher on October 9, 2018 9:44_

  • VSCode Version: 1.28.0
  • VSCode Insiders Version: 1.29.0-insider (user setup) Commit: c1100eff93b35dc220ce63e2ed0d5ace54259795 Date: 2018-10-09T06:54:02.898Z
  • OS Version: Windows 10 1803

Steps to Reproduce:

  1. open some project
  2. start to type a function name which is not yet imported. code completion should show import suggestions during typing and when pressing CTRL+SPACE

Does this issue occur when all extensions are disabled?: Yes

The following error occurs in TypeScript output

[Error  - 11:27:50 AM] 'completionInfo' request failed with error.
Error processing request. Cannot read property 'some' of undefined
TypeError: Cannot read property 'some' of undefined
    at c:\Users\zfeher\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:94664:59
    at c:\Users\zfeher\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:108298:21
    at forEachExternalModule (c:\Users\zfeher\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:108311:21)
    at Object.forEachExternalModuleToImportFrom (c:\Users\zfeher\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:108296:13)
    at getSymbolsFromOtherSourceFileExports (c:\Users\zfeher\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:94651:28)
    at getGlobalCompletions (c:\Users\zfeher\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:94548:21)
    at tryGetGlobalSymbols (c:\Users\zfeher\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:94471:25)
    at getCompletionData (c:\Users\zfeher\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:94350:22)
    at Object.getCompletionsAtPosition (c:\Users\zfeher\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:93542:34)
    at Object.getCompletionsAtPosition (c:\Users\zfeher\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:114798:35)
    at IOSession.Session.getCompletions (c:\Users\zfeher\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:122583:64)
    at Session.handlers.ts.createMapFromTemplate._a.(anonymous function) (c:\Users\zfeher\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:121645:61)
    at c:\Users\zfeher\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:123061:88
    at IOSession.Session.executeWithRequestId (c:\Users\zfeher\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:123052:28)
    at IOSession.Session.executeCommand (c:\Users\zfeher\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:123061:33)
    at IOSession.Session.onMessage (c:\Users\zfeher\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:123081:35)
    at Interface.<anonymous> (c:\Users\zfeher\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:124344:27)
    at emitOne (events.js:116:13)
    at Interface.emit (events.js:211:7)
    at Interface._onLine (readline.js:282:10)
    at Interface._normalWrite (readline.js:424:12)
    at Socket.ondata (readline.js:141:10)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at addChunk (_stream_readable.js:263:12)
    at readableAddChunk (_stream_readable.js:250:11)
    at Socket.Readable.push (_stream_readable.js:208:10)
    at Pipe.onread (net.js:594:20)

_Copied from original issue: Microsoft/vscode#60273_

Duplicate

Most helpful comment

@mjbvz after playing with the issue ~2,5 hours I managed to isolate the problem which you can use to reproduce the issue.
Here you can find the repo: link

As it seems the npm-check-updates package existence cause the problem for some reason. Without it the code completion works for import suggestions but the imported form is placed at the cursor replacing the actual function name and it is in a different form, but this may be another issue.

All 14 comments

@zfeher Can you please provide example code or a small example project that shows this issue.

Also, try upgrading your workspace to use typescript@next by following these instructions. Does this issue still happen when using typescript@next?

Also hitting this issue.
Here is my stack trace on mac.

Err 3488  [12:3:47.764] Exception on executing command {"seq":57,"type":"request","command":"completionEntryDetails","arguments":{"file":"/____/src/exp/Text.tsx","line":154,"offset":25,"entryNames":[{"name":"Shimmer","source":"/____/src/exp/Shimmer"}]}}:

    Debug Failure.

    Error: Debug Failure.
    at Object.assertDefined (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:1446:24)
    at getDefaultExportInfoWorker (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:108190:80)
    at getDefaultLikeExportInfo (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:108171:24)
    at /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:107968:35
    at forEachExternalModule (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:108311:21)
    at getAllReExportingModules (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:107963:13)
    at Object.getImportCompletionAction (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:107949:31)
    at getCompletionEntryCodeActionsAndSourceDisplay (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:94041:33)
    at Object.getCompletionEntryDetails (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:93991:30)
    at Object.getCompletionEntryDetails (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:114803:35)
    at /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:122609:57
    at Object.mapDefined (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:578:30)
    at IOSession.Session.getCompletionEntryDetails (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:122607:33)
    at Session.handlers.ts.createMapFromTemplate._a.(anonymous function) (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:121654:61)
    at /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:123061:88
    at IOSession.Session.executeWithRequestId (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:123052:28)
    at IOSession.Session.executeCommand (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:123061:33)
    at IOSession.Session.onMessage (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:123081:35)
    at Interface.<anonymous> (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:124344:27)
    at emitOne (events.js:116:13)
    at Interface.emit (events.js:211:7)
    at Interface._onLine (readline.js:282:10)
    at Interface._normalWrite (readline.js:424:12)
    at Socket.ondata (readline.js:141:10)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at addChunk (_stream_readable.js:263:12)
    at readableAddChunk (_stream_readable.js:250:11)
    at Socket.Readable.push (_stream_readable.js:208:10)
    at Pipe.onread (net.js:594:20)

@mjbvz I checked with typescript@next and it showed the suggestions but still printing a similar console error. It prints the error on every key type and when I am trying to accept the suggestion (which fails).

Tried to quickly setup a minimal 2 file scenario (a.js + b.js) where one of them had a function named foo. Typing foo in the other empty js showed the import suggestion and accepting it worked just fine with the actual and next version of typescript too.

So it is interesting. I will try to create a small version of our project (javascript with jsconfig.json) where the problem can be reproducable tomorrow.

The error via using typescript@next

[Error  - 9:18:07 PM] 'completionEntryDetails' request failed with error.
Error processing request. Debug Failure.
Error: Debug Failure.
    at Object.assertDefined (C:\Users\midnite\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:1446:24)
    at getDefaultExportInfoWorker (C:\Users\midnite\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:108711:80)
    at getDefaultLikeExportInfo (C:\Users\midnite\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:108692:24)
    at C:\Users\midnite\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:108489:35
    at forEachExternalModule (C:\Users\midnite\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:108832:21)
    at getAllReExportingModules (C:\Users\midnite\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:108484:13)
    at Object.getImportCompletionAction (C:\Users\midnite\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:108470:31)
    at getCompletionEntryCodeActionsAndSourceDisplay (C:\Users\midnite\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:94494:33)
    at Object.getCompletionEntryDetails (C:\Users\midnite\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:94444:30)
    at Object.getCompletionEntryDetails (C:\Users\midnite\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:115324:35)
    at C:\Users\midnite\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:123187:57
    at Object.mapDefined (C:\Users\midnite\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:578:30)
    at IOSession.Session.getCompletionEntryDetails (C:\Users\midnite\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:123185:33)
    at Session.handlers.ts.createMapFromTemplate._a.(anonymous function) (C:\Users\midnite\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:122202:61)
    at C:\Users\midnite\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:123639:88
    at IOSession.Session.executeWithRequestId (C:\Users\midnite\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:123630:28)
    at IOSession.Session.executeCommand (C:\Users\midnite\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:123639:33)
    at IOSession.Session.onMessage (C:\Users\midnite\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:123661:35)
    at Interface.<anonymous> (C:\Users\midnite\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:124925:27)
    at emitOne (events.js:116:13)
    at Interface.emit (events.js:211:7)
    at Interface._onLine (readline.js:282:10)
    at Interface._normalWrite (readline.js:424:12)
    at Socket.ondata (readline.js:141:10)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at addChunk (_stream_readable.js:263:12)
    at readableAddChunk (_stream_readable.js:250:11)
    at Socket.Readable.push (_stream_readable.js:208:10)
    at Pipe.onread (net.js:594:20)

@RyanCavanaugh This is another 3.1.5 candidate

@mjbvz after playing with the issue ~2,5 hours I managed to isolate the problem which you can use to reproduce the issue.
Here you can find the repo: link

As it seems the npm-check-updates package existence cause the problem for some reason. Without it the code completion works for import suggestions but the imported form is placed at the cursor replacing the actual function name and it is in a different form, but this may be another issue.

@andy-ms can you look into this and make sure the change makes its way into release-3.1 and master?

Looks like this may have been fixed by #27674. Can reproduce in typescript@next but not with the latest master branch. @zfeher Could you try again with tomorrow's typescript@next release?

Looks like the original issue is a duplicate of #27338. I'll port the fix (#27485) to release-3.1.

@andy-ms I checked it again with a freshly installed typescript@next which solved the initial problem, no more exception on the console and the suggestions were listed. The accepted "weird" import format problem remained though. Then I checked the typescript version which was 3.2.0-dev.20181010. Waited a little then tried another typescript@next install which installed the 3.2.0-dev.20181011 version and that solved the import format problem as well.

So it seems the problems are solved \o/

@andy-ms Hmmm as it seems the problem still occurs. Earlier I checked my small example project only which was extracted from our full project. There everything worked and works still just fine. But now in our full project I noticed that accepting the import suggestion still doesn't work :(

The import suggestions are listed in code completion but when I try to accept them they fail with the error. Also noticed that the listed suggestions has no Auto import from './...' text on the left side in the same line.

Tomorrow I will try to create another small example project again to see what might be causing the error.

Similar error printed like before:

[Error  - 6:44:21 PM] 'completionEntryDetails' request failed with error.
Error processing request. Debug Failure.
Error: Debug Failure.
    at Object.assertDefined (C:\Users\midnite\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:1446:24)
    at getDefaultExportInfoWorker (C:\Users\midnite\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:108802:80)
    at getDefaultLikeExportInfo (C:\Users\midnite\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:108783:24)
    at C:\Users\midnite\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:108580:35
    at forEachExternalModule (C:\Users\midnite\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:108923:21)
    at getAllReExportingModules (C:\Users\midnite\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:108575:13)
    at Object.getImportCompletionAction (C:\Users\midnite\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:108561:31)
    at getCompletionEntryCodeActionsAndSourceDisplay (C:\Users\midnite\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:94543:33)
    at Object.getCompletionEntryDetails (C:\Users\midnite\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:94493:30)
    at Object.getCompletionEntryDetails (C:\Users\midnite\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:115460:35)
    at C:\Users\midnite\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:123323:57
    at Object.mapDefined (C:\Users\midnite\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:578:30)
    at IOSession.Session.getCompletionEntryDetails (C:\Users\midnite\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:123321:33)
    at Session.handlers.ts.createMapFromTemplate._a.(anonymous function) (C:\Users\midnite\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:122338:61)
    at C:\Users\midnite\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:123775:88
    at IOSession.Session.executeWithRequestId (C:\Users\midnite\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:123766:28)
    at IOSession.Session.executeCommand (C:\Users\midnite\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:123775:33)
    at IOSession.Session.onMessage (C:\Users\midnite\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:123797:35)
    at Interface.<anonymous> (C:\Users\midnite\AppData\Roaming\npm\node_modules\typescript\lib\tsserver.js:125061:27)
    at emitOne (events.js:116:13)
    at Interface.emit (events.js:211:7)
    at Interface._onLine (readline.js:282:10)
    at Interface._normalWrite (readline.js:424:12)
    at Socket.ondata (readline.js:141:10)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at addChunk (_stream_readable.js:263:12)
    at readableAddChunk (_stream_readable.js:250:11)
    at Socket.Readable.push (_stream_readable.js:208:10)
    at Pipe.onread (net.js:594:20)

@zfeher can you open up a separate issue for that so it's easier to track your issue?

@DanielRosenwasser Yes I can create another issue but I don't understand how and why would it be any different than this one (which is also created by me)? The same problem still exists though some part of it is fixed,

Anyway I will try to find out which npm package (if the node_modules folder are not present it works flawlessly) cause the same issue (maybe there are more).

@DanielRosenwasser as per your request I created another issue (#27857) with an updated example project. I found another 3 dependencies which cause the crashing of the code completion feature.

Hello, maybe I found similar problem when Typescript imports some JavaScript - bug #28014. Example with the particular problematic JavaScript is included. Problem is also with 2.9.x. I also don't know how to exclude these JavaScript from Typescript compilation via exclude - see my issue. Thanks.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

quantuminformation picture quantuminformation  路  273Comments

rbuckton picture rbuckton  路  139Comments

Gaelan picture Gaelan  路  231Comments

sandersn picture sandersn  路  265Comments

chanon picture chanon  路  138Comments