microsoft / microsoft/TypeScript

Go to Definition for Angular (9.0.0-rc.9) project breaks

Open
#36,335 8 comments 7 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Needs Investigation
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

OS and VSCode version
  • VSCode Version: 1.41.1
  • OS Version: Ubuntu Mate 18.04
  • Typescript versions tested: 3.6.4 (version from node_modules) , 3.7.3 (current version used in VSCode), ms-vscode.vscode-typescript-next-3.8.20200119 (using VSCode plugin)
  • Angular version: 9.0.0-rc.9
Problem description (updated with findings in comments below)

Go To Definition does not work properly when trying to go to definition of an Angular class that resides in node_modules. Simply mouse-hovering over this Class (or function) definition works though and the context popup is shown.
Moreover, if navigating to a class that resides inside the project source files (not inside node_modules) also works.
Go To Definition also works when going into definition of libraries that are not part of Angular - for example, rxjs.

Steps to Reproduce:
  1. Import or create Angular project (using RC version 9.0.0-rc.9) and install node_modules
  2. Create a component like so:
import { Component, OnInit } from '@angular/core';

@Component({
  selector: 'app-login',
  templateUrl: './login.component.html',
  styleUrls: ['./login.component.scss']
})
export class LoginComponent implements OnInit {
  constructor() {}

  ngOnInit() {}
}
  1. Try ctrl + mouse click on OnInit class. Following error is thrown in the log file:
Info 260  [8:44:36.701] request:
    {"seq":37,"type":"request","command":"definitionAndBoundSpan","arguments":{"file":"/media/martin/DADOS/Programacao/projetos/bootstrap-code/ui/src/app/modules/login/login.component.ts","line":8,"offset":44}}
Err 261   [8:44:36.883] Exception on executing command {"seq":37,"type":"request","command":"definitionAndBoundSpan","arguments":{"file":"/media/martin/DADOS/Programacao/projetos/bootstrap-code/ui/src/app/modules/login/login.component.ts","line":8,"offset":44}}:

    Maximum call stack size exceeded

    RangeError: Maximum call stack size exceeded
        at String.replace (<anonymous>)
        at Object.normalizeSlashes (/media/martin/DADOS/Programacao/projetos/bootstrap-code/ui/node_modules/typescript/lib/tsserver.js:15757:21)
        at Object.combinePaths (/media/martin/DADOS/Programacao/projetos/bootstrap-code/ui/node_modules/typescript/lib/tsserver.js:16094:31)
        at Object.getPathComponents (/media/martin/DADOS/Programacao/projetos/bootstrap-code/ui/node_modules/typescript/lib/tsserver.js:15943:19)
        at Object.resolvePath (/media/martin/DADOS/Programacao/projetos/bootstrap-code/ui/node_modules/typescript/lib/tsserver.js:16115:82)
        at Object.normalizePath (/media/martin/DADOS/Programacao/projetos/bootstrap-code/ui/node_modules/typescript/lib/tsserver.js:15865:19)
        at Object.toPath (/media/martin/DADOS/Programacao/projetos/bootstrap-code/ui/node_modules/typescript/lib/tsserver.js:8866:18)
        at toPath (/media/martin/DADOS/Programacao/projetos/bootstrap-code/ui/node_modules/typescript/lib/tsserver.js:110995:23)
        at getSourceFile (/media/martin/DADOS/Programacao/projetos/bootstrap-code/ui/node_modules/typescript/lib/tsserver.js:111043:24)
        at tryGetSourcePosition (/media/martin/DADOS/Programacao/projetos/bootstrap-code/ui/node_modules/typescript/lib/tsserver.js:111016:24)
        at tryGetSourcePosition (/media/martin/DADOS/Programacao/projetos/bootstrap-code/ui/node_modules/typescript/lib/tsserver.js:111020:61)
        at tryGetSourcePosition (/media/martin/DADOS/Programacao/projetos/bootstrap-code/ui/node_modules/typescript/lib/tsserver.js:111020:61)
        at tryGetSourcePosition (/media/martin/DADOS/Programacao/projetos/bootstrap-code/ui/node_modules/typescript/lib/tsserver.js:111020:61)
        at tryGetSourcePosition (/media/martin/DADOS/Programacao/projetos/bootstrap-code/ui/node_modules/typescript/lib/tsserver.js:111020:61)
        at tryGetSourcePosition (/media/martin/DADOS/Programacao/projetos/bootstrap-code/ui/node_modules/typescript/lib/tsserver.js:111020:61)
        [... repeated entries ommited for brevity]

