microsoft / TypeScript

TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
https://www.typescriptlang.org
Apache License 2.0
100.75k stars 12.46k forks source link

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

Open martinreus opened 4 years ago

martinreus commented 4 years ago

OS and VSCode version

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() {} }

3. 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 ()\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
martinreus commented 4 years ago

Update on the issue:

When trying something else, using the same component, but now with an added rxjs library:

import { Component, OnInit } from '@angular/core';
import { Subject } from 'rxjs';

@Component({
  selector: 'app-login',
  templateUrl: './login.component.html',
  styleUrls: ['./login.component.scss']
})
export class LoginComponent implements OnInit {
  $subject: Subject<any>;

  constructor() {}

  ngOnInit() {}
}

Ctrl + mouse click (go to definition) works for Subject, but OnInit remains broken. Does this maybe have to do with something related to the @ in the import path? Or with Angular itself?

martinreus commented 4 years ago

Third update:

Removing node_modules folder and doing npm i again fixed the problem for now. But why??????????

martinreus commented 4 years ago

Update four: Now happening again, same RangeError: Maximum call stack size exceeded error. Something is degrading behind the curtains.. I can provide all logs I have collected so far if needed.

mjbvz commented 4 years ago

Similar call stack to #35515

@martinreus Can you please try upgrading your workspace to use typescript@next by installing this extension. Does that fix the issue?

ajafff commented 4 years ago

Looks like #35014. Even though the title is misleading it should be the same cause.

martinreus commented 4 years ago

Thanks for the answers and sorry for the title of the Issue; it does look incredibly similar to #35014, I am using Angular's @next version 9.0.0-rc.9 here (which has Ivy enabled for default - not sure if it is because of Ivy though, just letting you know).

Unfortunately changing TS version did not help, as you can see from the log file:


Info 520  [21:49:46.331] request:
    {"seq":51,"type":"request","command":"definitionAndBoundSpan","arguments":{"file":"/media/martin/DADOS/Programacao/projetos/bootstrap-code/ui/src/app/modules/login/login.module.ts","line":15,"offset":17}}
