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,
I had this error but I resolved it by using this command, my ts file name is promises-fs.ts:
tsc promises-fs.ts --target es6 && node promises-fs.js
and the error is gone
I had the same error and I fixed it with this configuration:
File: tsconfig.json
{
"compilerOptions": {
"target": "es2015",
"module": "commonjs",
"strict": true,
"esModuleInterop": true
}
}
Having spent lot of time trying to fix this. I had no luck with any solution provide here or elsewhere.
But then later realised it wasn't so much as just solving the issue. But you also need to RESTART the VSCODE for it to take affect.
The same error here. I fixed this, using "module": "ES6" in tsconfig.
Encounter the same error today and solved it with:
npm i --save-dev @types/es6-promise
Update:
add:
import {Promise} from 'es6-promise'
Finally tsc started working without any errors. But multiple changes. Thanks to Sandro Keil, Pointy & unional
tsconfig.json
{
"compileOnSave": true,
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"noImplicitAny": false,
"strictNullChecks": true,
"alwaysStrict": true,
"preserveConstEnums": true,
"sourceMap": false,
"moduleResolution": "Node",
"lib": [
"dom",
"es2015",
"es5",
"es6"
]
},
"include": [
"*",
"src/**/*"
],
"exclude": [
"./node_modules"
]
}
Gruntfile.js
ts: {
app: {
tsconfig: {
tsconfig: "./tsconfig.json"
}
},
...