TS2585: 'Promise' only refers to a type, but is being used as a value here
Just install @types/node from npm. This should solve the problem.
npm install @types/node
In my case I simply added a tsconfig.json
file with the following contents where the significant part relating to the above error is "target": "es2015"
:
{
"compilerOptions": {
"noImplicitAny": false,
"noEmitOnError": true,
"removeComments": false,
"sourceMap": true,
"target": "es2015"
},
"include": [
"file.ts"
],
"exclude": [
"node_modules",
"wwwroot"
]
}
Problem
TypeScript has two modes.
- A project-builder mode (when
tsc
is invoked with no arguments) - A compile-mode (when
tsc
is invoked with any arguments) which does not read from the configuration filetsconfig.json
If that sounds confusing, it's even more confusing when you account for
- the flag for the compiler-mode to accept a configuration file is called
--project
- inside the project-builder's configuration file there the pragma is called "compilerOptions"
- the compiler-mode and the project-builder mode accept the same configuration file
Anyway, the problem here was that TypeScript was simply ignoring the configuration file in the current working directory that I was running it in.
If you want to see this changed vote here,
- https://twitter.com/TheEvanCarroll/status/1080899909522477061
This is further reported here,
- https://github.com/Microsoft/TypeScript/issues/29241