2017-07-25 20 views
3

https://github.com/bevacqua/dragula/issues/289#issuecomment-277143172で見つかったコードを自分のIonicプロジェクトに使用しようとしています。Ionic 2でNodeJS.Timerを使用しているときに名前空間NodeJSが見つかりません

私は、コードを実行すると、私はエラーCannot find namespace 'NodeJS'を取得し、エラーが私はNodeJS.Timerラインの仕事をするために以下のコードを適応させることができますどのようtouchTimeout: NodeJS.Timer;

を指し?

import { Directive, ElementRef, HostListener } from '@angular/core'; 

@Directive({ selector: '[delayDragLift]' }) 
export class DelayDragLiftDirective { 

    dragDelay: number = 200; // milliseconds 
    draggable: boolean = false; 
    touchTimeout: NodeJS.Timer; 

    @HostListener('touchmove', ['$event']) 
    // @HostListener('mousemove', ['$event']) 
    onMove(e: Event) { 
     if (!this.draggable) { 
      e.stopPropagation(); 
      clearTimeout(this.touchTimeout); 
     } 
    } 

    @HostListener('touchstart', ['$event']) 
    // @HostListener('mousedown', ['$event']) 
    onDown(e: Event) { 
     this.touchTimeout = setTimeout(() => { 
      this.draggable = true; 
     }, this.dragDelay); 
    } 

    @HostListener('touchend', ['$event']) 
    // @HostListener('mouseup', ['$event']) 
    onUp(e: Event) { 
     clearTimeout(this.touchTimeout); 
     this.draggable = false; 
    } 

    constructor(private el: ElementRef) { 
    } 
} 
+0

あなたはそれを解決しましたか? – Alberick0

答えて

1

公開src/tsconfig.app.json *。

"types"アレイに"node"を追加します。

例:

{ 
    "extends": "../tsconfig.json", 
    "compilerOptions": { 
    "outDir": "../out-tsc/app", 
    "baseUrl": "./", 
    "module": "es2015", 
    "types": [ 
     "node" 
    ] 
    }, 
    "exclude": [ 
    "test.ts", 
    "**/*.spec.ts" 
    ] 
} 

*このファイルは、ルートフォルダにtsconfig.jsonに指定された部分を追加存在しない場合。

関連する問題