尽管使用ECMAScript 6,却打字稿找不到名字'Promise' [英] Typescript cannot find name 'Promise' despite using ECMAScript 6

查看:146
本文介绍了尽管使用ECMAScript 6,却打字稿找不到名字'Promise'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在尝试在Visual Studio 2015中开发一个node.js应用程序,它一直告诉我

I am currently trying to develop a node.js application in Visual Studio 2015 and it keeps telling me


TS2304无法找到名称'承诺'

TS2304 Cannot find the name 'Promise'

在项目设置中,我将ECMAScript 6配置为构建系统,ES 2015配置为模块系统。

In the project settings I have ECMAScript 6 configured as build system and ES 2015 as module system.

我已经尝试了

如何使用带有本机ES6承诺的Typescript

没有成功,但在第二个链接中他们说它应该与ECMAScript版本设置为6,但是它对我没有任何改变。

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.

编辑:我现在做了更多的诊断。问题似乎是IntelliSense使用的ECMAScript版本与构建系统之间存在不匹配。

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.

我通过使用更多ECMAScript 6函数发现了这一点,导致了以下IntelliSense投诉:

I discovered this by using more ECMAScript 6 functions, which resulted in the following IntelliSense complaint:


TS1311异步功能仅在定位ECMAScript 6及更高版本时可用。

TS1311 Async functions are only available when targeting ECMAScript 6 and higher.

所以新问题:我在哪里设置IntelliSense使用的ECMAScript版本?

So the new question: Where do I set the ECMAScript version that IntelliSense uses?

推荐答案

这似乎是一种疏忽(我有同样的问题)。如果您安装类型定义,您可以轻松解决问题a> .d.ts files。

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.

如果您使用的是Nuget,只需从Package Manager控制台安装即可:

If you are using Nuget, just install from the Package Manager console with:

PM> Install-Package es6-promise.TypeScript.DefinitelyTyped

这篇关于尽管使用ECMAScript 6,却打字稿找不到名字'Promise'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