[Typescript] Installing Promise Type Definitions Using the lib Built-In Types

To fix Promise is not recolized in TypeScript, we can choose to use a lib:

npm i @types/es6-promise

we can also use built-in libs:

{
    "compilerOptions": {
        "module": "commonjs",
        "target": "es5",
        "noImplicitAny": true,
        "sourceMap": true,
        "strictNullChecks": true,
        "noEmitOnError": true,
        "experimentalDecorators": true,
        "emitDecoratorMetadata": true,
        "lib": ["es6"],
        "skipLibCheck": true
    },
    "exclude": [
      "client/node_modules"
    ]
}

Inside "es6" have Promise already, so that we don't need to install other devdependices.

原文地址:https://www.cnblogs.com/Answer1215/p/8408483.html