私はangle-cliを使って私のプロジェクトを生成しました。そのバージョンは1.0.0-beta.28.3
です。
私はターミナルでコマンドng lint
を書いて、大きな量のエラーを取得:宣言の前に変数を使用しました
私はng lint
を実行した後、このような量のエラーが出る理由を任意のアイデアを持っていません。 machines.component.ts
のコードの下
:
プロジェクトは、私がtslint.json
内の任意のプロパティを変更していない生成された
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});
}
);
}
}
。デフォルト値は"no-use-before-declare": true
です。
GithubとStackoverflowで回答を検索しましたが、見つかりませんでした。おそらく、これまでに見つからなかった場合、私はそれをひどく探しました。
お願いします。
宣言される前に
let
とconst
変数が使用されている場合、コンパイラは検出されますがng-cliの最新の安定版、およびそれに付属するtslintのバージョンに変更します。時代遅れのベータ版を使用して以来、もたらされたバグや改善点はおそらくたくさんあります。 –私は 'angular-cli'を更新しました。 –