Err 521   [21:49:46.497] Exception on executing command {"seq":51,"type":"request","command":"definitionAndBoundSpan","arguments":{"file":"/media/martin/DADOS/Programacao/projetos/bootstrap-code/ui/src/app/modules/login/login.module.ts","line":15,"offset":17}}:

    Maximum call stack size exceeded

    RangeError: Maximum call stack size exceeded
        at String.split (<anonymous>)
        at pathComponents (/home/martin/.vscode/extensions/ms-vscode.vscode-typescript-next-3.8.20200119/node_modules/typescript/lib/tsserver.js:6086:47)
        at getPathComponents (/home/martin/.vscode/extensions/ms-vscode.vscode-typescript-next-3.8.20200119/node_modules/typescript/lib/tsserver.js:6124:16)
        at normalizePath (/home/martin/.vscode/extensions/ms-vscode.vscode-typescript-next-3.8.20200119/node_modules/typescript/lib/tsserver.js:6257:73)
        at Object.toPath (/home/martin/.vscode/extensions/ms-vscode.vscode-typescript-next-3.8.20200119/node_modules/typescript/lib/tsserver.js:6272:15)
        at toPath (/home/martin/.vscode/extensions/ms-vscode.vscode-typescript-next-3.8.20200119/node_modules/typescript/lib/tsserver.js:118201:23)
        at getSourceFile (/home/martin/.vscode/extensions/ms-vscode.vscode-typescript-next-3.8.20200119/node_modules/typescript/lib/tsserver.js:118253:24)
        at tryGetSourcePosition (/home/martin/.vscode/extensions/ms-vscode.vscode-typescript-next-3.8.20200119/node_modules/typescript/lib/tsserver.js:118222:24)
        at tryGetSourcePosition (/home/martin/.vscode/extensions/ms-vscode.vscode-typescript-next-3.8.20200119/node_modules/typescript/lib/tsserver.js:118226:61)
        at tryGetSourcePosition (/home/martin/.vscode/extensions/ms-vscode.vscode-typescript-next-3.8.20200119/node_modules/typescript/lib/tsserver.js:118226:61)
        at tryGetSourcePosition (/home/martin/.vscode/extensions/ms-vscode.vscode-typescript-next-3.8.20200119/node_modules/typescript/lib/tsserver.js:118226:61)
        at tryGetSourcePosition (/home/martin/.vscode/extensions/ms-vscode.vscode-typescript-next-3.8.20200119/node_modules/typescript/lib/tsserver.js:118226:61)
        at tryGetSourcePosition (/home/martin/.vscode/extensions/ms-vscode.vscode-typescript-next-3.8.20200119/node_modules/typescript/lib/tsserver.js:118226:61)
        at tryGetSourcePosition (/home/martin/.vscode/extensions/ms-vscode.vscode-typescript-next-3.8.20200119/node_modules/typescript/lib/tsserver.js:118226:61)
        at tryGetSourcePosition (/home/martin/.vscode/extensions/ms-vscode.vscode-typescript-next-3.8.20200119/node_modules/typescript/lib/tsserver.js:118226:61)
        at tryGetSourcePosition (/home/martin/.vscode/extensions/ms-vscode.vscode-typescript-next-3.8.20200119/node_modules/typescript/lib/tsserver.js:118226:61)
        at tryGetSourcePosition (/home/martin/.vscode/extensions/ms-vscode.vscode-typescript-next-3.8.20200119/node_modules/typescript/lib/tsserver.js:118226:61)
        at tryGetSourcePosition (/home/martin/.vscode/extensions/ms-vscode.vscode-typescript-next-3.8.20200119/node_modules/typescript/lib/tsserver.js:118226:61)
        at tryGetSourcePosition (/home/martin/.vscode/extensions/ms-vscode.vscode-typescript-next-3.8.20200119/node_modules/typescript/lib/tsserver.js:118226:61)
        at tryGetSourcePosition (/home/martin/.vscode/extensions/ms-vscode.vscode-typescript-next-3.8.20200119/node_modules/typescript/lib/tsserver.js:118226:61)
        at tryGetSourcePosition (/home/martin/.vscode/extensions/ms-vscode.vscode-typescript-next-3.8.20200119/node_modules/typescript/lib/tsserver.js:118226:61)
        at tryGetSourcePosition (/home/martin/.vscode/extensions/ms-vscode.vscode-typescript-next-3.8.20200119/node_modules/typescript/lib/tsserver.js:118226:61)
        at tryGetSourcePosition (/home/martin/.vscode/extensions/ms-vscode.vscode-typescript-next-3.8.20200119/node_modules/typescript/lib/tsserver.js:118226:61)
        at tryGetSourcePosition (/home/martin/.vscode/extensions/ms-vscode.vscode-typescript-next-3.8.20200119/node_modules/typescript/lib/tsserver.js:118226:61)
        at tryGetSourcePosition (/home/martin/.vscode/extensions/ms-vscode.vscode-typescript-next-3.8.20200119/node_modules/typescript/lib/tsserver.js:118226:61)
        at tryGetSourcePosition (/home/martin/.vscode/extensions/ms-vscode.vscode-typescript-next-3.8.20200119/node_modules/typescript/lib/tsserver.js:118226:61)
        at tryGetSourcePosition (/home/martin/.vscode/extensions/ms-vscode.vscode-typescript-next-3.8.20200119/node_modules/typescript/lib/tsserver.js:118226:61)
        at tryGetSourcePosition (/home/martin/.vscode/extensions/ms-vscode.vscode-typescript-next-3.8.20200119/node_modules/typescript/lib/tsserver.js:118226:61)
        at tryGetSourcePosition (/home/martin/.vscode/extensions/ms-vscode.vscode-typescript-next-3.8.20200119/node_modules/typescript/lib/tsserver.js:118226:61)
        at tryGetSourcePosition (/home/martin/.vscode/extensions/ms-vscode.vscode-typescript-next-3.8.20200119/node_modules/typescript/lib/tsserver.js:118226:61)

TS version that was installed is ms-vscode.vscode-typescript-next-3.8.20200119

seritools commented 4 years ago

As far as I have seen, Go-to-Definition breaks as soon as ngcc adds stuff to the type definitions, either on-demand with ng build/ng serve, or precompiled via something like ngcc --properties es2015 browser module main --first-only --create-ivy-entry-points.

RyanCavanaugh commented 4 years ago

It would be fantastic to get a repro that doesn't involve the Angular LS since that component is a common source of breaks. Otherwise we can look at this later on.