2017-08-29 19 views
0

私はangle-cliを使って私のプロジェクトを生成しました。そのバージョンは1.0.0-beta.28.3です。
私はターミナルでコマンドng lintを書いて、大きな量のエラーを取得:宣言の前に変数を使用しました

enter image description here

私は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で回答を検索しましたが、見つかりませんでした。おそらく、これまでに見つからなかった場合、私はそれをひどく探しました。
お願いします。

+3

宣言される前にletconst変数が使用されている場合、コンパイラは検出されますがng-cliの最新の安定版、およびそれに付属するtslintのバージョンに変更します。時代遅れのベータ版を使用して以来、もたらされたバグや改善点はおそらくたくさんあります。 –

+0

私は 'angular-cli'を更新しました。 –

答えて

3

あなたは"no-use-before-declare": false

varキーワードを使用している場合、このルールは主に便利です設定することができます - それはあなたがアップグレードすることによって起動しないのはなぜ

+0

私は '' no-use-before-declare ':false'を設定したいと思っていましたが、最後に、 '' angle-cli''を更新している方が良い能力を決めました。 –

関連する問題