英文:
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"。
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论