Typescript: tsserver Error when Go to Definition in VSCode

Created on 10 May 2017  路  5Comments  路  Source: microsoft/TypeScript



TypeScript Version: typescript@next (2.4.0-dev.20170510)

Code
When enable VSCode setting "typescript.tsserver.trace": "verbose", and I tried to go to definition in my react project file, the logs are below.

[Info  - 7:01:56 PM] Using tsserver from: /Users/blanu/.config/yarn/global/node_modules/typescript/lib/tsserver.js
[Info  - 7:01:56 PM] TSServer log file: /var/folders/fw/2qk8yy7935d68q1ctphcq9rr0000gn/T/vscode-tsserver-log-3QG2Lk/tsserver.log
[Error - 7:02:23 PM] 'definition' request failed with error.
Error processing request. Cannot read property 'name' of undefined
TypeError: Cannot read property 'name' of undefined
    at createDefinitionInfo (/Users/blanu/.config/yarn/global/node_modules/typescript/lib/tsserver.js:63970:53)
    at Object.getDefinitionAtPosition (/Users/blanu/.config/yarn/global/node_modules/typescript/lib/tsserver.js:63861:25)
    at Object.getDefinitionAtPosition (/Users/blanu/.config/yarn/global/node_modules/typescript/lib/tsserver.js:72058:38)
    at IOSession.Session.getDefinition (/Users/blanu/.config/yarn/global/node_modules/typescript/lib/tsserver.js:77189:64)
    at Session.handlers.ts.createMapFromTemplate._a.(anonymous function) (/Users/blanu/.config/yarn/global/node_modules/typescript/lib/tsserver.js:76748:61)
    at /Users/blanu/.config/yarn/global/node_modules/typescript/lib/tsserver.js:78041:88
    at IOSession.Session.executeWithRequestId (/Users/blanu/.config/yarn/global/node_modules/typescript/lib/tsserver.js:78032:28)
    at IOSession.Session.executeCommand (/Users/blanu/.config/yarn/global/node_modules/typescript/lib/tsserver.js:78041:33)
    at IOSession.Session.onMessage (/Users/blanu/.config/yarn/global/node_modules/typescript/lib/tsserver.js:78061:35)
    at Interface.<anonymous> (/Users/blanu/.config/yarn/global/node_modules/typescript/lib/tsserver.js:79242:27)

Another try gives different error info:
After turn off Occurrences Highlight ( "editor.occurrencesHighlight": false ), only error above will occur.
Expected behavior:
Go to definition place in VSCode
Actual behavior:
Result no definition.

Bug Fixed

All 5 comments

Also seeing this error. It appears to be limited to GTD when the cursor is on JSX elements, where the component is imported from another file, and _only when that component is defined as an ES6 class_. E.g.:

test.js

import React from 'react';
import C from './C';

const foo = <C />;

C.js

import React from 'react';

export default class C extends React.Component {
  render() {
    return <div>Hello, World</div>;
  }
}

Thanks @andy-ms!

Upgraded Code to 1.13.0 but still face the problem.

@iddan Could you try installing typescript@next and settings typescript.tsdk to point to that?

I currently don't have typescript installed. So I guess I'll just have to wait for this update to get to Code.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bgrieder picture bgrieder  路  3Comments

Zlatkovsky picture Zlatkovsky  路  3Comments

dlaberge picture dlaberge  路  3Comments

Antony-Jones picture Antony-Jones  路  3Comments

manekinekko picture manekinekko  路  3Comments