Cannot find namespace NodeJS when using NodeJS.Timer in Ionic 2

后端 未结 3 1290
说谎
说谎 2020-12-17 08:03

I am attempting to use some code I found on https://github.com/bevacqua/dragula/issues/289#issuecomment-277143172 to my Ionic project.

When I run the code I get an

相关标签:
3条回答
  • 2020-12-17 08:19

    Open src/tsconfig.app.json*.

    Add "node" to the "types" array.

    Example:

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

    *if this file does not exist add the specified part to tsconfig.json in root folder.

    0 讨论(0)
  • 2020-12-17 08:24

    A quick way to solve this problem is here.

    Basically change setTimeout and clearInterval to window.setTimeout and window.clearInterval, respectively. For example, your onDown becomes:

    onDown(e: Event) {
        this.touchTimeout = window.setTimeout(() => {
            this.draggable = true;
        }, this.dragDelay);
    }
    

    Then, your declaration becomes:

    this.touchTimeout: number | undefined;
    
    0 讨论(0)
  • 2020-12-17 08:26

    To me, solve include the typeRoots member in compilerOptions from tsconfig.json

    {
      "extends": "../tsconfig.json",
      "compilerOptions": {
        "outDir": "../out-tsc/app",
        "baseUrl": "./",
        "module": "es2015",
        "typeRoots": [
             "node_modules/@types"
         ]
      },
      "exclude": [
        "test.ts",
        "**/*.spec.ts"
      ]
    }
    
    0 讨论(0)
提交回复
热议问题