我使用angular-cli生成我的项目,版本为1.0.0-beta.28.3
。
我在终端编写命令ng lint
,并得到大量的错误:声明前使用的变量
我没有为什么我得到运行ng lint
后该金额的错误任何想法。
下面的代码machines.component.ts
:
import { Component, OnDestroy, OnInit } from '@angular/core';
import { Response } from '@angular/http';
import { Observable } from 'rxjs/Observable';
import { DialogService } from 'ng2-bootstrap-modal';
import { ModalComponent } from '../modal/modal.component';
import { MachineService } from '../services/machine.service';
import { Machine } from '../models/machine.model';
import { BoxService } from '../services/box.service';
import { Box } from '../models/box.model';
import { AppConfig } from '../app.config';
@Component({
selector: 'app-machines',
templateUrl: './machines.component.html',
styleUrls: ['./machines.component.scss']
})
export class MachinesComponent implements OnInit, OnDestroy {
private display: boolean;
private alive: boolean;
private timer: Observable<number>;
machines: Machine [];
box: Box;
constructor(
private dialogService: DialogService,
private boxService: BoxService,
private machineService: MachineService,
private appConfig: AppConfig) {
this.display = false;
this.alive = true;
this.timer = Observable.timer(0, this.appConfig.interval_requests);
}
ngOnInit() {
this.timer
.takeWhile(() => this.alive)
.subscribe(() => {
this.machineService.getStatesMachines().subscribe(
(res: Response) => {
this.machines = res.json();
if (!this.display) {
this.display = true;
}
}
);
}
);
}
ngOnDestroy() {
this.alive = false;
}
getBox(device_name: string) {
this.boxService.getBox(device_name).subscribe(
(res: Response) => {
const box = res.json();
this.box = box;
this.dialogService.addDialog(ModalComponent, {
device_name: this.box.device_name + '`s info',
name: this.box.name,
timestamp: this.box.timestamp,
ip_address: this.box.ip_address
}, {closeByClickingOutside: true});
}
);
}
}
当生成项目,我并没有改变tslint.json
任何属性。默认,"no-use-before-declare": true
。
我在Github和Stackoverflow搜索了答案,但没有找到。也许,如果到目前为止没有找到,我就会严重地搜查它。
请帮帮我。
你为什么不通过升级开始之前到ng-cli的最新稳定版本以及随附的tslint版本。自从您使用的过时beta版本以来,可能会出现很多错误和改进。 –
我更新了'angular-cli'。 –