使用带有typescript的easeljs:错误TS2304:找不到名称' EventDispatcher'

时间:2016-03-02 22:09:24

标签: typescript easeljs

我试图将easeljs与typescript一起使用

我已经设置了打字稿,并按照以下方式安装了打字:

function executeTransaction() {
        tNG_log::log('tNG' . $this->transactionType, 'executeTransaction', 'begin');
        if ($this->started) {
            tNG_log::log('tNG' . $this->transactionType, 'executeTransaction', 'end');
            return false;
        }

我有一个名为$ typings install easeljs --ambient 的文件:

canvas.ts

致电/// <reference path="browser/main.d.ts" /> var canv = < HTMLCanvasElement > document.createElement("canvas"); canv.width = 800; canv.height = 600; canv.style.border = "5px solid silver"; var stage = new createjs.Stage(canv); var circle = new createjs.Shape(); circle.graphics.beginFill("DeepSkyBlue").drawCircle(0, 0, 50); circle.x = 100; circle.y = 100; stage.addChild(circle); stage.update(); document.body.appendChild(canv); 我得到:

tsc canvas.ts

如果我执行typings/main/ambient/easeljs/easeljs.d.ts(187,40): error TS2304: Cannot find name 'EventDispatcher'. typings/main/ambient/easeljs/easeljs.d.ts(657,19): error TS2304: Cannot find name 'Timeline'. typings/main/ambient/easeljs/easeljs.d.ts(679,22): error TS2304: Cannot find name 'Tween'. typings/main/ambient/easeljs/easeljs.d.ts(797,38): error TS2304: Cannot find name 'EventDispatcher'. typings/main/ambient/easeljs/easeljs.d.ts(818,45): error TS2304: Cannot find name 'EventDispatcher'. ,则仅保留有关typings install tweenjs --ambient的消息。使用打字安装EventDispatcher不会有帮助。

调用createjs后,.js文件似乎正确生成(我可以看到圆圈),但错误似乎表明我做错了。有什么想法吗?

免责声明:之前从未使用过javascript /打字稿,所以它可能是微不足道的。

1 个答案:

答案 0 :(得分:4)

默认情况下,Typings不会为 ambient 东西安装依赖项,因为它们会导致模块依赖性问题(例如钻石问题)。

但它会告诉您可能需要哪些:

enter image description here

你想出了tweenj.d.ts。您还需要createjs-lib指出