将 easeljs 与打字稿一起使用:错误 TS2304:找不到名称 'EventDispatcher'
Using easeljs with typescript: error TS2304: Cannot find name 'EventDispatcher'
我正在尝试将 easeljs 与打字稿一起使用
我已经设置了打字稿,并通过以下方式安装了打字:
$ 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
无济于事。
调用 tsc
后,.js 文件似乎已正确生成(我可以看到圆圈),但错误似乎表明我做错了什么。知道它是什么吗?
免责声明:之前从未使用过 javascript/typescript,所以它可能是微不足道的。
Typings 默认情况下不会为 ambient 安装依赖项,因为它们会导致模块依赖项问题(例如菱形问题)。
但是它确实会告诉您可能需要哪些:
你想通了 tweenj.d.ts
。您还需要 createjs-lib
正如所指出的那样
我正在尝试将 easeljs 与打字稿一起使用
我已经设置了打字稿,并通过以下方式安装了打字:
$ 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
无济于事。
调用 tsc
后,.js 文件似乎已正确生成(我可以看到圆圈),但错误似乎表明我做错了什么。知道它是什么吗?
免责声明:之前从未使用过 javascript/typescript,所以它可能是微不足道的。
Typings 默认情况下不会为 ambient 安装依赖项,因为它们会导致模块依赖项问题(例如菱形问题)。
但是它确实会告诉您可能需要哪些:
你想通了 tweenj.d.ts
。您还需要 createjs-lib
正如所指出的那样