TsLint:'$ http'不能在构造函数中声明

dav*_*d.s 6 typescript tslint

正如标题所述,我得到以下TSLint错误:

'$ http'无法在构造函数中声明

我在互联网上找不到任何与此错误相关的内容.

这是我的代码:

module MyModule {
    "use strict";

    class MyService {
        static $inject = ["$http"];
        constructor(private $http: ng.IHttpService) {
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

dav*_*d.s 10

正如我发布的问题,我意识到我需要检查我的tslint.json文件,我发现了这个:

"no-constructor-vars": true,
Run Code Online (Sandbox Code Playgroud)

显然,这是在tslint的github页面记录的:

no-constructor-vars 不允许使用构造函数参数的public和private修饰符.

所以解决方案就是禁用no-constructor-vars:

 "no-constructor-vars": false,
Run Code Online (Sandbox Code Playgroud)