Skip to content

Unable to get variable suggestions in VS Code, error in TS Server logs #27338

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
IllusionMH opened this issue Sep 25, 2018 · 4 comments · Fixed by #27485
Closed

Unable to get variable suggestions in VS Code, error in TS Server logs #27338

IllusionMH opened this issue Sep 25, 2018 · 4 comments · Fixed by #27485
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@IllusionMH
Copy link
Contributor

Problem appeared last week when I've updated typescript version to @next and added path to updated version in typescript.tsdk.

As result - completion for object properties/methods works as intended, but VS Code unable to produce suggestions for variables etc. Which makes development in big files problematic.
Problem appeared in big JS only project (TS Server reports 3566 files), allowJS/checkJS enabled. I will try to make smaller repro case later.
VS Code 1.27.2 works fine with built-in TS 3.0.3, but fails with TS 3.1.0-dev.20180829 and later, therefore issue was created directly in this repo. VS Code Insiders, that has 3.1.0 build-in - has described problem.

TypeScript Version: 3.1.0-dev.20180925
First bad TypeScript Version: 3.1.0-dev.20180829

Search Terms: suggestions, completionInfo, intellisense, completion, 'some' of undefined

Code

import React from 'react';
import { Row, Col } from 'react-bootstrap';

const REQUIRED_EXAMPLE_COLUMN = 6;

export const EditComponent = () => (<Row>
    <Col xs={|cursor here|} />
</Row>);

const noSuggestion = 2 * |cursor here|;

Expected behavior:
Proper list of suggestions.

Actual behavior:
Only text suggestions are available in VS Code.

Screenshot

image

`tsserver.log` has next trace in it:
Info 3536 [14:44:41.382] request:
    {"seq":35,"type":"request","command":"quickinfo","arguments":{"file":"c:/projects/<path redacted>/index.js","line":7,"offset":13}}
Perf 3537 [14:44:41.382] 35::quickinfo: elapsed time (in milliseconds) 0.2604
Info 3538 [14:44:41.382] response:
    {"seq":0,"type":"response","command":"quickinfo","request_seq":35,"success":false,"message":"No content available."}
Info 3539 [14:44:41.715] request:
    {"seq":36,"type":"request","command":"getCodeFixes","arguments":{"file":"c:/projects/<path redacted>/index.js","startLine":7,"startOffset":13,"endLine":7,"endOffset":15,"errorCodes":[17000]}}
Perf 3540 [14:44:41.716] 36::getCodeFixes: elapsed time (in milliseconds) 0.6273
Info 3541 [14:44:41.716] response:
    {"seq":0,"type":"response","command":"getCodeFixes","request_seq":36,"success":true,"body":[{"fixName":"disableJsDiagnostics","description":"Ignore this error message","changes":[{"fileName":"c:/projects/<path redacted>/index.js","textChanges":[{"start":{"line":7,"offset":5},"end":{"line":7,"offset":5},"newText":"// @ts-ignore\n    "}]}],"fixId":"disableJsDiagnostics","fixAllDescription":"Add '@ts-ignore' to all error messages"},{"fixName":"disableJsDiagnostics","description":"Disable checking for this file","changes":[{"fileName":"c:/projects/<path redacted>/index.js","textChanges":[{"start":{"line":1,"offset":1},"end":{"line":1,"offset":1},"newText":"// @ts-nocheck\n"}]}]}]}
Info 3542 [14:44:42.452] request:
    {"seq":37,"type":"request","command":"completionInfo","arguments":{"file":"c:/projects/<path redacted>/index.js","line":7,"offset":14,"includeExternalModuleExports":true,"includeInsertTextCompletions":true}}
