简体   繁体   English

尝试迁移到 Angular 9 时出错:使用 DI 迁移的未修饰类

[英]Getting error while trying to migrate to Angular 9 : Undecorated classes with DI migration

I am trying to migrate from Angular 8 to Angular 9 and getting below error on step: Undecorated classes with DI migration.我正在尝试从 Angular 8 迁移到 Angular 9 并在步骤中遇到以下错误:使用 DI 迁移的未修饰类。

Could not migrate all undecorated classes that use dependency injection.无法迁移所有使用依赖注入的未修饰类。 Some project targets could not be analyzed due to TypeScript program failures.由于 TypeScript 程序失败,无法分析某些项目目标。

Error: error TS100: src\\app\\app.module.ts(107,25): Error during template compile of 'AppModule' Function calls are not supported in decorators but 'combineReducers' was called in 'appReducers' 'appReducers' references 'modelReducer' at src\\app\\store\\reducers\\index.ts(13,10) 'modelReducer' calls 'combineReducers' at src\\app\\store\\reducers\\model.ts(25,29).错误:错误 TS100: src\\app\\app.module.ts(107,25): 'AppModule' 模板编译期间出错装饰器不支持函数调用,但在 'appReducers' 'appReducers' 引用中调用了 'combineReducers' src\\app\\store\\reducers\\index.ts(13,10) 处的modelReducer' 'modelReducer' 调用src\\app\\store\\reducers\\model.ts(25,29) 处的'combineReducers'。

Any idea why I am getting this error?知道为什么我会收到此错误吗?

You more than likely need to decorate any classes that are using DI with @Injectable()您很可能需要用@Injectable()装饰任何使用 DI 的类

ex:前任:

@Injectable()
class MyClass {
  constructor(someService: SomeService) {...}
}

I personally am holding off on working with 9 until it's GA (due to previous experiences with major releases).我个人推迟使用 9,直到它成为 GA(由于以前的主要版本经验)。 But, "DI" and "undecorated classes" screams "you're missing the Injectable decorator" to me.但是,“DI”和“未修饰的类”对我来说“你缺少可注入的装饰器”。

Are you going from 8.x to 9?你是从 8.x 升级到 9 吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM