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

Exception accessing undefined array when requesting completions. #16537

Closed
DanielRosenwasser opened this issue Jun 14, 2017 · 1 comment
Closed
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@DanielRosenwasser
Copy link
Member

It's hard for me to repro simply, but start out with the following:

class C<T, U, V> {}

class D extends C</**/

Then start typing at /**/ to get:

[Error - 3:25:29 PM] 'completions' request failed with error.
Error processing request. Cannot read property 'forEach' of undefined
TypeError: Cannot read property 'forEach' of undefined
    at symbolsToArray (C:\Program Files\nodejs\node_modules\typescript\lib\tsserver.js:27940:20)
    at Object.getExportsOfModuleAsArray [as getExportsOfModule] (C:\Program Files\nodejs\node_modules\typescript\lib\tsserver.js:24293:20)
    at symbolCanbeReferencedAtTypeLocation (C:\Program Files\nodejs\node_modules\typescript\lib\tsserver.js:62854:55)
    at C:\Program Files\nodejs\node_modules\typescript\lib\tsserver.js:62818:36
    at Object.filter (C:\Program Files\nodejs\node_modules\typescript\lib\tsserver.js:1438:25)
    at filterGlobalCompletion (C:\Program Files\nodejs\node_modules\typescript\lib\tsserver.js:62804:27)
    at tryGetGlobalSymbols (C:\Program Files\nodejs\node_modules\typescript\lib\tsserver.js:62800:27)
    at getCompletionData (C:\Program Files\nodejs\node_modules\typescript\lib\tsserver.js:62692:22)
    at Object.getCompletionsAtPosition (C:\Program Files\nodejs\node_modules\typescript\lib\tsserver.js:62312:34)
    at Object.getCompletionsAtPosition (C:\Program Files\nodejs\node_modules\typescript\lib\tsserver.js:74328:35)
@DanielRosenwasser DanielRosenwasser added the Bug A bug in TypeScript label Jun 14, 2017
@DanielRosenwasser DanielRosenwasser added this to the TypeScript 2.5 milestone Jun 19, 2017
@ghost
Copy link

ghost commented Jun 28, 2017

I can't reproduce this in a fourslash test or in vscode with typescript@next.
However, this is probably happening because completions calls getExportsOfModule on non-modules. This might be fixed by #16768. It would be nice to have a test case to prove it though.
Should getExportsOfModule just assert that the symbol is a module symbol?

@ghost ghost closed this as completed in #17013 Jul 7, 2017
@ghost ghost added the Fixed A PR has been merged for this issue label Jul 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
Projects
None yet
Development

No branches or pull requests

1 participant