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,
Add below line to file where error is being thrown.This should fix the issue
declare var Promise: any;
P.S: This is definitely not the optimal solution
Core-js did not work for me as it caused other issues, however, simply installing the latest version of npm i @types/es6-promise --save-dev
got rid of the issues. The issues for me stemmed from compiling an sdk that was using rxjs. Here is the error I was getting:
`node_modules/rxjs/Observable.d.ts(59,60): error TS2693: Promise only refers to a type, but is being used as a value here.`
Please be aware that if you are running the tsc command with a file name ie:
tsc testfile.ts
then the tsconfig.json compiler configuration file is ignored. The solution is to run either the tsc command on its own, in which case all .ts files in the directory will be compiled, unless you have edited the tsconfig.json to include a set of files.
see 'using the files property'... https://www.typescriptlang.org/docs/handbook/tsconfig-json.html
Solved by changing the target in compilerOptions.
{
"compilerOptions": {
"module": "es2015",
"target": "es2015",
"lib": [
"es2016",
"dom"
],
"moduleResolution": "node",
"noImplicitAny": false,
"sourceMap": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"outDir": "./public/js/app"
},
"exclude": [
"node_modules",
"public/js",
"assets/app/polyfills.ts"
],
"angularCompilerOptions": {
"skipMetadataEmit": true
}
}