无法解析使用@Injectable 和@Inject 固定的所有参数?

Can't resolve all parameters fixed using @Injectable AND @Inject?

我一直在慢慢升级到 Angular 5。但是,几天前我开始从我的 ApiService 中看到这个错误: can't resolve all parameters for ApiService(?)

这仅在我添加新组件后才开始发生(none 其中实际使用了相关服务)。在此之前,ApiService 工作得很好。我的 ApiService 看起来像这样:

import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
...
@Injectable()
export class ApiService {
    constructor(private http: HttpClient)
}
... 

我的 tsconfig.json 已经将 'emitDecoratorMetadata' 设置为 true。我的 app.module.ts 将 ApiService 作为提供者并正确导入。

但是,如果我同时使用 @Injectable 和 @Inject 那么它会更快乐并且可以正确编译(我这样做是为了测试它为什么会崩溃;我知道这是你不需要做的事情).

还有其他我可能忘记的配置吗?到目前为止我找到的大多数答案都说包括 @Injectable() include、emitDecoratorMetadata,或者将服务作为 app.module.ts 提供程序的一部分,所有这些我都已经完成了。同样,在我开始添加更多组件之前,ApiService 一直在运行。

我正在使用 webpack-dev-server 运行 我的服务器。如果我使用 'ng serve' 它工作得很好,这让我相信我配置 webpack-dev-server 的方式可能有问题?最近是否有更新可能需要我稍微更改配置?

感谢您的建议和帮助!

啊哈!

看来我只需要添加

import 'core-js/es6/reflect';
import 'core-js/es7/reflect';

给我的 polyfills.ts。这似乎是升级到 Angular5 所特有的问题。我希望这能帮助遇到类似问题的其他人!