Angular compilation error : TS2585 Build:'Promise' only refers to a type, but is being used as a value here. Do you need to change your target library

huangapple go评论70阅读模式
英文:

Angular compilation error : TS2585 Build:'Promise' only refers to a type, but is being used as a value here. Do you need to change your target library

问题

我正在使用Visual Studio 2022开发一个Angular项目。当我将fileUpload.ts文件包含在项目中时,项目开始出现编译错误,不再正常工作。我需要帮助,项目不再能够编译。

错误: 错误 TS2585 生成: 'Promise'仅用作类型,但在此处被用作值。您是否需要更改目标库?尝试将'lib'编译选项更改为es2015或更高版本。

错误 NG6001: 'FileUpload'类被列在NgModule 'AppModule'的声明中,但它既不是指令、组件,也不是管道。要么从NgModule的声明中移除它,要么添加一个适当的Angular装饰器。

我正在使用Angular 14。

当我移除项目文件时,项目又能正常工作。

英文:

I'm working on an Angular project using Visual Studio 2022. When I included a fileUpload.ts file in the project, it started giving a compilation error in the project and it doesn't work anymore. I need help, the project no longer compiles.

Error: Error TS2585 Build:'Promise' only refers to a type, but is being used as a value here. Do you need to change your target library? Try changing the 'lib' compiler option to es2015 or later.

error NG6001: The class 'FileUpload' is listed in the declarations of the NgModule 'AppModule', but is not a directive, a component, or a pipe. Either remove it from the NgModule's declarations, or add an appropriate Angular decorator.

I'm using Angular 14

When I remove the project file it works again.

答案1

得分: 1

这个错误是因为在通过Visual Studio添加文件时,它被标记为要编译。要解决这个问题,只需将构建操作设置为"None"

英文:

This error occurs because when adding the file through Visual Studio it is marked to be compiled. To solve just put the biuld action as "None"

Angular compilation error : TS2585 Build:'Promise' only refers to a type, but is being used as a value here. Do you need to change your target library

huangapple
  • 本文由 发表于 2023年1月9日 19:00:40
  • 转载请务必保留本文链接:https://go.coder-hub.com/75056325.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定