【TS】使用Promise报错

IDE

webstorm

报错提示

error TS2693: 'Promise' only refers to a type, but is being used as a value here.

解决方法:

  1. npm i --save-dev @types/es6-promise
  2. /node_modules/vue-template-compiler/types/tsconfig.json
{
    "compilerOptions": {
        "target": "es5",
        "module": "commonjs",
        "declaration": false,
        "noImplicitAny": false,
        "noLib": false,
        "moduleResolution": "node",
        "strict": true,
        "noEmit": true,
        "lib": [
            "ES5",
            "ES2015",
            "DOM",
            "ScriptHost"
        ]
    },
    "filesGlob": [
        "./**/*.ts",
        "!./node_modules/**/*.ts"
    ],
    "files": [
        "./main.ts",
        "./typings/es6-promise/es6-promise.d.ts"
    ],
    "compileOnSave": false,
    "include": [
        "**/*.ts"
    ]
}

你可能感兴趣的:(【TS】使用Promise报错)