OS 和 VSCode 版本
- VSCode 版本:1.41.1
- OS 版本:Ubuntu Mate 18.04
- 测试过的 Typescript 版本:3.6.4(来自 node_modules 的版本),3.7.3(在 VSCode 中使用的当前版本),ms-vscode.vscode-typescript-next-3.8.20200119(使用 VSCode 插件)
- Angular 版本:9.0.0-rc.9
问题描述(在下面的评论中更新了发现的问题)
当尝试查找位于 node_modules 中的 Angular 类的定义时,Go To Definition 功能无法正常工作。但是,只需将鼠标悬停在该类(或函数)定义上即可,上下文弹出窗口将显示。此外,如果导航到项目源文件内的类(而不是 node_modules 内),也同样可以正常工作。当查找非 Angular 库(例如 rxjs)的定义时,Go To Definition 也可以正常工作。
重现步骤:
- 导入或创建一个使用 RC 版本 9.0.0-rc.9 的 Angular 项目并安装 node_modules
- 创建一个组件,如下所示:
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() {}
}
- 在
ctrl + mouse click
类上尝试OnInit
。日志文件中会抛出以下错误:
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]
当禁用所有扩展时,此问题是否仍然存在?:是/否
是
8条答案
按热度按时间ekqde3dh1#
问题更新:
尝试使用相同的组件,但现在添加了rxjs库:
Subject
有效,但OnInit
仍然无法正常工作。这是否可能与导入路径中的@
有关?或者是与Angular本身有关?dojqjjoe2#
第三次更新:
删除node_modules文件夹并再次执行
npm i
已暂时解决问题。但是为什么?6yt4nkrj3#
更新四:
现在又发生了同样的问题,
RangeError: Maximum call stack size exceeded
错误。幕后的一些东西正在恶化。如果需要,我可以提供迄今为止收集的所有日志。xiozqbni4#
相似的调用栈到 #35515
@martinreus 你能尝试升级你的工作区,使用
typescript@next
吗?通过安装 this extension 来实现。这能解决这个问题吗?svujldwt5#
看起来像 #35014 。尽管标题具有误导性,但原因应该是相同的。
a0zr77ik6#
感谢您的回答,为问题起了一个不太恰当的标题;它确实看起来与 #35014 非常相似,我在这里使用的是 Angular 的
@next
版本 9.0.0-rc.9(默认启用了 Ivy - 不确定是否是因为 Ivy,只是让您知道)。不幸的是,更改 TS 版本并没有帮助,正如您从日志文件中看到的那样:
安装的 TS 版本是
ms-vscode.vscode-typescript-next-3.8.20200119
hkmswyz67#
就我所见,一旦
ngcc
向类型定义中添加内容,Go-to-Definition就会中断,无论是通过ng build
/ng serve
按需加载,还是通过类似ngcc --properties es2015 browser module main --first-only --create-ivy-entry-points
的预编译方式。pbwdgjma8#
如果能得到一个不涉及Angular LS的复制品,那就太棒了,因为该组件是破坏的常见来源。否则我们可以稍后再看这个问题。