问题
I am currently trying to develop a node.js application in Visual Studio 2015 and it keeps telling me
TS2304 Cannot find the name 'Promise'
In the project settings I have ECMAScript 6 configured as build system and ES 2015 as module system.
I already tried
how to use es6-promises with typescript?
How to use Typescript with native ES6 Promises
without success, but in the second link they say that it should work with ECMAScript version set to 6, but it changes nothing for me.
EDIT: I now did some more diagnosing. The problem seems to be that there is a mismatch between the ECMAScript Versions used by IntelliSense and the build system.
I discovered this by using more ECMAScript 6 functions, which resulted in the following IntelliSense complaint:
TS1311 Async functions are only available when targeting ECMAScript 6 and higher.
So the new question: Where do I set the ECMAScript version that IntelliSense uses?
回答1:
This seems to be an oversight (I had the same issue). You can easily make the problem go away if you install the type definition .d.ts
files.
If you are using Nuget, just install from the Package Manager console with:
PM> Install-Package es6-promise.TypeScript.DefinitelyTyped
来源:https://stackoverflow.com/questions/35972037/typescript-cannot-find-name-promise-despite-using-ecmascript-6