From 0d94a170e4930419aaf76657885f83d64d6809b6 Mon Sep 17 00:00:00 2001 From: Andrew Babin Date: Sun, 20 Aug 2017 22:45:08 -0500 Subject: [PATCH 1/8] Initial commit of animejs typings --- animejs/animejs-tests.js | 61 +++++++++++++++++ animejs/index.d.ts | 141 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 202 insertions(+) create mode 100644 animejs/animejs-tests.js create mode 100644 animejs/index.d.ts diff --git a/animejs/animejs-tests.js b/animejs/animejs-tests.js new file mode 100644 index 0000000000..43961d6208 --- /dev/null +++ b/animejs/animejs-tests.js @@ -0,0 +1,61 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var anime = require("animejs"); +var test1 = anime({ + targets: 'div', + duration: 40, + color: "#FFFFFF" +}); +var callback = function (anim) { + console.log(anim.completed); +}; +var test2 = anime({ + targets: 'div', + translateX: function (el, i, index) { + return 0; + }, + translateY: '40px', + color: [ + { value: '#FF0000', duration: 2000 }, + { value: '#00FF00', duration: 2000 }, + { value: '#0000FF', duration: 2000 }, + ], + duration: function () { + return 1000000000000; + }, + update: callback, + complete: callback +}); +var someNodes = document.querySelector('button'); +var test3 = anime({ + targets: someNodes, + top: "-5000000em" +}); +var tl = anime.timeline({ + loop: false, + direction: 'normal' +}); +tl.add({ + targets: ".tiny-divvy-div", + scale: 10000000 +}); +var path = anime.path('#motionPath path'); +test1.play(); +test2.reverse(); +test3.pause(); +tl.seek(4000); +tl.finished.then(function () { + console.log("I wonder if anyone will ever actually read this."); +}); +var usesEnums = anime({ + targets: ".usingEnumsIsAReallyHandyThing", + direction: "reverse" /* Reverse */, + easing: "easeInOutExpo" /* InOutExpo */, + someProperty: "+=4000" +}); +var bezier = anime.bezier(0, 0, 100, 100); +// anime.speed = 100000000; +anime.speed = 4000; +anime.easings['hello'] = anime.bezier(0, 0, 1900, 3020); +var runningAnims = anime.running; +anime.remove(".tiny-divvy-div"); diff --git a/animejs/index.d.ts b/animejs/index.d.ts new file mode 100644 index 0000000000..235f0690ec --- /dev/null +++ b/animejs/index.d.ts @@ -0,0 +1,141 @@ +// Type definitions for animejs 2.0 +// Project: http://animejs.com +// Definitions by: Andrew Babin +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +type FunctionBasedParamter = (element : HTMLElement, index : number, length : number) => number; +type AnimeCallbackFunction = (anim : anime.AnimeInstance) => void; +type AnimeTarget = string | object | HTMLElement | SVGElement | NodeList | null; //Allowing null is necessary because DOM querys may not return anything. + +declare namespace anime { + const enum EasingsEnum { + Linear = "linear", + InQuad = "easeInQuad", + InCubic = "easeInCubic", + InQuart = "easeInQuart", + InQuint = "easeInQuint", + InSine = "easeInSine", + InExpo = "easeInExpo", + InCirc = "easeInCirc", + InBack = "easeInBack", + InElastic = "easeInElastic", + OutQuad = "easeOutQuad", + OutCubic = "easeOutCubic", + OutQuart = "easeOutQuart", + OutQuint = "easeOutQuint", + OutSine = "easeOutSine", + OutExpo = "easeOutExpo", + OutCirc = "easeOutCirc", + OutBack = "easeOutBack", + OutElastic = "easeOutElastic", + InOutQuad = "easeInOutQuad", + InOutCubic = "easeInOutCubic", + InOutQuart = "easeInOutQuart", + InOutQuint = "easeInOutQuint", + InOutSine = "easeInOutSine", + InOutExpo = "easeInOutExpo", + InOutCirc = "easeInOutCirc", + InOutBack = "easeInOutBack", + InOutElastic = "easeInOutElastic", + } + const enum DirectionEnum { + Reverse = "reverse", + Alternate = "alternate", + Normal = "normal" + } + + interface AnimeInstanceParams { + loop ?: number | boolean; + autoplay ?: boolean; + direction ?: DirectionEnum | string; + + begin ?: AnimeCallbackFunction; + run ?: AnimeCallbackFunction; + update ?: AnimeCallbackFunction; + complete ?: AnimeCallbackFunction; + } + + interface AnimeAnimParams { + targets : AnimeTarget | AnimeTarget[]; + + duration ?: number | FunctionBasedParamter; + delay ?: number | FunctionBasedParamter; + elasticity ?: number | FunctionBasedParamter; + round ?: number | boolean | FunctionBasedParamter; + + easing ?: EasingsEnum | string | number[]; + + begin ?: AnimeCallbackFunction; + run ?: AnimeCallbackFunction; + update ?: AnimeCallbackFunction; + complete ?: AnimeCallbackFunction; + [AnyAnimatedProperty: string] : any; + } + + interface AnimeParams extends AnimeInstanceParams, AnimeAnimParams { + //Just need this to merge both Params interfaces. + } + + interface AnimeInstance { + play : () => void; + pause : () => void; + restart : () => void; + reverse : () => void; + seek : (time : number) => void; + + began : boolean; + paused : boolean; + completed : boolean; + finished : Promise; + + begin : AnimeCallbackFunction; + run : AnimeCallbackFunction; + update : AnimeCallbackFunction; + complete : AnimeCallbackFunction; + + + autoplay : boolean + currentTime : number; + delay : number; + direction : string; + duration : number; + loop : number | boolean; + offset : number; + progress : number; + remaining : number; + reversed : boolean; + + animatables : object[]; + animations : object[]; + } + + interface AnimeTimelineAnimParams extends AnimeAnimParams { + offset : number | string | FunctionBasedParamter; + } + + interface AnimeTimelineInstance extends AnimeInstance { + add (params : AnimeAnimParams) : AnimeTimelineInstance; + } + + // Helpers + var speed : number; + var running : AnimeInstance[]; + var easings : { [EasingFunction : string] : (t : number) => any }; + function remove (targets : AnimeTarget | AnimeTarget[] ) : void; + function getValue (targets : AnimeTarget, prop : string) : string | number; + function path (path : string | HTMLElement | SVGElement | null, percent ?: number) : (prop : string) => { + el : HTMLElement | SVGElement, + property : string, + totalLength : number + }; + function setDashoffset (el : HTMLElement | SVGElement | null) : number; + function bezier (x1 : number, y1 : number, x2 : number, y2 : number) : (t : number) => number; + // Timeline + function timeline (params ?: AnimeInstanceParams | AnimeInstance[]) : AnimeTimelineInstance; + function random(min : number, max : number) : number; +} + +declare function anime(params : anime.AnimeParams) : anime.AnimeInstance; + +export = anime; +export as namespace anime; \ No newline at end of file From 1cac6c748789b21aedc5e3399e9bbfe6a883d6d9 Mon Sep 17 00:00:00 2001 From: Andrew Babin Date: Mon, 21 Aug 2017 00:13:41 -0500 Subject: [PATCH 2/8] Initial commit of type definitions for animejs . --- types/animejs/animejs-tests.ts | 73 +++++++++++++++++ types/animejs/index.d.ts | 141 +++++++++++++++++++++++++++++++++ 2 files changed, 214 insertions(+) create mode 100644 types/animejs/animejs-tests.ts create mode 100644 types/animejs/index.d.ts diff --git a/types/animejs/animejs-tests.ts b/types/animejs/animejs-tests.ts new file mode 100644 index 0000000000..e7eec563c9 --- /dev/null +++ b/types/animejs/animejs-tests.ts @@ -0,0 +1,73 @@ +import * as anime from 'animejs'; + +const test1 = anime({ + targets: 'div', + duration: 40, + color: "#FFFFFF" +}) + + + +const callback = (anim : any) => { + console.log(anim.completed); +} + +const test2 = anime({ + targets: 'div', + translateX: (el : HTMLElement, i : number, index : number) => { + return 0; + }, + translateY: '40px', + color: [ + {value: '#FF0000', duration: 2000}, + {value: '#00FF00', duration: 2000}, + {value: '#0000FF', duration: 2000}, + ], + duration: () => { + return 1000000000000; + }, + update: callback, + complete: callback +}) + +const someNodes = document.querySelector('button'); + +const test3 = anime({ + targets: someNodes, + top: "-5000000em" +}) + +const tl = anime.timeline({ + loop: false, + direction: 'normal' +}) + +tl.add({ + targets: ".tiny-divvy-div", + scale: 10000000 +}) + +var path = anime.path('#motionPath path'); + +test1.play(); +test2.reverse(); +test3.pause(); +tl.seek(4000); + +tl.finished.then(() => { + console.log("I wonder if anyone will ever actually read this."); +}) + +let usesEnums = anime({ + targets: ".usingEnumsIsAReallyHandyThing", + direction: anime.DirectionEnum.Reverse, + easing: anime.EasingsEnum.InOutExpo, + someProperty: "+=4000" +}) + +const bezier = anime.bezier(0, 0, 100, 100); +// anime.speed = 100000000; +(anime as any).speed = 4000; +anime.easings['hello'] = anime.bezier(0, 0, 1900, 3020); +const runningAnims = anime.running; +anime.remove(".tiny-divvy-div"); \ No newline at end of file diff --git a/types/animejs/index.d.ts b/types/animejs/index.d.ts new file mode 100644 index 0000000000..e58380cb82 --- /dev/null +++ b/types/animejs/index.d.ts @@ -0,0 +1,141 @@ +// Type definitions for animejs 2.0 +// Project: http://animejs.com +// Definitions by: Andrew Babin +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +type FunctionBasedParamter = (element : HTMLElement, index : number, length : number) => number; +type AnimeCallbackFunction = (anim : anime.AnimeInstance) => void; +type AnimeTarget = string | object | HTMLElement | SVGElement | NodeList | null; //Allowing null is necessary because DOM querys may not return anything. + +declare namespace anime { + const enum EasingsEnum { + Linear = "linear", + InQuad = "easeInQuad", + InCubic = "easeInCubic", + InQuart = "easeInQuart", + InQuint = "easeInQuint", + InSine = "easeInSine", + InExpo = "easeInExpo", + InCirc = "easeInCirc", + InBack = "easeInBack", + InElastic = "easeInElastic", + OutQuad = "easeOutQuad", + OutCubic = "easeOutCubic", + OutQuart = "easeOutQuart", + OutQuint = "easeOutQuint", + OutSine = "easeOutSine", + OutExpo = "easeOutExpo", + OutCirc = "easeOutCirc", + OutBack = "easeOutBack", + OutElastic = "easeOutElastic", + InOutQuad = "easeInOutQuad", + InOutCubic = "easeInOutCubic", + InOutQuart = "easeInOutQuart", + InOutQuint = "easeInOutQuint", + InOutSine = "easeInOutSine", + InOutExpo = "easeInOutExpo", + InOutCirc = "easeInOutCirc", + InOutBack = "easeInOutBack", + InOutElastic = "easeInOutElastic", + } + const enum DirectionEnum { + Reverse = "reverse", + Alternate = "alternate", + Normal = "normal" + } + + interface AnimeInstanceParams { + loop ?: number | boolean; + autoplay ?: boolean; + direction ?: DirectionEnum | string; + + begin ?: AnimeCallbackFunction; + run ?: AnimeCallbackFunction; + update ?: AnimeCallbackFunction; + complete ?: AnimeCallbackFunction; + } + + interface AnimeAnimParams { + targets : AnimeTarget | ReadonlyArray; + + duration ?: number | FunctionBasedParamter; + delay ?: number | FunctionBasedParamter; + elasticity ?: number | FunctionBasedParamter; + round ?: number | boolean | FunctionBasedParamter; + + easing ?: EasingsEnum | string | ReadonlyArray; + + begin ?: AnimeCallbackFunction; + run ?: AnimeCallbackFunction; + update ?: AnimeCallbackFunction; + complete ?: AnimeCallbackFunction; + [AnyAnimatedProperty: string] : any; + } + + interface AnimeParams extends AnimeInstanceParams, AnimeAnimParams { + //Just need this to merge both Params interfaces. + } + + interface AnimeInstance { + play : () => void; + pause : () => void; + restart : () => void; + reverse : () => void; + seek : (time : number) => void; + + began : boolean; + paused : boolean; + completed : boolean; + finished : Promise; + + begin : AnimeCallbackFunction; + run : AnimeCallbackFunction; + update : AnimeCallbackFunction; + complete : AnimeCallbackFunction; + + + autoplay : boolean + currentTime : number; + delay : number; + direction : string; + duration : number; + loop : number | boolean; + offset : number; + progress : number; + remaining : number; + reversed : boolean; + + animatables : ReadonlyArray; + animations : ReadonlyArray; + } + + interface AnimeTimelineAnimParams extends AnimeAnimParams { + offset : number | string | FunctionBasedParamter; + } + + interface AnimeTimelineInstance extends AnimeInstance { + add (params : AnimeAnimParams) : AnimeTimelineInstance; + } + + // Helpers + var speed : number; + var running : AnimeInstance[]; + var easings : { [EasingFunction : string] : (t : number) => any }; + function remove (targets : AnimeTarget | ReadonlyArray ) : void; + function getValue (targets : AnimeTarget, prop : string) : string | number; + function path (path : string | HTMLElement | SVGElement | null, percent ?: number) : (prop : string) => { + el : HTMLElement | SVGElement, + property : string, + totalLength : number + }; + function setDashoffset (el : HTMLElement | SVGElement | null) : number; + function bezier (x1 : number, y1 : number, x2 : number, y2 : number) : (t : number) => number; + // Timeline + function timeline (params ?: AnimeInstanceParams | ReadonlyArray) : AnimeTimelineInstance; + function random(min : number, max : number) : number; +} + +declare function anime(params : anime.AnimeParams) : anime.AnimeInstance; + +export = anime; +export as namespace anime; \ No newline at end of file From fe3a33773646232299f2061a150a5387ea77abfe Mon Sep 17 00:00:00 2001 From: Andrew Babin Date: Mon, 21 Aug 2017 16:37:48 -0500 Subject: [PATCH 3/8] Done with animejs type definitions. --- types/animejs/tsconfig.json | 53 +++++++++++++++++++++++++++++++++++++ types/animejs/tslint.json | 1 + 2 files changed, 54 insertions(+) create mode 100644 types/animejs/tsconfig.json create mode 100644 types/animejs/tslint.json diff --git a/types/animejs/tsconfig.json b/types/animejs/tsconfig.json new file mode 100644 index 0000000000..9fc73cf1ed --- /dev/null +++ b/types/animejs/tsconfig.json @@ -0,0 +1,53 @@ +{ + "compilerOptions": { + /* Basic Options */ + "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */ + "module": "commonjs", /* Specify module code generation: 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ + // "lib": [], /* Specify library files to be included in the compilation: */ + // "allowJs": true, /* Allow javascript files to be compiled. */ + // "checkJs": true, /* Report errors in .js files. */ + // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ + // "declaration": true, /* Generates corresponding '.d.ts' file. */ + // "sourceMap": true, /* Generates corresponding '.map' file. */ + // "outFile": "./index.js", /* Concatenate and emit output to single file. */ + "outDir": "./build", /* Redirect output structure to the directory. */ + // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ + // "removeComments": true, /* Do not emit comments to output. */ + // "noEmit": true, /* Do not emit outputs. */ + // "importHelpers": true, /* Import emit helpers from 'tslib'. */ + // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ + // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ + + /* Strict Type-Checking Options */ + "strict": true, /* Enable all strict type-checking options. */ + "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ + "strictNullChecks": true, /* Enable strict null checks. */ + "noImplicitThis": true /* Raise error on 'this' expressions with an implied 'any' type. */ + // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ + + /* Additional Checks */ + // "noUnusedLocals": true, /* Report errors on unused locals. */ + // "noUnusedParameters": true, /* Report errors on unused parameters. */ + // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ + // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ + + /* Module Resolution Options */ + // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ + // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ + // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ + // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ + // "typeRoots": [], /* List of folders to include type definitions from. */ + // "types": [], /* Type declaration files to be included in compilation. */ + // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ + + /* Source Map Options */ + // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ + // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ + // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ + + /* Experimental Options */ + // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ + // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ + } +} \ No newline at end of file diff --git a/types/animejs/tslint.json b/types/animejs/tslint.json new file mode 100644 index 0000000000..2750cc0197 --- /dev/null +++ b/types/animejs/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } \ No newline at end of file From 53c5b13c13ffb7e18b53c341770d4b7c8683ea3a Mon Sep 17 00:00:00 2001 From: Andrew Babin Date: Mon, 21 Aug 2017 16:43:32 -0500 Subject: [PATCH 4/8] Deleting file that shouldn't be there --- animejs/animejs-tests.js | 61 ---------------------------------------- 1 file changed, 61 deletions(-) delete mode 100644 animejs/animejs-tests.js diff --git a/animejs/animejs-tests.js b/animejs/animejs-tests.js deleted file mode 100644 index 43961d6208..0000000000 --- a/animejs/animejs-tests.js +++ /dev/null @@ -1,61 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var anime = require("animejs"); -var test1 = anime({ - targets: 'div', - duration: 40, - color: "#FFFFFF" -}); -var callback = function (anim) { - console.log(anim.completed); -}; -var test2 = anime({ - targets: 'div', - translateX: function (el, i, index) { - return 0; - }, - translateY: '40px', - color: [ - { value: '#FF0000', duration: 2000 }, - { value: '#00FF00', duration: 2000 }, - { value: '#0000FF', duration: 2000 }, - ], - duration: function () { - return 1000000000000; - }, - update: callback, - complete: callback -}); -var someNodes = document.querySelector('button'); -var test3 = anime({ - targets: someNodes, - top: "-5000000em" -}); -var tl = anime.timeline({ - loop: false, - direction: 'normal' -}); -tl.add({ - targets: ".tiny-divvy-div", - scale: 10000000 -}); -var path = anime.path('#motionPath path'); -test1.play(); -test2.reverse(); -test3.pause(); -tl.seek(4000); -tl.finished.then(function () { - console.log("I wonder if anyone will ever actually read this."); -}); -var usesEnums = anime({ - targets: ".usingEnumsIsAReallyHandyThing", - direction: "reverse" /* Reverse */, - easing: "easeInOutExpo" /* InOutExpo */, - someProperty: "+=4000" -}); -var bezier = anime.bezier(0, 0, 100, 100); -// anime.speed = 100000000; -anime.speed = 4000; -anime.easings['hello'] = anime.bezier(0, 0, 1900, 3020); -var runningAnims = anime.running; -anime.remove(".tiny-divvy-div"); From 13ed94174781a547ef3b38d7263ee0743ba3dd4e Mon Sep 17 00:00:00 2001 From: Andrew Babin Date: Mon, 21 Aug 2017 16:43:49 -0500 Subject: [PATCH 5/8] Deleting another file that shouldn't be there --- animejs/index.d.ts | 141 --------------------------------------------- 1 file changed, 141 deletions(-) delete mode 100644 animejs/index.d.ts diff --git a/animejs/index.d.ts b/animejs/index.d.ts deleted file mode 100644 index 235f0690ec..0000000000 --- a/animejs/index.d.ts +++ /dev/null @@ -1,141 +0,0 @@ -// Type definitions for animejs 2.0 -// Project: http://animejs.com -// Definitions by: Andrew Babin -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -type FunctionBasedParamter = (element : HTMLElement, index : number, length : number) => number; -type AnimeCallbackFunction = (anim : anime.AnimeInstance) => void; -type AnimeTarget = string | object | HTMLElement | SVGElement | NodeList | null; //Allowing null is necessary because DOM querys may not return anything. - -declare namespace anime { - const enum EasingsEnum { - Linear = "linear", - InQuad = "easeInQuad", - InCubic = "easeInCubic", - InQuart = "easeInQuart", - InQuint = "easeInQuint", - InSine = "easeInSine", - InExpo = "easeInExpo", - InCirc = "easeInCirc", - InBack = "easeInBack", - InElastic = "easeInElastic", - OutQuad = "easeOutQuad", - OutCubic = "easeOutCubic", - OutQuart = "easeOutQuart", - OutQuint = "easeOutQuint", - OutSine = "easeOutSine", - OutExpo = "easeOutExpo", - OutCirc = "easeOutCirc", - OutBack = "easeOutBack", - OutElastic = "easeOutElastic", - InOutQuad = "easeInOutQuad", - InOutCubic = "easeInOutCubic", - InOutQuart = "easeInOutQuart", - InOutQuint = "easeInOutQuint", - InOutSine = "easeInOutSine", - InOutExpo = "easeInOutExpo", - InOutCirc = "easeInOutCirc", - InOutBack = "easeInOutBack", - InOutElastic = "easeInOutElastic", - } - const enum DirectionEnum { - Reverse = "reverse", - Alternate = "alternate", - Normal = "normal" - } - - interface AnimeInstanceParams { - loop ?: number | boolean; - autoplay ?: boolean; - direction ?: DirectionEnum | string; - - begin ?: AnimeCallbackFunction; - run ?: AnimeCallbackFunction; - update ?: AnimeCallbackFunction; - complete ?: AnimeCallbackFunction; - } - - interface AnimeAnimParams { - targets : AnimeTarget | AnimeTarget[]; - - duration ?: number | FunctionBasedParamter; - delay ?: number | FunctionBasedParamter; - elasticity ?: number | FunctionBasedParamter; - round ?: number | boolean | FunctionBasedParamter; - - easing ?: EasingsEnum | string | number[]; - - begin ?: AnimeCallbackFunction; - run ?: AnimeCallbackFunction; - update ?: AnimeCallbackFunction; - complete ?: AnimeCallbackFunction; - [AnyAnimatedProperty: string] : any; - } - - interface AnimeParams extends AnimeInstanceParams, AnimeAnimParams { - //Just need this to merge both Params interfaces. - } - - interface AnimeInstance { - play : () => void; - pause : () => void; - restart : () => void; - reverse : () => void; - seek : (time : number) => void; - - began : boolean; - paused : boolean; - completed : boolean; - finished : Promise; - - begin : AnimeCallbackFunction; - run : AnimeCallbackFunction; - update : AnimeCallbackFunction; - complete : AnimeCallbackFunction; - - - autoplay : boolean - currentTime : number; - delay : number; - direction : string; - duration : number; - loop : number | boolean; - offset : number; - progress : number; - remaining : number; - reversed : boolean; - - animatables : object[]; - animations : object[]; - } - - interface AnimeTimelineAnimParams extends AnimeAnimParams { - offset : number | string | FunctionBasedParamter; - } - - interface AnimeTimelineInstance extends AnimeInstance { - add (params : AnimeAnimParams) : AnimeTimelineInstance; - } - - // Helpers - var speed : number; - var running : AnimeInstance[]; - var easings : { [EasingFunction : string] : (t : number) => any }; - function remove (targets : AnimeTarget | AnimeTarget[] ) : void; - function getValue (targets : AnimeTarget, prop : string) : string | number; - function path (path : string | HTMLElement | SVGElement | null, percent ?: number) : (prop : string) => { - el : HTMLElement | SVGElement, - property : string, - totalLength : number - }; - function setDashoffset (el : HTMLElement | SVGElement | null) : number; - function bezier (x1 : number, y1 : number, x2 : number, y2 : number) : (t : number) => number; - // Timeline - function timeline (params ?: AnimeInstanceParams | AnimeInstance[]) : AnimeTimelineInstance; - function random(min : number, max : number) : number; -} - -declare function anime(params : anime.AnimeParams) : anime.AnimeInstance; - -export = anime; -export as namespace anime; \ No newline at end of file From 1134bd3da8c7f589546819d2916d7244d34882b4 Mon Sep 17 00:00:00 2001 From: Andrew Babin Date: Mon, 21 Aug 2017 16:53:17 -0500 Subject: [PATCH 6/8] Fixed tsconfig --- types/animejs/tsconfig.json | 74 +++++++++++-------------------------- 1 file changed, 22 insertions(+), 52 deletions(-) diff --git a/types/animejs/tsconfig.json b/types/animejs/tsconfig.json index 9fc73cf1ed..a8cfacd5fd 100644 --- a/types/animejs/tsconfig.json +++ b/types/animejs/tsconfig.json @@ -1,53 +1,23 @@ { - "compilerOptions": { - /* Basic Options */ - "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */ - "module": "commonjs", /* Specify module code generation: 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ - // "lib": [], /* Specify library files to be included in the compilation: */ - // "allowJs": true, /* Allow javascript files to be compiled. */ - // "checkJs": true, /* Report errors in .js files. */ - // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ - // "declaration": true, /* Generates corresponding '.d.ts' file. */ - // "sourceMap": true, /* Generates corresponding '.map' file. */ - // "outFile": "./index.js", /* Concatenate and emit output to single file. */ - "outDir": "./build", /* Redirect output structure to the directory. */ - // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ - // "removeComments": true, /* Do not emit comments to output. */ - // "noEmit": true, /* Do not emit outputs. */ - // "importHelpers": true, /* Import emit helpers from 'tslib'. */ - // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ - // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ - - /* Strict Type-Checking Options */ - "strict": true, /* Enable all strict type-checking options. */ - "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ - "strictNullChecks": true, /* Enable strict null checks. */ - "noImplicitThis": true /* Raise error on 'this' expressions with an implied 'any' type. */ - // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ - - /* Additional Checks */ - // "noUnusedLocals": true, /* Report errors on unused locals. */ - // "noUnusedParameters": true, /* Report errors on unused parameters. */ - // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ - // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ - - /* Module Resolution Options */ - // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ - // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ - // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ - // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ - // "typeRoots": [], /* List of folders to include type definitions from. */ - // "types": [], /* Type declaration files to be included in compilation. */ - // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - - /* Source Map Options */ - // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ - // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */ - // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ - // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ - - /* Experimental Options */ - // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ - // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ - } -} \ No newline at end of file + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "animejs-tests.ts" + ] +} From b20f1eb1a50139bb9ae252b46d2ccb4e17eecb29 Mon Sep 17 00:00:00 2001 From: Andrew Babin Date: Mon, 21 Aug 2017 17:12:51 -0500 Subject: [PATCH 7/8] Added TS version specifier --- types/animejs/index.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/types/animejs/index.d.ts b/types/animejs/index.d.ts index e58380cb82..70fa6b7375 100644 --- a/types/animejs/index.d.ts +++ b/types/animejs/index.d.ts @@ -2,6 +2,7 @@ // Project: http://animejs.com // Definitions by: Andrew Babin // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.4 type FunctionBasedParamter = (element : HTMLElement, index : number, length : number) => number; type AnimeCallbackFunction = (anim : anime.AnimeInstance) => void; @@ -138,4 +139,4 @@ declare namespace anime { declare function anime(params : anime.AnimeParams) : anime.AnimeInstance; export = anime; -export as namespace anime; \ No newline at end of file +export as namespace anime; From 88771c319d2aa3b5c992caf3fb67a342bf3d3e29 Mon Sep 17 00:00:00 2001 From: Andrew Babin Date: Mon, 21 Aug 2017 17:45:14 -0500 Subject: [PATCH 8/8] Replaced Enums --- types/animejs/index.d.ts | 41 ++++------------------------------------ 1 file changed, 4 insertions(+), 37 deletions(-) diff --git a/types/animejs/index.d.ts b/types/animejs/index.d.ts index 70fa6b7375..f7c24bf349 100644 --- a/types/animejs/index.d.ts +++ b/types/animejs/index.d.ts @@ -9,46 +9,13 @@ type AnimeCallbackFunction = (anim : anime.AnimeInstance) => void; type AnimeTarget = string | object | HTMLElement | SVGElement | NodeList | null; //Allowing null is necessary because DOM querys may not return anything. declare namespace anime { - const enum EasingsEnum { - Linear = "linear", - InQuad = "easeInQuad", - InCubic = "easeInCubic", - InQuart = "easeInQuart", - InQuint = "easeInQuint", - InSine = "easeInSine", - InExpo = "easeInExpo", - InCirc = "easeInCirc", - InBack = "easeInBack", - InElastic = "easeInElastic", - OutQuad = "easeOutQuad", - OutCubic = "easeOutCubic", - OutQuart = "easeOutQuart", - OutQuint = "easeOutQuint", - OutSine = "easeOutSine", - OutExpo = "easeOutExpo", - OutCirc = "easeOutCirc", - OutBack = "easeOutBack", - OutElastic = "easeOutElastic", - InOutQuad = "easeInOutQuad", - InOutCubic = "easeInOutCubic", - InOutQuart = "easeInOutQuart", - InOutQuint = "easeInOutQuint", - InOutSine = "easeInOutSine", - InOutExpo = "easeInOutExpo", - InOutCirc = "easeInOutCirc", - InOutBack = "easeInOutBack", - InOutElastic = "easeInOutElastic", - } - const enum DirectionEnum { - Reverse = "reverse", - Alternate = "alternate", - Normal = "normal" - } + type EasingOptions = "linear" | "easeInQuad" | "easeInCubic" | "easeInQuart" | "easeInQuint" | "easeInSine" | "easeInExpo" | "easeInCirc" | "easeInBack" | "easeInElastic" | "easeOutQuad" | "easeOutCubic" | "easeOutQuart" | "easeOutQuint" | "easeOutSine" | "easeOutExpo" | "easeOutCirc" | "easeOutBack" | "easeOutElastic" | "easeInOutQuad" | "easeInOutCubic" | "easeInOutQuart" | "easeInOutQuint" | "easeInOutSine" | "easeInOutExpo" | "easeInOutCirc" | "easeInOutBack" | "easeInOutElastic"; + type DirectionOptions = "reverse" | "alternate" | "normal"; interface AnimeInstanceParams { loop ?: number | boolean; autoplay ?: boolean; - direction ?: DirectionEnum | string; + direction ?: DirectionOptions | string; begin ?: AnimeCallbackFunction; run ?: AnimeCallbackFunction; @@ -64,7 +31,7 @@ declare namespace anime { elasticity ?: number | FunctionBasedParamter; round ?: number | boolean | FunctionBasedParamter; - easing ?: EasingsEnum | string | ReadonlyArray; + easing ?: EasingOptions | string | ReadonlyArray; begin ?: AnimeCallbackFunction; run ?: AnimeCallbackFunction;