File text of /media/martin/DADOS/Programacao/projetos/bootstrap-code/ui/src/app/modules/login/login.component.ts:
    import { Component, OnInit } from '@angular/core';
    
    @Component({
      selector: 'app-login',
      templateUrl: './login.component.html',
      styleUrls: ['./login.component.scss']
    })
    export class LoginComponent implements OnInit {
      constructor() {}
    
      ngOnInit() {}
    }
    

Info 176  [8:56:13.165] response:
    {"seq":0,"type":"response","command":"definitionAndBoundSpan","request_seq":14,"success":false,"message":"Error processing request. Maximum call stack size exceeded\nRangeError: Maximum call stack size exceeded\n    at String.replace (<anonymous>)\n    at Object.normalizeSlashes (/media/martin/DADOS/Programacao/projetos/bootstrap-code/ui/node_modules/typescript/lib/tsserver.js:15757:21)\n    at Object.combinePaths (/media/martin/DADOS/Programacao/projetos/bootstrap-code/ui/node_modules/typescript/lib/tsserver.js:16094:31)\n    at Object.getPathComponents (/media/martin/DADOS/Programacao/projetos/bootstrap-code/ui/node_modules/typescript/lib/tsserver.js:15943:19)\n    at Object.resolvePath (/media/martin/DADOS/Programacao/projetos/bootstrap-code/ui/node_modules/typescript/lib/tsserver.js:16115:82)\n    at Object.normalizePath (/media/martin/DADOS/Programacao/projetos/bootstrap-code/ui/node_modules/typescript/lib/tsserver.js:15865:19)\n    at Object.toPath (/media/martin/DADOS/Programacao/projetos/bootstrap-code/ui/node_modules/typescript/lib/tsserver.js:8866:18)\n    at toPath (/media/martin/DADOS/Programacao/projetos/bootstrap-code/ui/node_modules/typescript/lib/tsserver.js:110995:23)\n    at getSourceFile (/media/martin/DADOS/Programacao/projetos/bootstrap-code/ui/node_modules/typescript/lib/tsserver.js:111043:24)\n    at tryGetSourcePosition (/media/martin/DADOS/Programacao/projetos/bootstrap-code/ui/node_modules/typescript/lib/tsserver.js:111016:24)\n    at tryGetSourcePosition (/media/martin/DADOS/Programacao/projetos/bootstrap-code/ui/node_modules/typescript/lib/tsserver.js:111020:61)\n    at tryGetSourcePosition (/media/martin/DADOS/Programacao/projetos/bootstrap-code/ui/node_modules/typescript/lib/tsserver.js:111020:61)\n    at tryGetSourcePosition (/media/martin/DADOS/Programacao/projetos/bootstrap-code/ui/node_modules/typescript/lib/tsserver.js:111016:24)\n    at tryGetSourcePosition (/media/martin/DADOS/Programacao/projetos/bootstrap-code/ui/node_modules/typescript/lib/tsserver.js:111020:61)\n    at tryGetSourcePosition (/media/martin/DADOS/Programacao/projetos/bootstrap-code/ui/node_modules/typescript/lib/tsserver.js:111020:61)\n    at tryGetSourcePosition (/media/martin/DADOS/Programacao/projetos/bootstrap-code/ui/node_modules/typescript/lib/tsserver.js:111016:24)\n    at tryGetSourcePosition (/media/martin/DADOS/Programacao/projetos/bootstrap-code/ui/node_modules/typescript/lib/tsserver.js:111020:61)\n    at tryGetSourcePosition (/media/martin/DADOS/Programacao/projetos/bootstrap-code/ui/node_modules/typescript/lib/tsserver.js:111020:61)\n    at tryGetSourcePosition (/media/martin/DADOS/Programacao/projetos/bootstrap-code/ui/node_modules/typescript/lib/tsserver.js:111020:61)\n    at tryGetSourcePosition (/media/martin/DADOS/Programacao/projetos/bootstrap-code/ui/node_modules/typescript/lib/tsserver.js:111020:61)\n    at tryGetSourcePosition (/media/martin/DADOS/Programacao/projetos/bootstrap-code/ui/node_modules/typescript/lib/tsserver.js:111020:61)\n    [... repeated entries ommited for brevity]

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

Yes

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing Go to Definition for OnInit in the reported Angular 9.0.0-rc.9 component and inspect the definitionAndBoundSpan request. Read the relevant stack path in node_modules/typescript/lib/tsserver.js, especially the repeated tryGetSourcePosition calls. Done means navigation into Angular classes no longer fails with Maximum call stack size exceeded.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, typescript
Domain
developer-experience, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.