Info 3543 [14:44:42.453] getCompletionData: Get current token: 0
Info 3544 [14:44:42.453] getCompletionData: Is inside comment: 0
Info 3545 [14:44:42.453] getCompletionData: Get previous token 1: 0
Info 3546 [14:44:42.453] getCompletionsAtPosition: isCompletionListBlocker: 0
Err 3547  [14:44:42.460] Exception on executing command {"seq":37,"type":"request","command":"completionInfo","arguments":{"file":"c:/projects/<path redacted>/index.js","line":7,"offset":14,"includeExternalModuleExports":true,"includeInsertTextCompletions":true}}:

    Cannot read property 'some' of undefined

    TypeError: Cannot read property 'some' of undefined
    at C:\web\ts-setup\typscript-next\node_modules\typescript\lib\tsserver.js:94735:59
    at C:\web\ts-setup\typscript-next\node_modules\typescript\lib\tsserver.js:108369:21
    at forEachExternalModule (C:\web\ts-setup\typscript-next\node_modules\typescript\lib\tsserver.js:108382:21)
    at Object.forEachExternalModuleToImportFrom (C:\web\ts-setup\typscript-next\node_modules\typescript\lib\tsserver.js:108367:13)
    at getSymbolsFromOtherSourceFileExports (C:\web\ts-setup\typscript-next\node_modules\typescript\lib\tsserver.js:94722:28)
    at getGlobalCompletions (C:\web\ts-setup\typscript-next\node_modules\typescript\lib\tsserver.js:94619:21)
    at tryGetGlobalSymbols (C:\web\ts-setup\typscript-next\node_modules\typescript\lib\tsserver.js:94542:25)
    at getCompletionData (C:\web\ts-setup\typscript-next\node_modules\typescript\lib\tsserver.js:94421:22)
    at Object.getCompletionsAtPosition (C:\web\ts-setup\typscript-next\node_modules\typescript\lib\tsserver.js:93613:34)
    at Object.getCompletionsAtPosition (C:\web\ts-setup\typscript-next\node_modules\typescript\lib\tsserver.js:114869:35)
    at IOSession.Session.getCompletions (C:\web\ts-setup\typscript-next\node_modules\typescript\lib\tsserver.js:122655:64)
    at Session.handlers.ts.createMapFromTemplate._a.(anonymous function) (C:\web\ts-setup\typscript-next\node_modules\typescript\lib\tsserver.js:121716:61)
    at C:\web\ts-setup\typscript-next\node_modules\typescript\lib\tsserver.js:123133:88
    at IOSession.Session.executeWithRequestId (C:\web\ts-setup\typscript-next\node_modules\typescript\lib\tsserver.js:123124:28)
    at IOSession.Session.executeCommand (C:\web\ts-setup\typscript-next\node_modules\typescript\lib\tsserver.js:123133:33)
    at IOSession.Session.onMessage (C:\web\ts-setup\typscript-next\node_modules\typescript\lib\tsserver.js:123153:35)
    at Interface.<anonymous> (C:\web\ts-setup\typscript-next\node_modules\typescript\lib\tsserver.js:124417: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)
