typescript 类型错误:无法在 getAssignmentTargetKind 读取未定义的属性“种类”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/53827570/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 05:44:38  来源:igfitidea点击:

TypeError: Cannot read property 'kind' of undefined at getAssignmentTargetKind

angulartypescriptangular-cliangular-cli-v7

提问by rawk

This problem started to occur when updating my Angular 6 project to 7.x.

将我的 Angular 6 项目更新到 7.x 时开始出现此问题。

I opened an issue on the angular-cli github repo but they couldn't help.

我在 angular-cli github repo 上打开了一个问题,但他们无能为力。

So what I did is create a new project and add all components one by one to "hopefully" notice what caused the problem.

所以我所做的是创建一个新项目并一个一个添加所有组件,以“希望”注意到导致问题的原因。

Unfortunately I couldn't identify the problem. Here's the log:

不幸的是,我无法确定问题所在。这是日志:

ERROR in : TypeError: Cannot read property 'kind' of undefined
at getAssignmentTargetKind (E:\McClient\node_modules\typescript\lib\typescript.js:10049:28)
at Object.isAssignmentTarget (E:\McClient\node_modules\typescript\lib\typescript.js:10092:16)
at checkObjectLiteral (E:\McClient\node_modules\typescript\lib\typescript.js:46107:45)
at checkExpressionWorker (E:\McClient\node_modules\typescript\lib\typescript.js:50748:28)
at checkExpression (E:\McClient\node_modules\typescript\lib\typescript.js:50696:42)
at checkExpressionWithContextualType (E:\McClient\node_modules\typescript\lib\typescript.js:50524:26)
at checkApplicableSignature (E:\McClient\node_modules\typescript\lib\typescript.js:47963:35)
at chooseOverload (E:\McClient\node_modules\typescript\lib\typescript.js:48281:26)
at resolveCall (E:\McClient\node_modules\typescript\lib\typescript.js:48231:26)
at resolveCallExpression (E:\McClient\node_modules\typescript\lib\typescript.js:48534:20)
at resolveSignature (E:\McClient\node_modules\typescript\lib\typescript.js:48800:28)
at getResolvedSignature (E:\McClient\node_modules\typescript\lib\typescript.js:48844:26)
at checkCallExpression (E:\McClient\node_modules\typescript\lib\typescript.js:48936:29)
at checkExpressionWorker (E:\McClient\node_modules\typescript\lib\typescript.js:50759:28)
at checkExpression (E:\McClient\node_modules\typescript\lib\typescript.js:50696:42)
at resolveDecorator (E:\McClient\node_modules\typescript\lib\typescript.js:48741:28)

Here's a link to the github issue with logs from a checkSourcefile function I was supposed to log:

这是 github 问题的链接,其中包含我应该记录的 checkSourcefile 函数的日志:

https://github.com/angular/angular-cli/issues/13172

https://github.com/angular/angular-cli/issues/13172

How can I track down and (hopefully) fix what's causing this?

我如何追踪并(希望)解决导致此问题的原因?

Edit: My ng --version info

编辑:我的 ng --version 信息

Angular CLI: 7.1.3
Node: 8.11.4
OS: win32 x64
Angular: 7.1.3
... animations, cli, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.11.3
@angular-devkit/build-angular     0.11.3
@angular-devkit/build-optimizer   0.11.3
@angular-devkit/build-webpack     0.11.3
@angular-devkit/core              7.1.3
@angular-devkit/schematics        7.1.3
@angular/cdk                      7.1.1
@ngtools/webpack                  7.1.3
@schematics/angular               7.1.3
@schematics/update                0.11.3
rxjs                              6.3.3
typescript                        3.1.6
webpack                           4.23.1

回答by David Njuguna

I simply re-run

我只是重新运行

    ng serve

again and it worked!

又一次成功了!

回答by Franklin Pious

Run the application again usingng serveand it fixed the issue for me. It happened when I pulled code from a branch to my existing running branch which was running via ng serve.

使用再次运行应用程序ng serve,它为我解决了问题。当我将代码从一个分支拉到我通过 ng serve 运行的现有运行分支时,发生了这种情况。

回答by Bert

I also had this problem. I solved it by updating my local @angular/cli to the same version as the @anguluar/cli version in my project .

我也有这个问题。我通过将我的本地 @angular/cli 更新为与我的项目中的 @anguluar/cli 版本相同的版本来解决它。

回答by Lastsword

I struggled with the same problem, did some digging and found 2 major solutions:

我遇到了同样的问题,做了一些挖掘并找到了两个主要的解决方案:

  1. Installing '@types/history' package.
  2. Downgrading typescript to 3.1.6(since the bug wasn't occurring then).
  1. 安装“@types/history”包。
  2. 将打字稿降级到 3.1.6(因为当时没有发生错误)。

See this GitHub issue here.

在此处查看此 GitHub 问题。

回答by Nanda Kishore Allu

  • I was having issue with while migrating ionic application from V4 to V5.
  • This is my error log image.
  • 我在将离子应用程序从 V4 迁移到 V5 时遇到了问题。
  • 这是我的错误日志图像。

enter image description here

在此处输入图片说明

  • It was fixed with the below solution.
  • 它已通过以下解决方案修复。

https://github.com/ckeditor/ckeditor4-angular/issues/78#issuecomment-565803253

https://github.com/ckeditor/ckeditor4-angular/issues/78#issuecomment-565803253

回答by Omkar Joshi

This Problem can be solved by restarting:

这个问题可以通过重启解决:

Use ng serve

使用ng 服务

回答by Mohamed Abo Elmagd

It solved from version

它从版本解决

npm i @angular-devkit/[email protected] -s

npm i @angular-devkit/[email protected] -s

check this https://www.npmjs.com/package/@angular-devkit/build-angular

检查这个https://www.npmjs.com/package/@angular-devkit/build-angular

回答by Luis Moreno

In my case the problem was that I had abstract classes with @Injectable, removing it solved the issue.

就我而言,问题是我有带有 @Injectable 的抽象类,删除它解决了这个问题。

Hopes it helps

希望有帮助