尽管使用es6-promise.d.ts仍找不到名称“ Promise” [英] Cannot find name 'Promise' despite using es6-promise.d.ts

查看:202
本文介绍了尽管使用es6-promise.d.ts仍找不到名称“ Promise”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将systemjs.d.ts文件添加到WebStorm IDE中的项目中。该文件包括Promise类的两种用法,被TSC标记为错误。这非常奇怪,因为我已经将es6-promise.d.ts文件添加到了我的项目中,并且确实为mongodb.d.ts文件解决了相同的问题。那么,为什么在一个文件中可以识别它,而在另一个文件中却不能识别呢?所有.d.ts文件都位于同一文件夹(root-folder\DefinitelyTyped)中。



我得到的错误:


TS2304:找不到名称'Promise'


systemjs.d.ts :
https://raw.githubusercontent.com/

任何帮助将不胜感激!

我解决了。我忘了添加参考注释。



在文件开头添加以下行即可解决问题:

  ///<参考路径='es6-promise.d.ts'/> 


I added the systemjs.d.ts file to my project in WebStorm IDE. This file includes two uses of the class Promise, which are marked as errors by TSC. This is extremely weird because I've already added the es6-promise.d.ts file to my project, and it does solve the same problem for the mongodb.d.ts file. So why in one file it's recognized and in the other it's not? All the .d.ts files are located in the same foler (root-folder\DefinitelyTyped).

The errors I get:

TS2304: Cannot find name 'Promise'

systemjs.d.ts: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/systemjs/systemjs.d.ts

Any help will be profoundly appreciated!

解决方案

I solved it. I forgot to add a reference comment.

Adding the following line to the beginning of the file solved the problem:

/// <reference path='es6-promise.d.ts' />

这篇关于尽管使用es6-promise.d.ts仍找不到名称“ Promise”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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