Info 3548 [14:44:42.461] response:
    {"seq":0,"type":"response","command":"completionInfo","request_seq":37,"success":false,"message":"Error processing request. Cannot read property 'some' of undefined\nTypeError: Cannot read property 'some' of undefined\n    at C:\\web\\ts-setup\\typscript-next\\node_modules\\typescript\\lib\\tsserver.js:94735:59\n    at C:\\web\\ts-setup\\typscript-next\\node_modules\\typescript\\lib\\tsserver.js:108369:21\n    at forEachExternalModule (C:\\web\\ts-setup\\typscript-next\\node_modules\\typescript\\lib\\tsserver.js:108382:21)\n    at Object.forEachExternalModuleToImportFrom (C:\\web\\ts-setup\\typscript-next\\node_modules\\typescript\\lib\\tsserver.js:108367:13)\n    at getSymbolsFromOtherSourceFileExports (C:\\web\\ts-setup\\typscript-next\\node_modules\\typescript\\lib\\tsserver.js:94722:28)\n    at getGlobalCompletions (C:\\web\\ts-setup\\typscript-next\\node_modules\\typescript\\lib\\tsserver.js:94619:21)\n    at tryGetGlobalSymbols (C:\\web\\ts-setup\\typscript-next\\node_modules\\typescript\\lib\\tsserver.js:94542:25)\n    at getCompletionData (C:\\web\\ts-setup\\typscript-next\\node_modules\\typescript\\lib\\tsserver.js:94421:22)\n    at Object.getCompletionsAtPosition (C:\\web\\ts-setup\\typscript-next\\node_modules\\typescript\\lib\\tsserver.js:93613:34)\n    at Object.getCompletionsAtPosition (C:\\web\\ts-setup\\typscript-next\\node_modules\\typescript\\lib\\tsserver.js:114869:35)\n    at IOSession.Session.getCompletions (C:\\web\\ts-setup\\typscript-next\\node_modules\\typescript\\lib\\tsserver.js:122655:64)\n    at Session.handlers.ts.createMapFromTemplate._a.(anonymous function) (C:\\web\\ts-setup\\typscript-next\\node_modules\\typescript\\lib\\tsserver.js:121716:61)\n    at C:\\web\\ts-setup\\typscript-next\\node_modules\\typescript\\lib\\tsserver.js:123133:88\n    at IOSession.Session.executeWithRequestId (C:\\web\\ts-setup\\typscript-next\\node_modules\\typescript\\lib\\tsserver.js:123124:28)\n    at IOSession.Session.executeCommand (C:\\web\\ts-setup\\typscript-next\\node_modules\\typescript\\lib\\tsserver.js:123133:33)\n    at IOSession.Session.onMessage (C:\\web\\ts-setup\\typscript-next\\node_modules\\typescript\\lib\\tsserver.js:123153:35)\n    at Interface.<anonymous> (C:\\web\\ts-setup\\typscript-next\\node_modules\\typescript\\lib\\tsserver.js:124417:27)\n    at emitOne (events.js:116:13)\n    at Interface.emit (events.js:211:7)\n    at Interface._onLine (readline.js:282:10)\n    at Interface._normalWrite (readline.js:424:12)\n    at Socket.ondata (readline.js:141:10)\n    at emitOne (events.js:116:13)\n    at Socket.emit (events.js:211:7)\n    at addChunk (_stream_readable.js:263:12)\n    at readableAddChunk (_stream_readable.js:250:11)\n    at Socket.Readable.push (_stream_readable.js:208:10)\n    at Pipe.onread (net.js:594:20)"}

Related Issues:
Pull request that introduced issue #25708 line

@IllusionMH IllusionMH changed the title Unable to get variable suggestions in VS Code, error in TS Servel logs Unable to get variable suggestions in VS Code, error in TS Server logs Sep 25, 2018
@IllusionMH
Copy link
Contributor Author

Looks like there is an easy fix for this issue. Would you mind to accept PR on this?

@IllusionMH
Copy link
Contributor Author

I've tried several file/code structures, but no luck to get repro case and I would try to debug it later.

In the meantime, do you accept PR that fixes exception?

@RyanCavanaugh RyanCavanaugh added the Bug A bug in TypeScript label Oct 1, 2018
@RyanCavanaugh
Copy link
Member

@IllusionMH sure, a PR would be great

@RyanCavanaugh RyanCavanaugh added this to the TypeScript 3.2 milestone Oct 1, 2018
IllusionMH added a commit to IllusionMH/TypeScript that referenced this issue Oct 1, 2018
@RyanCavanaugh RyanCavanaugh added the Fixed A PR has been merged for this issue label Oct 2, 2018
RyanCavanaugh added a commit that referenced this issue Oct 2, 2018
…n-27338

Use safe some function to handle undefined declarations (fixes #27338)
@IllusionMH
Copy link
Contributor Author

Checked with recent typescript@next package and suggestions works as expected.

@RyanCavanaugh Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants