Pedro Ferreira avatar Pedro Ferreira committed 9aef138

- fix Image to HTMLImageElement type
- change the type of methods/properties that can have more than 1 type to any
- add link to DefinitelyTyped repository

Comments (0)

Files changed (6)

easeljs-0.5.0.d.ts

 
 export class AlphaMapFilter extends Filter
     {
-    constructor( alphaMap: Image );    //HERE doesn't recognize Image type
+    constructor( alphaMap: HTMLImageElement );
     constructor( alphaMap: HTMLCanvasElement );
 
         // properties
-    alphaMap: Image;    //HERE can be also an HTMLCanvasElement.. can't overload properties
+    alphaMap: any;    // HTMLImageElement or HTMLCanvasElement --  can't overload properties
 
         // methods
     applyFilter( ctx: CanvasRenderingContext2D, x: number, y: number, width: number, height: number, targetCtx?: CanvasRenderingContext2D, targetX?: number, targetY?: number ): bool;
 
 export class AlphaMaskFilter extends Filter
     {
-    constructor( mask: Image );
+    constructor( mask: HTMLImageElement );
     constructor( mask: HTMLCanvasElement );
 
         // properties
-    mask: Image;    //HERE or HTMLCanvasElement
+    mask: any;    // HTMLImageElement or HTMLCanvasElement
 
         // methods
     applyFilter( ctx: CanvasRenderingContext2D, x: number, y: number, width: number, height: number, targetCtx?: CanvasRenderingContext2D, targetX?: number, targetY?: number ): bool;
 
 export class Bitmap extends DisplayObject
     {
-    constructor( imageOrUrl: Image );
+    constructor( imageOrUrl: HTMLImageElement );
     constructor( imageOrUrl: HTMLCanvasElement );
     constructor( imageOrUrl: HTMLVideoElement );
     constructor( imageOrUrl: string );
 
         // properties
-    image;  //HERE how to tell the various type possibilities?
+    image: any;  // HTMLImageElement or HTMLCanvasElement or HTMLVideoElement
     snapToPixel: bool;
     sourceRect: Rectangle;
 
 
         // methods
     addChild( ...child: DisplayObject[] ): DisplayObject;
-    addChildAt( ...child: DisplayObject[], index: number ): DisplayObject;  //HERE typescript doesnt like having an argument after the variable length argument
+    //addChildAt( ...child: DisplayObject[], index: number ): DisplayObject;  //HERE typescript doesnt like having an argument after the variable length argument
+    addChildAt( ...child:any[] ): DisplayObject;
+
     clone( recursive?: bool ): Container;
     contains( child: DisplayObject ): bool;
     draw( ctx: CanvasRenderingContext2D, ignoreCache: bool ): void;
     spriteSheet: SpriteSheet;
 
         // methods
-    addFrame( source: DisplayObject, sourceRect?: Rectangle, scale?: number, setupFunction?: () => any, setupParams?: any[], setupScope?: Object ): number; //HERE returns number or null
+    addFrame( source: DisplayObject, sourceRect?: Rectangle, scale?: number, setupFunction?: () => any, setupParams?: any[], setupScope?: Object ): any; //HERE returns number or null
     addMovieClip( source: MovieClip, sourceRect?: Rectangle, scale?: number ): void;
     build(): void;
     buildAsync( callback?: ( reference: SpriteSheetBuilder ) => any, timeSlice?: number ): void;
 export class SpriteSheetUtils
     {
     static addFlippedFrames(spriteSheet: SpriteSheet, horizontal?: bool, vertical?: bool, both?: bool ): void;
-    static extractFrame( spriteSheet: Image, frame: number ): Image;   //HERE
-    static flip( spriteSheet: Image, flipData: Object ): void;
-    static mergeAlpha( rgbImage: Image, alphaImage: Image, canvas?: HTMLCanvasElement ): HTMLCanvasElement;
+    static extractFrame( spriteSheet: HTMLImageElement, frame: number ): HTMLImageElement;
+    static flip( spriteSheet: HTMLImageElement, flipData: Object ): void;
+    static mergeAlpha( rgbImage: HTMLImageElement, alphaImage: HTMLImageElement, canvas?: HTMLCanvasElement ): HTMLCanvasElement;
     }
 
 

examples/BitmapAnimation/BitmapAnimation.js

+var __extends = this.__extends || function (d, b) {
+    function __() { this.constructor = d; }
+    __.prototype = b.prototype;
+    d.prototype = new __();
+}
 window.onload = function () {
     init();
 };

examples/BitmapAnimation/BitmapAnimation.ts

 	var h = canvas.height;
 
 	// create spritesheet and assign the associated data.
-	var spriteSheet  = new createjs.SpriteSheet({
+	var spriteSheet = new createjs.SpriteSheet({
 		images: [img],
 		frames: {width:64, height:68, regX:32, regY:34},
 		animations: {
 		}
 	});
 
+	
 	// to save file size, the loaded sprite sheet only includes right facing animations
 	// we could flip the display objects with scaleX=-1, but this is expensive in some browsers
 	// instead, we append flipped versions of the frames to our sprite sheet
Add a comment to this file

examples/BitmapAnimation/assets/Thumbs.db

Binary file removed.

 CreateJS TypeScript Definitions
 ===============================
 
+  
+  
+Development has changed into here:
+
+<https://github.com/borisyankov/DefinitelyTyped>
+
+
+It has more libraries there, be sure to check them out!
+
+  
+  
+------------------------------------------------
+
+  
+  
 
 Hello, here you can find the typescript definitions of createjs's libraries. Uses the MIT license.
 
 This is still in its early stage, so if you find something wrong (maybe some argument that should be optional) be sure to tell.
 
-
+  
+  
 
 Versions
 ========
     SoundJS: 0.3.0
     PreloadJS: 0.2.0
 
+  
+  
 
 Usage
 ======
     etc
 
 
+  
+  
+
 Some issues
 ===========
 
 - not sure about how to inherit from a createjs class (right now, I'm having a interface extend the class -- see the BitmapAnimation example)
 - properties that can have different types
 - methods that return different types
-- it doesn't seem to recognize the Image type

soundjs-0.3.0.d.ts

     paused: bool;
     playState: string;
     src: string;
-    uniqueId: string;   //HERE string or number
+    uniqueId: any;   //HERE string or number
 
         // methods
     getDuration(): number;
         // methods
     static checkPlugin( initializeDefault: bool ): bool;
     static getCapabilities(): Object;
-    static getCapability( key: string );    //HERE can return string | number | bool
+    static getCapability( key: string ): any;    // can return string | number | bool
     static getInstanceById( uniqueId: string ): SoundInstance;
     static getMasterVolume(): number;
     static getSrcFromId( value: string ): string;
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.