I am trying to use Typescript for my AWS Lambda and i am getting the following errors where ever I use promises.
error TS2693: 'Promise' only refers to a type, but is being used as a value here.
I tried using the following variations in the code
Using the Promise constructor
responsePromise = new Promise((resolve, reject) => {
                    return reject(new Error(`missing is needed data`))
                })
using Promise.reject
responsePromise = Promise.reject(new Error(`Unsupported method "${request.httpMethod}"`));
Following are the versions in my dev dependencies:
"typescript": "^2.2.2"
"@types/aws-lambda": "0.0.9",
"@types/core-js": "^0.9.40",
"@types/node": "^7.0.12",
{
    "compileOnSave": true,
    "compilerOptions": {
        "module": "commonjs",
        // "typeRoots" : ["./typings", "./node_modules/@types"],
        "target": "es5",
        // "types" : [ "core-js" ],
        "noImplicitAny": true,
        "strictNullChecks": true,
        "allowJs": true,
        "noEmit": true,
        "alwaysStrict": true,
        "preserveConstEnums": true,
        "sourceMap": true,
        "outDir": "dist",
        "moduleResolution": "Node",
        "declaration": true,
        "lib": [
            "es6"
        ]
    },
    "include": [
        "index.ts",
        "lib/**/*.ts"
    ],
    "exclude": [
        "node_modules",
        "**/*.spec.ts"
    ]
}
I am using grunt-ts with the following configuration for running ts task.
ts: {
            app: {
                tsconfig: {
                    tsconfig: "./tsconfig.json",
                    ignoreSettings: true
                }
            },
...
I tried with the solution mentioned in I get: [ts] 'Promise' only refers to a type, but is being used as a value here but no luck.
The 'instanceof' error "only refers to a type, but is being used as a value here" occurs when we try to use the instanceof operator with a type instead of a value. To solve the error, create a class instead, or simply use a user-defined type guard.
I had the same issue with the aws-sdk and I solved it by using "target": "es2015". This is my tsconfig.json file.
{
    "compilerOptions": {
        "outDir": "./dist/",
        "sourceMap": false,
        "noImplicitAny": false,
        "module": "commonjs",
        "target": "es2015"
    },
    "include": [
        "src/**/*"
    ],
    "exclude": [
        "node_modules",
        "**/*.spec.ts"
    ]
}
Encounter the same error today and solved it with:
npm i --save-dev  @types/es6-promise
Update:
add:
import {Promise} from 'es6-promise'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With