From c3a688719edf7545818a18d3514c6ae5e4b257b6 Mon Sep 17 00:00:00 2001 From: Vadim Ogievetsky Date: Wed, 28 Jan 2015 11:15:55 -0800 Subject: [PATCH 001/185] fixed typing for async.parallel and co --- async/async-explicit-tests.ts | 44 +++++++++++++++++ async/async-explicit-tests.ts.tscparams | 1 + async/async.d.ts | 63 +++++++++++++------------ 3 files changed, 79 insertions(+), 29 deletions(-) create mode 100644 async/async-explicit-tests.ts create mode 100644 async/async-explicit-tests.ts.tscparams diff --git a/async/async-explicit-tests.ts b/async/async-explicit-tests.ts new file mode 100644 index 000000000..10d8f0bd2 --- /dev/null +++ b/async/async-explicit-tests.ts @@ -0,0 +1,44 @@ +/// + +interface StringCallback { (err: Error, result: string): void; } +interface AsyncStringGetter { (callback: StringCallback): void; } + +var taskArray: AsyncStringGetter[] = [ + function (callback) { + setTimeout(function () { + callback(null, 'one'); + }, 200); + }, + function (callback) { + setTimeout(function () { + callback(null, 'two'); + }, 100); + }, +]; + +async.series(taskArray, function (err, results) { console.log(results[0].match(/o/)) }); +async.parallel(taskArray, function (err, results) { console.log(results[0].match(/o/)) }); +async.parallelLimit(taskArray, 3, function (err, results) { console.log(results[0].match(/o/)) }); + + +interface Lookup { [key: string]: T; } +interface NumberCallback { (err: Error, result: number): void; } +interface AsyncNumberGetter { (callback: NumberCallback): void; } + +var taskDict: Lookup = { + one: function(callback){ + setTimeout(function(){ + callback(null, 1); + }, 200); + }, + two: function(callback){ + setTimeout(function(){ + callback(null, 2); + }, 100); + } +} + +async.series(taskDict, function(err, results) { console.log(results['one'].toFixed(1)) }); +async.parallel(taskDict, function(err, results) { console.log(results['one'].toFixed(1)) }); +async.parallelLimit(taskDict, 3, function(err, results) { console.log(results['one'].toFixed(1)) }); + diff --git a/async/async-explicit-tests.ts.tscparams b/async/async-explicit-tests.ts.tscparams new file mode 100644 index 000000000..3195c46cd --- /dev/null +++ b/async/async-explicit-tests.ts.tscparams @@ -0,0 +1 @@ +--noImplicitAny diff --git a/async/async.d.ts b/async/async.d.ts index 5f558c384..aae7eb1ae 100644 --- a/async/async.d.ts +++ b/async/async.d.ts @@ -3,10 +3,13 @@ // Definitions by: Boris Yankov // Definitions: https://github.com/borisyankov/DefinitelyTyped +interface Dict { [key: string]: T; } + interface ErrorCallback { (err?: Error): void; } -interface AsyncResultsCallback { (err: Error, results: T[]): void; } interface AsyncResultCallback { (err: Error, result: T): void; } -interface AsyncTimesCallback { (n: number, callback: AsyncResultsCallback): void; } +interface AsyncResultArrayCallback { (err: Error, results: T[]): void; } +interface AsyncResultDictCallback { (err: Error, results: Dict): void; } +interface AsyncTimesCallback { (n: number, callback: AsyncResultArrayCallback): void; } interface AsyncIterator { (item: T, callback: ErrorCallback): void; } interface AsyncResultIterator { (item: T, callback: AsyncResultCallback): void; } @@ -14,15 +17,17 @@ interface AsyncMemoIterator { (memo: R, item: T, callback: AsyncResultCall interface AsyncWorker { (task: T, callback: Function): void; } +interface AsyncTaskFn { (callback: AsyncResultCallback): void; } + interface AsyncQueue { length(): number; concurrency: number; started: boolean; paused: boolean; - push(task: T, callback?: AsyncResultsCallback): void; - push(task: T[], callback?: AsyncResultsCallback): void; - unshift(task: T, callback?: AsyncResultsCallback): void; - unshift(task: T[], callback?: AsyncResultsCallback): void; + push(task: T, callback?: AsyncResultArrayCallback): void; + push(task: T[], callback?: AsyncResultArrayCallback): void; + unshift(task: T, callback?: AsyncResultArrayCallback): void; + unshift(task: T[], callback?: AsyncResultArrayCallback): void; saturated: () => any; empty: () => any; drain: () => any; @@ -38,8 +43,8 @@ interface AsyncPriorityQueue { concurrency: number; started: boolean; paused: boolean; - push(task: T, priority: number, callback?: AsyncResultsCallback): void; - push(task: T[], priority: number, callback?: AsyncResultsCallback): void; + push(task: T, priority: number, callback?: AsyncResultArrayCallback): void; + push(task: T[], priority: number, callback?: AsyncResultArrayCallback): void; saturated: () => any; empty: () => any; drain: () => any; @@ -56,9 +61,9 @@ interface Async { each(arr: T[], iterator: AsyncIterator, callback: ErrorCallback): void; eachSeries(arr: T[], iterator: AsyncIterator, callback: ErrorCallback): void; eachLimit(arr: T[], limit: number, iterator: AsyncIterator, callback: ErrorCallback): void; - map(arr: T[], iterator: AsyncResultIterator, callback: AsyncResultsCallback): any; - mapSeries(arr: T[], iterator: AsyncResultIterator, callback: AsyncResultsCallback): any; - mapLimit(arr: T[], limit: number, iterator: AsyncResultIterator, callback: AsyncResultsCallback): any; + map(arr: T[], iterator: AsyncResultIterator, callback: AsyncResultArrayCallback): any; + mapSeries(arr: T[], iterator: AsyncResultIterator, callback: AsyncResultArrayCallback): any; + mapLimit(arr: T[], limit: number, iterator: AsyncResultIterator, callback: AsyncResultArrayCallback): any; filter(arr: T[], iterator: AsyncResultIterator, callback: (results: T[]) => any): any; select(arr: T[], iterator: AsyncResultIterator, callback: (results: T[]) => any): any; filterSeries(arr: T[], iterator: AsyncResultIterator, callback: (results: T[]) => any): any; @@ -70,33 +75,33 @@ interface Async { foldl(arr: T[], memo: R, iterator: AsyncMemoIterator, callback: AsyncResultCallback): any; reduceRight(arr: T[], memo: R, iterator: AsyncMemoIterator, callback: AsyncResultCallback): any; foldr(arr: T[], memo: R, iterator: AsyncMemoIterator, callback: AsyncResultCallback): any; - detect(arr: T[], iterator: AsyncResultIterator, callback: AsyncResultsCallback): any; - detectSeries(arr: T[], iterator: AsyncResultIterator, callback: AsyncResultsCallback): any; - sortBy(arr: T[], iterator: AsyncResultIterator, callback: AsyncResultsCallback): any; - some(arr: T[], iterator: AsyncResultIterator, callback: AsyncResultsCallback): any; - any(arr: T[], iterator: AsyncResultIterator, callback: AsyncResultsCallback): any; + detect(arr: T[], iterator: AsyncResultIterator, callback: AsyncResultArrayCallback): any; + detectSeries(arr: T[], iterator: AsyncResultIterator, callback: AsyncResultArrayCallback): any; + sortBy(arr: T[], iterator: AsyncResultIterator, callback: AsyncResultArrayCallback): any; + some(arr: T[], iterator: AsyncResultIterator, callback: AsyncResultArrayCallback): any; + any(arr: T[], iterator: AsyncResultIterator, callback: AsyncResultArrayCallback): any; every(arr: T[], iterator: AsyncResultIterator, callback: (result: boolean) => any): any; all(arr: T[], iterator: AsyncResultIterator, callback: (result: boolean) => any): any; - concat(arr: T[], iterator: AsyncResultIterator, callback: AsyncResultsCallback): any; - concatSeries(arr: T[], iterator: AsyncResultIterator, callback: AsyncResultsCallback): any; + concat(arr: T[], iterator: AsyncResultIterator, callback: AsyncResultArrayCallback): any; + concatSeries(arr: T[], iterator: AsyncResultIterator, callback: AsyncResultArrayCallback): any; // Control Flow - series(tasks: T[], callback?: AsyncResultsCallback): void; - series(tasks: T, callback?: AsyncResultsCallback): void; - parallel(tasks: T[], callback?: AsyncResultsCallback): void; - parallel(tasks: T, callback?: AsyncResultsCallback): void; - parallelLimit(tasks: T[], limit: number, callback?: AsyncResultsCallback): void; - parallelLimit(tasks: T, limit: number, callback?: AsyncResultsCallback): void; + series(tasks: Array>, callback?: AsyncResultArrayCallback): void; + series(tasks: Dict>, callback?: AsyncResultDictCallback): void; + parallel(tasks: Array>, callback?: AsyncResultArrayCallback): void; + parallel(tasks: Dict>, callback?: AsyncResultDictCallback): void; + parallelLimit(tasks: Array>, limit: number, callback?: AsyncResultArrayCallback): void; + parallelLimit(tasks: Dict>, limit: number, callback?: AsyncResultDictCallback): void; whilst(test: Function, fn: Function, callback: Function): void; until(test: Function, fn: Function, callback: Function): void; - waterfall(tasks: T[], callback?: AsyncResultsCallback): void; - waterfall(tasks: T, callback?: AsyncResultsCallback): void; + waterfall(tasks: Function[], callback?: AsyncResultArrayCallback): void; + waterfall(tasks: Function, callback?: AsyncResultArrayCallback): void; queue(worker: AsyncWorker, concurrency: number): AsyncQueue; priorityQueue(worker: AsyncWorker, concurrency: number): AsyncPriorityQueue; - // auto(tasks: any[], callback?: AsyncResultsCallback): void; - auto(tasks: any, callback?: AsyncResultsCallback): void; + // auto(tasks: any[], callback?: AsyncResultArrayCallback): void; + auto(tasks: any, callback?: AsyncResultArrayCallback): void; iterator(tasks: Function[]): Function; - apply(fn: Function, ...arguments: any[]): void; + apply(fn: Function, ...arguments: any[]): AsyncTaskFn; nextTick(callback: Function): void; times (n: number, callback: AsyncTimesCallback): void; From a583963da3e3b91df3be96922329629fd300b7ed Mon Sep 17 00:00:00 2001 From: reppners Date: Mon, 2 Feb 2015 12:12:34 +0100 Subject: [PATCH 002/185] + enhanced existing typedefinitions by looking at source code of angular-hotkeys to identify missing pieces --- angular-hotkeys/angular-hotkeys.d.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/angular-hotkeys/angular-hotkeys.d.ts b/angular-hotkeys/angular-hotkeys.d.ts index f209fbe08..63085fc03 100644 --- a/angular-hotkeys/angular-hotkeys.d.ts +++ b/angular-hotkeys/angular-hotkeys.d.ts @@ -9,13 +9,16 @@ declare module ng.hotkeys { interface HotkeysProvider { template: string; + templateTitle:string; includeCheatSheet: boolean; cheatSheetHotkey: string; cheatSheetDescription: string; - add(combo: string, description: string, callback: (event: Event, hotkeys: ng.hotkeys.Hotkey) => void): void; + add(combo: string, callback: (event: Event, hotkey?: Hotkey) => void, action?: string, allowIn?: Array, persistent?: boolean): ng.hotkeys.Hotkey; - add(hotkeyObj: ng.hotkeys.Hotkey): void; + add(combo: string, description: string, callback: (event: Event, hotkey?: Hotkey) => void, action?: string, allowIn?: Array, persistent?: boolean): ng.hotkeys.Hotkey; + + add(hotkeyObj: ng.hotkeys.Hotkey): ng.hotkeys.Hotkey; bindTo(scope : ng.IScope): ng.hotkeys.HotkeysProviderChained; @@ -24,6 +27,8 @@ declare module ng.hotkeys { get(combo: string): ng.hotkeys.Hotkey; toggleCheatSheet(): void; + + purgeHotkeys(): void; } interface HotkeysProviderChained { @@ -36,5 +41,8 @@ declare module ng.hotkeys { combo: string; description?: string; callback: (event: Event, hotkey: ng.hotkeys.Hotkey) => void; + action?: string; + allowIn?: Array; + persistent?: boolean; } } From 57708d0b2416820cb7946a3ffb467d32fa1616fb Mon Sep 17 00:00:00 2001 From: reppners Date: Mon, 2 Feb 2015 14:56:52 +0100 Subject: [PATCH 003/185] + added additional overload for del() --- angular-hotkeys/angular-hotkeys.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/angular-hotkeys/angular-hotkeys.d.ts b/angular-hotkeys/angular-hotkeys.d.ts index 63085fc03..60ffc2bfb 100644 --- a/angular-hotkeys/angular-hotkeys.d.ts +++ b/angular-hotkeys/angular-hotkeys.d.ts @@ -24,6 +24,8 @@ declare module ng.hotkeys { del(combo: string): void; + del(hotkeyObj: ng.hotkeys.Hotkey): void; + get(combo: string): ng.hotkeys.Hotkey; toggleCheatSheet(): void; From 3552529f78b81f6eeaf215e8813a03037836288e Mon Sep 17 00:00:00 2001 From: Vadim Ogievetsky Date: Tue, 3 Feb 2015 21:16:00 -0800 Subject: [PATCH 004/185] updated PR following review from @lukehoban and @chbrown --- async/async-tests.ts | 74 ++++++++++++++++++++++++++++++++++++++------ async/async.d.ts | 43 ++++++++++++------------- 2 files changed, 86 insertions(+), 31 deletions(-) diff --git a/async/async-tests.ts b/async/async-tests.ts index 9a563276a..a6b041b4d 100644 --- a/async/async-tests.ts +++ b/async/async-tests.ts @@ -67,6 +67,17 @@ async.series([ ], function (err, results) { }); +async.series([ + function (callback) { + callback(null, 'one'); + }, + function (callback) { + callback(null, 'two'); + }, +], +function (err, results) { }); + + async.series({ one: function (callback) { setTimeout(function () { @@ -81,6 +92,21 @@ async.series({ }, function (err, results) { }); +async.series({ + one: function (callback) { + setTimeout(function () { + callback(null, 1); + }, 200); + }, + two: function (callback) { + setTimeout(function () { + callback(null, 2); + }, 100); + }, +}, +function (err, results) { }); + + async.parallel([ function (callback) { setTimeout(function () { @@ -95,6 +121,20 @@ async.parallel([ ], function (err, results) { }); +async.parallel([ + function (callback) { + setTimeout(function () { + callback(null, 'one'); + }, 200); + }, + function (callback) { + setTimeout(function () { + callback(null, 'two'); + }, 100); + }, +], +function (err, results) { }); + async.parallel({ one: function (callback) { @@ -110,6 +150,20 @@ async.parallel({ }, function (err, results) { }); +async.parallel({ + one: function (callback) { + setTimeout(function () { + callback(null, 1); + }, 200); + }, + two: function (callback) { + setTimeout(function () { + callback(null, 2); + }, 100); + }, +}, +function (err, results) { }); + var count = 0; @@ -136,7 +190,7 @@ async.waterfall([ ], function (err, result) { }); -var q = async.queue(function (task: any, callback) { +var q = async.queue(function (task: any, callback) { console.log('hello ' + task.name); callback(); }, 2); @@ -189,29 +243,29 @@ q.resume(); q.kill(); // tests for strongly typed tasks -var q2 = async.queue(function (task: string, callback) { +var q2 = async.queue(function (task: string, callback) { console.log('Task: ' + task); callback(); }, 1); q2.push('task1'); -q2.push('task2', function (error, results: string[]) { - console.log('Finished tasks: ' + results.join(', ')); +q2.push('task2', function (error) { + console.log('Finished tasks'); }); -q2.push(['task3', 'task4', 'task5'], function (error, results: string[]) { - console.log('Finished tasks: ' + results.join(', ')); +q2.push(['task3', 'task4', 'task5'], function (error) { + console.log('Finished tasks'); }); q2.unshift('task1'); -q2.unshift('task2', function (error, results: string[]) { - console.log('Finished tasks: ' + results.join(', ')); +q2.unshift('task2', function (error) { + console.log('Finished tasks'); }); -q2.unshift(['task3', 'task4', 'task5'], function (error, results: string[]) { - console.log('Finished tasks: ' + results.join(', ')); +q2.unshift(['task3', 'task4', 'task5'], function (error) { + console.log('Finished tasks'); }); var filename = ''; diff --git a/async/async.d.ts b/async/async.d.ts index aae7eb1ae..bb8890ef7 100644 --- a/async/async.d.ts +++ b/async/async.d.ts @@ -3,31 +3,32 @@ // Definitions by: Boris Yankov // Definitions: https://github.com/borisyankov/DefinitelyTyped -interface Dict { [key: string]: T; } +interface Dictionary { [key: string]: T; } interface ErrorCallback { (err?: Error): void; } interface AsyncResultCallback { (err: Error, result: T): void; } interface AsyncResultArrayCallback { (err: Error, results: T[]): void; } -interface AsyncResultDictCallback { (err: Error, results: Dict): void; } +interface AsyncResultObjectCallback { (err: Error, results: Dictionary): void; } interface AsyncTimesCallback { (n: number, callback: AsyncResultArrayCallback): void; } interface AsyncIterator { (item: T, callback: ErrorCallback): void; } interface AsyncResultIterator { (item: T, callback: AsyncResultCallback): void; } interface AsyncMemoIterator { (memo: R, item: T, callback: AsyncResultCallback): void; } -interface AsyncWorker { (task: T, callback: Function): void; } +interface AsyncWorker { (task: T, callback: ErrorCallback): void; } -interface AsyncTaskFn { (callback: AsyncResultCallback): void; } +interface AsyncFunction { (callback: AsyncResultCallback): void; } +interface AsyncVoidFunction { (callback: ErrorCallback): void; } interface AsyncQueue { length(): number; concurrency: number; started: boolean; paused: boolean; - push(task: T, callback?: AsyncResultArrayCallback): void; - push(task: T[], callback?: AsyncResultArrayCallback): void; - unshift(task: T, callback?: AsyncResultArrayCallback): void; - unshift(task: T[], callback?: AsyncResultArrayCallback): void; + push(task: T, callback?: ErrorCallback): void; + push(task: T[], callback?: ErrorCallback): void; + unshift(task: T, callback?: ErrorCallback): void; + unshift(task: T[], callback?: ErrorCallback): void; saturated: () => any; empty: () => any; drain: () => any; @@ -86,23 +87,23 @@ interface Async { concatSeries(arr: T[], iterator: AsyncResultIterator, callback: AsyncResultArrayCallback): any; // Control Flow - series(tasks: Array>, callback?: AsyncResultArrayCallback): void; - series(tasks: Dict>, callback?: AsyncResultDictCallback): void; - parallel(tasks: Array>, callback?: AsyncResultArrayCallback): void; - parallel(tasks: Dict>, callback?: AsyncResultDictCallback): void; - parallelLimit(tasks: Array>, limit: number, callback?: AsyncResultArrayCallback): void; - parallelLimit(tasks: Dict>, limit: number, callback?: AsyncResultDictCallback): void; - whilst(test: Function, fn: Function, callback: Function): void; - until(test: Function, fn: Function, callback: Function): void; - waterfall(tasks: Function[], callback?: AsyncResultArrayCallback): void; - waterfall(tasks: Function, callback?: AsyncResultArrayCallback): void; + series(tasks: Array>, callback?: AsyncResultArrayCallback): void; + series(tasks: Dictionary>, callback?: AsyncResultObjectCallback): void; + parallel(tasks: Array>, callback?: AsyncResultArrayCallback): void; + parallel(tasks: Dictionary>, callback?: AsyncResultObjectCallback): void; + parallelLimit(tasks: Array>, limit: number, callback?: AsyncResultArrayCallback): void; + parallelLimit(tasks: Dictionary>, limit: number, callback?: AsyncResultObjectCallback): void; + whilst(test: () => boolean, fn: AsyncVoidFunction, callback: (err: any) => void): void; + doWhilst(fn: AsyncVoidFunction, test: () => boolean, callback: (err: any) => void): void; + until(test: () => boolean, fn: AsyncVoidFunction, callback: (err: any) => void): void; + doUntil(fn: AsyncVoidFunction, test: () => boolean, callback: (err: any) => void): void; + waterfall(tasks: Function[], callback?: AsyncResultArrayCallback): void; queue(worker: AsyncWorker, concurrency: number): AsyncQueue; priorityQueue(worker: AsyncWorker, concurrency: number): AsyncPriorityQueue; - // auto(tasks: any[], callback?: AsyncResultArrayCallback): void; auto(tasks: any, callback?: AsyncResultArrayCallback): void; iterator(tasks: Function[]): Function; - apply(fn: Function, ...arguments: any[]): AsyncTaskFn; - nextTick(callback: Function): void; + apply(fn: Function, ...arguments: any[]): AsyncFunction; + nextTick(callback: Function): void; times (n: number, callback: AsyncTimesCallback): void; timesSeries (n: number, callback: AsyncTimesCallback): void; From 6aefcc0fd9935befd11d76001753354d50d68729 Mon Sep 17 00:00:00 2001 From: reppners Date: Wed, 4 Feb 2015 21:23:37 +0100 Subject: [PATCH 005/185] + added author --- angular-hotkeys/angular-hotkeys.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/angular-hotkeys/angular-hotkeys.d.ts b/angular-hotkeys/angular-hotkeys.d.ts index 60ffc2bfb..63da273ce 100644 --- a/angular-hotkeys/angular-hotkeys.d.ts +++ b/angular-hotkeys/angular-hotkeys.d.ts @@ -1,6 +1,6 @@ // Type definitions for angular-hotkeys // Project: https://github.com/chieffancypants/angular-hotkeys -// Definitions by: Jason Zhao +// Definitions by: Jason Zhao , Stefan Steinhart // Definitions: https://github.com/borisyankov/DefinitelyTyped /// From a7981f2146914d3522101bf8c454fa2de80da016 Mon Sep 17 00:00:00 2001 From: "EWOUT-QMINO\\Ewout" Date: Thu, 5 Feb 2015 10:07:20 +0100 Subject: [PATCH 006/185] Added event callbacks to CellView --- jointjs/jointjs.d.ts | 110 ++++++++++++++++++++++++------------------- 1 file changed, 61 insertions(+), 49 deletions(-) diff --git a/jointjs/jointjs.d.ts b/jointjs/jointjs.d.ts index 9e6a2f0cc..e52c13f3c 100644 --- a/jointjs/jointjs.d.ts +++ b/jointjs/jointjs.d.ts @@ -17,33 +17,33 @@ declare module joint { class Graph extends Backbone.Model { initialize(); - fromJSON(json: any); + fromJSON(json:any); clear(); - addCell(cell: Cell); - addCells(cells: Cell[]); - getConnectedLinks(cell: Cell, opt?: any): Link[]; - disconnectLinks(cell: Cell); - removeLinks(cell: Cell); + addCell(cell:Cell); + addCells(cells:Cell[]); + getConnectedLinks(cell:Cell, opt?:any):Link[]; + disconnectLinks(cell:Cell); + removeLinks(cell:Cell); findModelsFromPoint(point:{x : number; y: number}):Element[]; } class Cell extends Backbone.Model { toJSON(); - remove(options?: any); + remove(options?:any); toFront(); toBack(); - embed(cell: Cell); - unembed(cell: Cell); - getEmbeddedCells(): Cell[]; - clone(opt?: any): Backbone.Model; // @todo: return can either be Cell or Cell[]. - attr(attrs: any): Cell; + embed(cell:Cell); + unembed(cell:Cell); + getEmbeddedCells():Cell[]; + clone(opt?:any):Backbone.Model; // @todo: return can either be Cell or Cell[]. + attr(attrs:any):Cell; } class Element extends Cell { - position(x: number, y: number): Element; - translate(tx: number, ty?: number): Element; - resize(width: number, height: number): Element; - rotate(angle: number, absolute): Element; + position(x:number, y:number):Element; + translate(tx:number, ty?:number):Element; + resize(width:number, height:number):Element; + rotate(angle:number, absolute):Element; } interface IDefaults { @@ -51,9 +51,9 @@ declare module joint { } class Link extends Cell { - defaults(): IDefaults; - disconnect(): Link; - label(idx?: number, value?: any): any; // @todo: returns either a label under idx or Link if both idx and value were passed + defaults():IDefaults; + disconnect():Link; + label(idx?:number, value?:any):any; // @todo: returns either a label under idx or Link if both idx and value were passed } interface IOptions { @@ -66,34 +66,41 @@ declare module joint { } class Paper extends Backbone.View { - options: IOptions; - setDimensions(width: number, height: number); - scale(sx: number, sy?: number, ox?: number, oy?: number): Paper; - rotate(deg: number, ox?: number, oy?: number): Paper; // @todo not released yet though it's in the source code already - findView(el: any): CellView; - findViewByModel(modelOrId: any): CellView; - findViewsFromPoint(p: { x: number; y: number; }): CellView[]; - findViewsInArea(r: { x: number; y: number; width: number; height: number; }): CellView[]; - snapToGrid(p): { x: number; y: number; }; + options:IOptions; + + setDimensions(width:number, height:number); + scale(sx:number, sy?:number, ox?:number, oy?:number):Paper; + rotate(deg:number, ox?:number, oy?:number):Paper; // @todo not released yet though it's in the source code already + findView(el:any):CellView; + findViewByModel(modelOrId:any):CellView; + findViewsFromPoint(p:{ x: number; y: number; }):CellView[]; + findViewsInArea(r:{ x: number; y: number; width: number; height: number; }):CellView[]; + snapToGrid(p):{ x: number; y: number; }; } - class ElementView extends CellView { - scale(sx: number, sy: number); + class ElementView extends CellView { + scale(sx:number, sy:number); } class CellView extends Backbone.View { - getBBox(): { x: number; y: number; width: number; height: number; }; - highlight(el?: any); - unhighlight(el?: any); - findMagnet(el: any); - getSelector(el: any); + getBBox():{ x: number; y: number; width: number; height: number; }; + highlight(el?:any); + unhighlight(el?:any); + findMagnet(el:any); + getSelector(el:any); + + pointerdblclick(evt:any, x:number, y:number):void; + pointerclick(evt:any, x:number, y:number):void; + pointerdown(evt:any, x:number, y:number):void; + pointermove(evt:any, x:number, y:number):void; + pointerup(evt:any, x:number, y:number):void; } class LinkView extends CellView { - getConnectionLength(): number; - getPointAtLength(length: number): { x: number; y: number; }; + getConnectionLength():number; + getPointAtLength(length:number):{ x: number; y: number; }; } - + } module ui { @@ -127,21 +134,26 @@ declare module joint { module shapes { module basic { - class Generic extends joint.dia.Element { } - class Rect extends Generic { } - class Text extends Generic { } - class Circle extends Generic { } - class Image extends Generic { } + class Generic extends joint.dia.Element { + } + class Rect extends Generic { + } + class Text extends Generic { + } + class Circle extends Generic { + } + class Image extends Generic { + } } } module util { - function uuid(): string; - function guid(obj: any): string; - function mixin(objects: any[]): any; - function supplement(objects: any[]): any; - function deepMixin(objects: any[]): any; - function deepSupplement(objects: any[], defaultIndicator?: any): any; + function uuid():string; + function guid(obj:any):string; + function mixin(objects:any[]):any; + function supplement(objects:any[]):any; + function deepMixin(objects:any[]):any; + function deepSupplement(objects:any[], defaultIndicator?:any):any; } } From a0f9e136c004ef9894833bb09a98bdb60a25bb1f Mon Sep 17 00:00:00 2001 From: "EWOUT-QMINO\\Ewout" Date: Fri, 6 Feb 2015 09:48:57 +0100 Subject: [PATCH 007/185] Separated jointjs and rappid definitions. --- jointjs/jointjs.d.ts | 34 ++++------------------------------ rappid/README.md | 1 + rappid/rappid.d.ts | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 30 deletions(-) create mode 100644 rappid/README.md create mode 100644 rappid/rappid.d.ts diff --git a/jointjs/jointjs.d.ts b/jointjs/jointjs.d.ts index e52c13f3c..483523d67 100644 --- a/jointjs/jointjs.d.ts +++ b/jointjs/jointjs.d.ts @@ -1,6 +1,7 @@ -// Type definitions for Joint JS 0.6 +// Type definitions for Joint JS 0.9.3 // Project: http://www.jointjs.com/ -// Definitions by: Aidan Reel , David Durman +// Definitions by: Aidan Reel , +// David Durman , Ewout Van Gossum // Definitions: https://github.com/borisyankov/DefinitelyTyped /// @@ -103,34 +104,7 @@ declare module joint { } - module ui { - interface Handle { - name : string; - position : string; - icon: string; - } - - class SelectionView extends Backbone.Model { - paper:joint.dia.Paper; - graph:joint.dia.Graph; - model:Backbone.Collection; - - constructor(opt:{ - paper : joint.dia.Paper; - graph : joint.dia.Graph; - model : Backbone.Collection - }); - - createSelectionBox(cellView:joint.dia.CellView); - destroySelectionBox(cellView:joint.dia.CellView); - startSelecting(evt:any); - cancelSelection(); - - addHandle(handle:Handle); - removeHandle(name:string); - changeHandle(name:string, handle:Handle); - } - } + module ui {} module shapes { module basic { diff --git a/rappid/README.md b/rappid/README.md new file mode 100644 index 000000000..1119a7e6b --- /dev/null +++ b/rappid/README.md @@ -0,0 +1 @@ +These definitions are far from complete. \ No newline at end of file diff --git a/rappid/rappid.d.ts b/rappid/rappid.d.ts new file mode 100644 index 000000000..2b3aaf4e2 --- /dev/null +++ b/rappid/rappid.d.ts @@ -0,0 +1,38 @@ +// Type definitions for Rappid 1.5 +// Project: http://jointjs.com/about-rappid +// Definitions by: Ewout Van Gossum +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// +/// + +declare module joint{ + module ui{ + interface Handle { + name : string; + position : string; + icon: string; + } + + class SelectionView extends Backbone.Model { + paper:joint.dia.Paper; + graph:joint.dia.Graph; + model:Backbone.Collection; + + constructor(opt:{ + paper : joint.dia.Paper; + graph : joint.dia.Graph; + model : Backbone.Collection + }); + + createSelectionBox(cellView:joint.dia.CellView); + destroySelectionBox(cellView:joint.dia.CellView); + startSelecting(evt:any); + cancelSelection(); + + addHandle(handle:Handle); + removeHandle(name:string); + changeHandle(name:string, handle:Handle); + } + } +} \ No newline at end of file From 9ce634af3aedb2313b64ea5bc40d0f6027c2c13c Mon Sep 17 00:00:00 2001 From: Vincent Siao Date: Thu, 5 Feb 2015 22:52:34 -0800 Subject: [PATCH 008/185] Split modules react and react/addons; exporting Component class --- react/react-0.13.0-tests.ts | 202 +++--- react/react-0.13.0.d.ts | 525 +++++---------- react/react-addons-0.13.0-tests.ts | 399 ++++++++++-- react/react-addons-0.13.0.d.ts | 997 +++++++++++++++++++++++++++++ 4 files changed, 1611 insertions(+), 512 deletions(-) create mode 100644 react/react-addons-0.13.0.d.ts diff --git a/react/react-0.13.0-tests.ts b/react/react-0.13.0-tests.ts index 18d4bcf4e..d85138857 100644 --- a/react/react-0.13.0-tests.ts +++ b/react/react-0.13.0-tests.ts @@ -1,7 +1,7 @@ -/// - +/// // requiring react/addons instead of react so react.d.ts doesn't get picked up -import React = require('react/addons'); +// TODO: import "react" once 0.13.0 is released +import React = require("react/addons"); interface Props { hello: string; @@ -42,36 +42,37 @@ var INPUT_REF: string = "input"; // Top-Level API // -------------------------------------------------------------------------- -var reactClassicClass: React.ClassicComponentClass = React.createClass({ - getDefaultProps: () => { - return { - hello: undefined, - world: "peace", - foo: undefined, - bar: undefined - }; - }, - getInitialState: () => { - return { - inputValue: this.context.someValue, - seconds: this.props.foo - }; - }, - reset: () => { - this.replaceState(this.getInitialState()); - }, - render: () => { - return React.DOM.div(null, - React.DOM.input({ - ref: INPUT_REF, - value: this.state.inputValue - })); - } -}); +var ClassicComponent: React.ClassicComponentClass = + React.createClass({ + getDefaultProps: () => { + return { + hello: undefined, + world: "peace", + foo: undefined, + bar: undefined + }; + }, + getInitialState: () => { + return { + inputValue: this.context.someValue, + seconds: this.props.foo + }; + }, + reset: () => { + this.replaceState(this.getInitialState()); + }, + render: () => { + return React.DOM.div(null, + React.DOM.input({ + ref: INPUT_REF, + value: this.state.inputValue + })); + } + }); -var reactClass: React.ComponentClass = reactClassicClass; +class ModernComponent extends React.Component + implements React.ChildContextProvider { -class ModernComponent extends React.Component implements React.ChildContextProvider { constructor(props: Props, context: Context) { super(props, context); this.state = { @@ -80,18 +81,17 @@ class ModernComponent extends React.Component implements }; } - // this should work but doesn't. Due to TypeScript bug? - //static propTypes = { - // foo: React.PropTypes.number - //} + static propTypes: React.ValidationMap = { + foo: React.PropTypes.number + } - //static contextTypes = { - // someValue: React.PropTypes.string - //} + static contextTypes: React.ValidationMap = { + someValue: React.PropTypes.string + } - //static childContextTypes = { - // someOtherValue: React.PropTypes.string - //} + static childContextTypes: React.ValidationMap = { + someOtherValue: React.PropTypes.string + } getChildContext() { return { @@ -120,66 +120,71 @@ class ModernComponent extends React.Component implements } } -ModernComponent.propTypes = { - foo: React.PropTypes.string, -} +// React.createFactory +var factory: React.Factory = + React.createFactory(ModernComponent); +var factoryElement: React.ReactElement = + factory(props); -ModernComponent.contextTypes = { - someValue: React.PropTypes.string -} +var classicFactory: React.ClassicFactory = + React.createFactory(ClassicComponent); +var classicFactoryElement: React.ReactClassicElement = + classicFactory(props); -ModernComponent.childContextTypes = { - someOtherValue: React.PropTypes.string -} +var domFactory: React.DOMFactory = + React.createFactory("foo"); +var domFactoryElement: React.ReactDOMElement = + domFactory(); -var reactElement: React.ReactElement; -reactElement = React.createElement(reactClass, props); -reactElement = React.createElement(ModernComponent, props); +// React.createElement +var element: React.ReactElement = + React.createElement(ModernComponent, props); +var classicElement: React.ReactClassicElement = + React.createElement(ClassicComponent, props); +var domElement: React.ReactHTMLElement = + React.createElement("div"); -var reactFactory: React.ComponentFactory; -reactFactory = React.createFactory(reactClass); -reactFactory = React.createFactory(ModernComponent); - -var component: React.Component = - React.render(reactElement, container); +// React.render +var component: React.Component = + React.render(element, container); +var classicComponent: React.ClassicComponent = + React.render(classicElement, container); +var domComponent: React.DOMComponent = + React.render(domElement, container); +// Other Top-Level API var unmounted: boolean = React.unmountComponentAtNode(container); -var str: string = React.renderToString(reactElement); -var markup: string = React.renderToStaticMarkup(reactElement); +var str: string = React.renderToString(element); +var markup: string = React.renderToStaticMarkup(element); var notValid: boolean = React.isValidElement(props); // false -var isValid = React.isValidElement(reactElement); // true +var isValid = React.isValidElement(element); // true React.initializeTouchEvents(true); var domNode: Element = React.findDOMNode(component); - -var reactClassicElement: React.ReactClassicElement; -reactClassicElement = React.createElement(reactClassicClass, props); -var classicComponent: React.ClassicComponent; -classicComponent = React.render(reactClassicElement, container); +domNode = React.findDOMNode(domNode); // // React Elements // -------------------------------------------------------------------------- -var type = reactElement.type; -var elementProps: Props = reactElement.props; -var key = reactElement.key; -var ref: string = reactElement.ref; -var factoryElement: React.ReactElement = reactFactory(elementProps); +var type = element.type; +var elementProps: Props = element.props; +var key = element.key; +var ref: string = element.ref; // // React Components // -------------------------------------------------------------------------- -var displayName: string = reactClass.displayName; -var defaultProps: Props = reactClass.getDefaultProps(); -var propTypes: React.ValidationMap = reactClass.propTypes; +var displayName: string = ClassicComponent.displayName; +var defaultProps: Props = ClassicComponent.getDefaultProps(); +var propTypes: React.ValidationMap = ClassicComponent.propTypes; // // Component API // -------------------------------------------------------------------------- // modern -var initialState: State = component.state; +var componentState: State = component.state; component.setState({ inputValue: "!!!" }); component.forceUpdate(); @@ -324,33 +329,28 @@ var onlyChild = React.Children.only([null, [[["Hallo"], true]], false]); interface TimerState { secondsElapsed: number; } -interface Timer extends React.Component<{}, TimerState, any> { -} -var Timer = React.createClass({ - displayName: "Timer", - getInitialState: () => { - return { secondsElapsed: 0 }; - }, - tick: () => { - var me = this; - me.setState({ - secondsElapsed: me.state.secondsElapsed + 1 - }); - }, - componentDidMount: () => { - this.interval = setInterval(this.tick, 1000); - }, - componentWillUnmount: () => { - clearInterval(this.interval); - }, - render: () => { - var me = this; +class Timer extends React.Component<{}, TimerState, {}> { + static state = { + secondsElapsed: 0 + } + private _interval: number; + tick() { + this.setState({ secondsElapsed: this.state.secondsElapsed + 1 }); + } + componentDidMount() { + var me = this; + this._interval = setInterval(() => me.tick(), 1000); + } + componentWillUnmount() { + clearInterval(this._interval); + } + render() { return React.DOM.div( null, "Seconds Elapsed: ", - me.state.secondsElapsed + this.state.secondsElapsed ); } -}); -var mountNode: Element; -React.render(React.createElement(Timer, null), mountNode); +} +React.render(React.createElement(Timer), container); + diff --git a/react/react-0.13.0.d.ts b/react/react-0.13.0.d.ts index 9ee102541..780fcc2d0 100644 --- a/react/react-0.13.0.d.ts +++ b/react/react-0.13.0.d.ts @@ -3,40 +3,177 @@ // Definitions by: Asana , AssureSign // Definitions: https://github.com/borisyankov/DefinitelyTyped -declare module React { +declare module "react" { // - // React Elements + // React Elements // ---------------------------------------------------------------------- - - type ReactType = ComponentClass | string; - interface ReactElement

{ - type: ComponentClass | string; + interface ReactElementBase { + type: T; props: P; key: number | string; ref: string; } - interface ReactClassicElement

extends ReactElement

{ - } + interface ReactElement

+ extends ReactElementBase, P> {} - interface ReactHTMLElement extends ReactElement {} - interface ReactSVGElement extends ReactElement {} + interface ReactClassicElement

+ extends ReactElementBase | string, P> {} + + interface ReactDOMElement

// subtype of ReactClassicElement + extends ReactElementBase {} + + type ReactHTMLElement = ReactDOMElement; + type ReactSVGElement = ReactDOMElement; // - // React Nodes + // Factories + // ---------------------------------------------------------------------- + + interface Factory

{ + (props?: P, ...children: ReactNode[]): ReactElement

; + } + + interface ClassicFactory

{ + (props?: P, ...children: ReactNode[]): ReactClassicElement

; + } + + interface DOMFactory

{ + (props?: P, ...children: ReactNode[]): ReactDOMElement

; + } + + type HTMLFactory = DOMFactory; + type SVGFactory = DOMFactory; + + // + // React Nodes // http://facebook.github.io/react/docs/glossary.html // ---------------------------------------------------------------------- type ReactText = string | number; - type ReactChild = ReactElement | ReactText; + type ReactChild = ReactElementBase | ReactText; // Should be Array but type aliases cannot be recursive type ReactFragment = Array; type ReactNode = ReactChild | ReactFragment | boolean; // - // React Components + // Top Level API + // ---------------------------------------------------------------------- + + function createClass( + spec: ComponentSpec): ClassicComponentClass; + + function createFactory

( + type: string): DOMFactory

; + function createFactory

( + type: ClassicComponentClass | string): ClassicFactory

; + function createFactory

( + type: ComponentClass): Factory

; + + function createElement

( + type: string, + props?: P, + ...children: ReactNode[]): ReactDOMElement

; + function createElement

( + type: ClassicComponentClass | string, + props?: P, + ...children: ReactNode[]): ReactClassicElement

; + function createElement

( + type: ComponentClass, + props?: P, + ...children: ReactNode[]): ReactElement

; + + function render

( + element: ReactDOMElement

, + container: Element, + callback?: () => any): DOMComponent

; + function render( + element: ReactClassicElement

, + container: Element, + callback?: () => any): ClassicComponent; + function render( + element: ReactElement

, + container: Element, + callback?: () => any): Component; + + function unmountComponentAtNode(container: Element): boolean; + function renderToString(element: ReactElementBase): string; + function renderToStaticMarkup(element: ReactElementBase): string; + function isValidElement(object: {}): boolean; + function initializeTouchEvents(shouldUseTouch: boolean): void; + + function findDOMNode( + componentOrElement: Component | Element): TElement; + function findDOMNode( + componentOrElement: Component | Element): Element; + + var DOM: ReactDOM; + var PropTypes: ReactPropTypes; + var Children: ReactChildren; + + // + // Component API + // ---------------------------------------------------------------------- + + // Base component for plain JS classes + class Component implements ComponentLifecycle { + constructor(props: P, context: C); + setState(state: S, callback?: () => any): void; + forceUpdate(): void; + props: P; + state: S; + context: C; + refs: { + [key: string]: Component + }; + } + + interface ClassicComponent extends Component { + replaceState(nextState: S, callback?: () => any): void; + getDOMNode(): TElement; + getDOMNode(): Element; + isMounted(): boolean; + getInitialState?(): S; + setProps(nextProps: P, callback?: () => any): void; + replaceProps(nextProps: P, callback?: () => any): void; + } + + interface DOMComponent

extends ClassicComponent { + tagName: string; + } + + type HTMLComponent = DOMComponent; + type SVGComponent = DOMComponent; + + interface ChildContextProvider { + getChildContext(): CC; + } + + // + // Class Interfaces + // ---------------------------------------------------------------------- + + interface ComponentClassBase { + propTypes?: ValidationMap

; + contextTypes?: ValidationMap; + childContextTypes?: ValidationMap<{}>; + } + + interface ComponentClass extends ComponentClassBase { + new(props?: P, context?: C): Component; + defaultProps?: P; + } + + interface ClassicComponentClass extends ComponentClassBase { + new(props?: P, context?: C): ClassicComponent; + getDefaultProps?(): P; + displayName?: string; + } + + // + // Component Specs and Lifecycle // ---------------------------------------------------------------------- interface ComponentLifecycle { @@ -48,102 +185,7 @@ declare module React { componentDidUpdate?(prevProps: P, prevState: S, prevContext: C): void; componentWillUnmount?(): void; } - - // "modern" ES6 classes - class Component implements ComponentLifecycle { - constructor(props: P, context: C); - // static members can't be type checked with generics. However, see ComponentClass - static defaultProps: any; - static propTypes: ValidationMap; - static contextTypes: ValidationMap; - static childContextTypes: ValidationMap; - static displayName: string; - setState(state: S, callback?: () => any): void; - forceUpdate(): void; - props: P; - state: S; - context: C; - refs: { - [key: string]: Component - }; - } - - interface ComponentClass { - new (props: P, context: C): Component; - // can cast to get type checking for generics if desired - defaultProps: P; - getDefaultProps?(): P; - propTypes: ValidationMap

; - contextTypes: ValidationMap; - childContextTypes: ValidationMap; - displayName: string; - } - - // "classic" createClass - class ClassicComponent extends Component { - replaceState(nextState: S, callback?: () => any): void; - getDOMNode(): TElement; - getDOMNode(): Element; - isMounted(): boolean; - getInitialState(): S; - setProps(nextProps: P, callback?: () => any): void; - replaceProps(nextProps: P, callback?: () => any): void; - } - - interface ClassicComponentClass extends ComponentClass { - new (props: P, context: C): ClassicComponent; - } - - interface ChildContextProvider { - getChildContext: () => C; - } - - // - // ReactElement Factories - // ---------------------------------------------------------------------- - interface ComponentFactory

{ - (props?: P, ...children: ReactNode[]): ReactElement

; - } - - interface HTMLFactory extends ComponentFactory {} - interface SVGFactory extends ComponentFactory {} - - // - // Top-Level API - // ---------------------------------------------------------------------- - - interface TopLevelAPI { - createClass(spec: ComponentSpec): ClassicComponentClass; - createElement

(type: ClassicComponentClass, props: P, ...children: ReactNode[]): ReactClassicElement

; - createElement

(type: ComponentClass | string, props: P, ...children: ReactNode[]): ReactElement

; - createFactory

(type: ComponentClass | string): ComponentFactory

; - render(element: ReactClassicElement

, container: Element, callback?: () => any): ClassicComponent; - render(element: ReactElement

, container: Element, callback?: () => any): Component; - unmountComponentAtNode(container: Element): boolean; - renderToString(element: ReactElement): string; - renderToStaticMarkup(element: ReactElement): string; - isValidElement(object: {}): boolean; - initializeTouchEvents(shouldUseTouch: boolean): void; - findDOMNode(component: Component): Element; - findDOMNode(component: Component): TElement; - } - - // - // Component API - // ---------------------------------------------------------------------- - - class DOMComponent

extends ClassicComponent { - tagName: string; - } - - interface HTMLComponent extends DOMComponent {} - interface SVGComponent extends DOMComponent {} - - // - // Component Specs and Lifecycle - // ---------------------------------------------------------------------- - interface Mixin extends ComponentLifecycle { mixins?: Mixin; statics?: { @@ -154,13 +196,13 @@ declare module React { propTypes?: ValidationMap; contextTypes?: ValidationMap; childContextTypes?: ValidationMap - + getInitialState?(): S; getDefaultProps?(): P; } interface ComponentSpec extends Mixin { - render(): ReactElement; + render(): ReactElementBase; } // @@ -445,7 +487,7 @@ declare module React { interface SVGAttributes extends ReactAttributes { cx?: SVGLength | SVGAnimatedLength; - cy?: any; + cy?: any; d?: string; dx?: SVGLength | SVGAnimatedLength; dy?: SVGLength | SVGAnimatedLength; @@ -490,7 +532,7 @@ declare module React { } // - // React.DOM + // React.DOM // ---------------------------------------------------------------------- interface ReactDOM { @@ -673,255 +715,6 @@ declare module React { only(children: ReactNode): ReactChild; } - // - // React.addons - // ---------------------------------------------------------------------- - - interface ClassSet { - [key: string]: boolean; - } - - // - // React.addons (Transitions) - // ---------------------------------------------------------------------- - - interface TransitionGroupProps { - component?: ReactType; - childFactory?: (child: ReactElement) => ReactElement; - } - - interface CSSTransitionGroupProps extends TransitionGroupProps { - transitionName: string; - transitionAppear?: boolean; - transitionEnter?: boolean; - transitionLeave?: boolean; - } - - interface CSSTransitionGroup extends ComponentClass {} - interface TransitionGroup extends ComponentClass {} - - // - // React.addons (Mixins) - // ---------------------------------------------------------------------- - - interface ReactLink { - value: T; - requestChange(newValue: T): void; - } - - interface LinkedStateMixin extends Mixin { - linkState(key: string): ReactLink; - } - - interface PureRenderMixin extends Mixin { - } - - // - // Reat.addons.update - // ---------------------------------------------------------------------- - - interface UpdateSpec { - $set: any; - $merge: {}; - $apply(value: any): any; - // [key: string]: UpdateSpec; - } - - interface UpdateArraySpec extends UpdateSpec { - $push?: any[]; - $unshift?: any[]; - $splice?: any[][]; - } - - // - // React.addons.Perf - // ---------------------------------------------------------------------- - - interface ComponentPerfContext { - current: string; - owner: string; - } - - interface NumericPerfContext { - [key: string]: number; - } - - interface Measurements { - exclusive: NumericPerfContext; - inclusive: NumericPerfContext; - render: NumericPerfContext; - counts: NumericPerfContext; - writes: NumericPerfContext; - displayNames: { - [key: string]: ComponentPerfContext; - }; - totalTime: number; - } - - interface ReactPerf { - start(): void; - stop(): void; - printInclusive(measurements: Measurements[]): void; - printExclusive(measurements: Measurements[]): void; - printWasted(measurements: Measurements[]): void; - printDOM(measurements: Measurements[]): void; - getLastMeasurements(): Measurements[]; - } - - // - // React.addons.TestUtils - // ---------------------------------------------------------------------- - - interface MockedComponentClass { - new(): any; - } - - interface ReactTestUtils { - Simulate: Simulate; - - renderIntoDocument

(element: ReactElement

): Component; - renderIntoDocument>(element: ReactElement): C; - - mockComponent(mocked: MockedComponentClass, mockTagName?: string): ReactTestUtils; - - isElementOfType(element: ReactElement, type: ReactType): boolean; - isDOMComponent(instance: Component): boolean; - isCompositeComponent(instance: Component): boolean; - isCompositeComponentWithType(instance: Component, type: ComponentClass): boolean; - isTextComponent(instance: Component): boolean; - - findAllInRenderedTree(tree: Component, fn: (i: Component) => boolean): Component; - - scryRenderedDOMComponentsWithClass(tree: Component, className: string): DOMComponent[]; - findRenderedDOMComponentWithClass(tree: Component, className: string): DOMComponent; - - scryRenderedDOMComponentsWithTag(tree: Component, tagName: string): DOMComponent[]; - findRenderedDOMComponentWithTag(tree: Component, tagName: string): DOMComponent; - - scryRenderedComponentsWithType( - tree: Component, type: ComponentClass): Component[]; - scryRenderedComponentsWithType>( - tree: Component, type: ComponentClass): C[]; - - findRenderedComponentWithType( - tree: Component, type: ComponentClass): Component; - findRenderedComponentWithType>( - tree: Component, type: ComponentClass): C; - } - - interface SyntheticEventData { - altKey?: boolean; - button?: number; - buttons?: number; - clientX?: number; - clientY?: number; - changedTouches?: TouchList; - charCode?: boolean; - clipboardData?: DataTransfer; - ctrlKey?: boolean; - deltaMode?: number; - deltaX?: number; - deltaY?: number; - deltaZ?: number; - detail?: number; - getModifierState?(key: string): boolean; - key?: string; - keyCode?: number; - locale?: string; - location?: number; - metaKey?: boolean; - pageX?: number; - pageY?: number; - relatedTarget?: EventTarget; - repeat?: boolean; - screenX?: number; - screenY?: number; - shiftKey?: boolean; - targetTouches?: TouchList; - touches?: TouchList; - view?: AbstractView; - which?: number; - } - - interface EventSimulator { - (element: Element, eventData?: SyntheticEventData): void; - (descriptor: Component, eventData?: SyntheticEventData): void; - } - - interface Simulate { - blur: EventSimulator; - change: EventSimulator; - click: EventSimulator; - cut: EventSimulator; - doubleClick: EventSimulator; - drag: EventSimulator; - dragEnd: EventSimulator; - dragEnter: EventSimulator; - dragExit: EventSimulator; - dragLeave: EventSimulator; - dragOver: EventSimulator; - dragStart: EventSimulator; - drop: EventSimulator; - focus: EventSimulator; - input: EventSimulator; - keyDown: EventSimulator; - keyPress: EventSimulator; - keyUp: EventSimulator; - mouseDown: EventSimulator; - mouseEnter: EventSimulator; - mouseLeave: EventSimulator; - mouseMove: EventSimulator; - mouseOut: EventSimulator; - mouseOver: EventSimulator; - mouseUp: EventSimulator; - paste: EventSimulator; - scroll: EventSimulator; - submit: EventSimulator; - touchCancel: EventSimulator; - touchEnd: EventSimulator; - touchMove: EventSimulator; - touchStart: EventSimulator; - wheel: EventSimulator; - } - - // - // react Exports - // ---------------------------------------------------------------------- - - interface Exports extends TopLevelAPI { - DOM: ReactDOM; - PropTypes: ReactPropTypes; - Children: ReactChildren; - Component: ComponentClass; - } - - // - // react/addons Exports - // ---------------------------------------------------------------------- - - interface AddonsExports extends Exports { - addons: { - CSSTransitionGroup: CSSTransitionGroup; - LinkedStateMixin: LinkedStateMixin; - PureRenderMixin: PureRenderMixin; - TransitionGroup: TransitionGroup; - - batchedUpdates(callback: (a: A, b: B) => any, a: A, b: B): void; - batchedUpdates(callback: (a: A) => any, a: A): void; - batchedUpdates(callback: () => any): void; - - classSet(cx: ClassSet): string; - cloneWithProps

(element: ReactElement

, props: P): ReactElement

; - - update(value: any[], spec: UpdateArraySpec): any[]; - update(value: {}, spec: UpdateSpec): any; - - // Development tools - Perf: ReactPerf; - TestUtils: ReactTestUtils; - }; - } - // // Browser Interfaces // https://github.com/nikeee/2048-typescript/blob/master/2048/js/touch.d.ts @@ -951,13 +744,3 @@ declare module React { } } -declare module "react" { - var exports: React.Exports; - export = exports; -} - -declare module "react/addons" { - var exports: React.AddonsExports; - export = exports; -} - diff --git a/react/react-addons-0.13.0-tests.ts b/react/react-addons-0.13.0-tests.ts index 6081a9824..fe5b772a3 100644 --- a/react/react-addons-0.13.0-tests.ts +++ b/react/react-addons-0.13.0-tests.ts @@ -1,15 +1,364 @@ -/// +/// import React = require("react/addons"); -var isImportant: boolean; -var isRead: boolean; -var classSet: React.ClassSet = { - "message": true, - "message-important": isImportant, - "message-read": isRead +interface Props { + hello: string; + world?: string; + foo: number; + bar: boolean; +} + +interface State { + inputValue?: string; + seconds?: number; +} + +interface Context { + someValue?: string; +} + +interface ChildContext { + someOtherValue: string; +} + +interface MyComponent extends React.Component { + reset(): void; +} + +var props: Props = { + key: 42, + ref: "myComponent42", + hello: "world", + foo: 42, + bar: true }; + +var container: Element; +var INPUT_REF: string = "input"; + +// +// Top-Level API +// -------------------------------------------------------------------------- + +var ClassicComponent: React.ClassicComponentClass = + React.createClass({ + getDefaultProps: () => { + return { + hello: undefined, + world: "peace", + foo: undefined, + bar: undefined + }; + }, + getInitialState: () => { + return { + inputValue: this.context.someValue, + seconds: this.props.foo + }; + }, + reset: () => { + this.replaceState(this.getInitialState()); + }, + render: () => { + return React.DOM.div(null, + React.DOM.input({ + ref: INPUT_REF, + value: this.state.inputValue + })); + } + }); + +class ModernComponent extends React.Component + implements React.ChildContextProvider { + + constructor(props: Props, context: Context) { + super(props, context); + this.state = { + inputValue: context.someValue, + seconds: props.foo + }; + } + + static propTypes: React.ValidationMap = { + foo: React.PropTypes.number + } + + static contextTypes: React.ValidationMap = { + someValue: React.PropTypes.string + } + + static childContextTypes: React.ValidationMap = { + someOtherValue: React.PropTypes.string + } + + getChildContext() { + return { + someOtherValue: 'foo' + } + } + + state = { + inputValue: this.context.someValue, + seconds: this.props.foo + } + + reset() { + this.setState({ + inputValue: this.context.someValue, + seconds: this.props.foo + }); + } + + render() { + return React.DOM.div(null, + React.DOM.input({ + ref: INPUT_REF, + value: this.state.inputValue + })); + } +} + +// React.createFactory +var factory: React.Factory = + React.createFactory(ModernComponent); +var factoryElement: React.ReactElement = + factory(props); + +var classicFactory: React.ClassicFactory = + React.createFactory(ClassicComponent); +var classicFactoryElement: React.ReactClassicElement = + classicFactory(props); + +var domFactory: React.DOMFactory = + React.createFactory("foo"); +var domFactoryElement: React.ReactDOMElement = + domFactory(); + +// React.createElement +var element: React.ReactElement = + React.createElement(ModernComponent, props); +var classicElement: React.ReactClassicElement = + React.createElement(ClassicComponent, props); +var domElement: React.ReactHTMLElement = + React.createElement("div"); + +// React.render +var component: React.Component = + React.render(element, container); +var classicComponent: React.ClassicComponent = + React.render(classicElement, container); +var domComponent: React.DOMComponent = + React.render(domElement, container); + +// Other Top-Level API +var unmounted: boolean = React.unmountComponentAtNode(container); +var str: string = React.renderToString(element); +var markup: string = React.renderToStaticMarkup(element); +var notValid: boolean = React.isValidElement(props); // false +var isValid = React.isValidElement(element); // true +React.initializeTouchEvents(true); +var domNode: Element = React.findDOMNode(component); +domNode = React.findDOMNode(domNode); + +// +// React Elements +// -------------------------------------------------------------------------- + +var type = element.type; +var elementProps: Props = element.props; +var key = element.key; +var ref: string = element.ref; + +// +// React Components +// -------------------------------------------------------------------------- + +var displayName: string = ClassicComponent.displayName; +var defaultProps: Props = ClassicComponent.getDefaultProps(); +var propTypes: React.ValidationMap = ClassicComponent.propTypes; + +// +// Component API +// -------------------------------------------------------------------------- + +// modern +var componentState: State = component.state; +component.setState({ inputValue: "!!!" }); +component.forceUpdate(); + +// classic +var htmlElement: Element = classicComponent.getDOMNode(); +var divElement: HTMLDivElement = classicComponent.getDOMNode(); +var isMounted: boolean = classicComponent.isMounted(); +classicComponent.setProps(elementProps); +classicComponent.replaceProps(props); +classicComponent.replaceState({ inputValue: "???", seconds: 60 }); + +var inputRef: React.HTMLComponent = + component.refs[INPUT_REF]; +var value: string = inputRef.getDOMNode().value; + +var myComponent = component; +myComponent.reset(); + +// +// Attributes +// -------------------------------------------------------------------------- + +var children = ["Hello world", [null], React.DOM.span(null)]; +var divStyle = { // CSSProperties + flex: "1 1 main-size", + backgroundImage: "url('hello.png')" +}; +var htmlAttr: React.HTMLAttributes = { + key: 36, + ref: "htmlComponent", + children: children, + className: "test-attr", + style: divStyle, + onClick: (event: React.MouseEvent) => { + event.preventDefault(); + event.stopPropagation(); + }, + dangerouslySetInnerHTML: { + __html: "STRONG" + } +}; +React.DOM.div(htmlAttr); +React.DOM.span(htmlAttr); +React.DOM.input(htmlAttr); + +// +// React.PropTypes +// -------------------------------------------------------------------------- + +var PropTypesSpecification: React.ComponentSpec = { + propTypes: { + optionalArray: React.PropTypes.array, + optionalBool: React.PropTypes.bool, + optionalFunc: React.PropTypes.func, + optionalNumber: React.PropTypes.number, + optionalObject: React.PropTypes.object, + optionalString: React.PropTypes.string, + optionalNode: React.PropTypes.node, + optionalElement: React.PropTypes.element, + optionalMessage: React.PropTypes.instanceOf(Date), + optionalEnum: React.PropTypes.oneOf(["News", "Photos"]), + optionalUnion: React.PropTypes.oneOfType([ + React.PropTypes.string, + React.PropTypes.number, + React.PropTypes.instanceOf(Date) + ]), + optionalArrayOf: React.PropTypes.arrayOf(React.PropTypes.number), + optionalObjectOf: React.PropTypes.objectOf(React.PropTypes.number), + optionalObjectWithShape: React.PropTypes.shape({ + color: React.PropTypes.string, + fontSize: React.PropTypes.number + }), + requiredFunc: React.PropTypes.func.isRequired, + requiredAny: React.PropTypes.any.isRequired, + customProp: function(props: any, propName: string, componentName: string) { + if (!/matchme/.test(props[propName])) { + return new Error("Validation failed!"); + } + return null; + } + }, + render: (): React.ReactHTMLElement => { + return null; + } +}; + +// +// ContextTypes +// -------------------------------------------------------------------------- + +var ContextTypesSpecification: React.ComponentSpec = { + contextTypes: { + optionalArray: React.PropTypes.array, + optionalBool: React.PropTypes.bool, + optionalFunc: React.PropTypes.func, + optionalNumber: React.PropTypes.number, + optionalObject: React.PropTypes.object, + optionalString: React.PropTypes.string, + optionalNode: React.PropTypes.node, + optionalElement: React.PropTypes.element, + optionalMessage: React.PropTypes.instanceOf(Date), + optionalEnum: React.PropTypes.oneOf(["News", "Photos"]), + optionalUnion: React.PropTypes.oneOfType([ + React.PropTypes.string, + React.PropTypes.number, + React.PropTypes.instanceOf(Date) + ]), + optionalArrayOf: React.PropTypes.arrayOf(React.PropTypes.number), + optionalObjectOf: React.PropTypes.objectOf(React.PropTypes.number), + optionalObjectWithShape: React.PropTypes.shape({ + color: React.PropTypes.string, + fontSize: React.PropTypes.number + }), + requiredFunc: React.PropTypes.func.isRequired, + requiredAny: React.PropTypes.any.isRequired, + customProp: function(props: any, propName: string, componentName: string) { + if (!/matchme/.test(props[propName])) { + return new Error("Validation failed!"); + } + return null; + } + }, + render: (): React.ReactHTMLElement => { + return null; + } +}; + +// +// React.Children +// -------------------------------------------------------------------------- + +var childMap: { [key: string]: number } = + React.Children.map(children, (child) => { return 42; }); +React.Children.forEach(children, (child) => {}); +var nChildren: number = React.Children.count(children); +var onlyChild = React.Children.only([null, [[["Hallo"], true]], false]); + +// +// Example from http://facebook.github.io/react/ +// -------------------------------------------------------------------------- + +interface TimerState { + secondsElapsed: number; +} +class Timer extends React.Component<{}, TimerState, {}> { + static state = { + secondsElapsed: 0 + } + private _interval: number; + tick() { + this.setState({ secondsElapsed: this.state.secondsElapsed + 1 }); + } + componentDidMount() { + var me = this; + this._interval = setInterval(() => me.tick(), 1000); + } + componentWillUnmount() { + clearInterval(this._interval); + } + render() { + return React.DOM.div( + null, + "Seconds Elapsed: ", + this.state.secondsElapsed + ); + } +} +React.render(React.createElement(Timer), container); + +// +// React.addons +// -------------------------------------------------------------------------- + var cx = React.addons.classSet; -var classes: string = cx(classSet); +var className: string = cx({ a: true, b: false, c: true }); +className = cx("a", null, "b"); // // React.addons (Transitions) @@ -31,38 +380,8 @@ React.createFactory(React.addons.CSSTransitionGroup)({ // React.addons.TestUtils // -------------------------------------------------------------------------- -var that: React.Component; -var node = React.findDOMNode(that.refs["input"]); +var node: Element; React.addons.TestUtils.Simulate.click(node); React.addons.TestUtils.Simulate.change(node); -React.addons.TestUtils.Simulate.keyDown(node, {key: "Enter"}); +React.addons.TestUtils.Simulate.keyDown(node, { key: "Enter" }); -interface GreetingProps { - name: string; -} -interface GreetingState { - morning: boolean; -} -interface Greeting extends React.Component { -} -var Greeting = React.createClass({ - displayName: "Greeting", - getInitialState: function() { - return {morning: true}; - }, - render: function() { - var me = this; - return React.DOM.div( - null, - me.state.morning ? "Hello " : "Goodbye ", - me.props.name); - } -}); - -var root = React.addons.TestUtils.renderIntoDocument( - React.createElement(Greeting, {name: "John"})); -var greeting = React.addons.TestUtils - .findRenderedComponentWithType(root, Greeting); -greeting.setState({ - morning: false -}); diff --git a/react/react-addons-0.13.0.d.ts b/react/react-addons-0.13.0.d.ts new file mode 100644 index 000000000..80afbb46d --- /dev/null +++ b/react/react-addons-0.13.0.d.ts @@ -0,0 +1,997 @@ +// Type definitions for ReactWithAddons 0.13.0 +// Project: http://facebook.github.io/react/ +// Definitions by: Asana , AssureSign +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module "react/addons" { + // + // React Elements + // ---------------------------------------------------------------------- + + interface ReactElementBase { + type: T; + props: P; + key: number | string; + ref: string; + } + + interface ReactElement

+ extends ReactElementBase, P> {} + + interface ReactClassicElement

+ extends ReactElementBase | string, P> {} + + interface ReactDOMElement

// subtype of ReactClassicElement + extends ReactElementBase {} + + type ReactHTMLElement = ReactDOMElement; + type ReactSVGElement = ReactDOMElement; + + // + // Factories + // ---------------------------------------------------------------------- + + interface Factory

{ + (props?: P, ...children: ReactNode[]): ReactElement

; + } + + interface ClassicFactory

{ + (props?: P, ...children: ReactNode[]): ReactClassicElement

; + } + + interface DOMFactory

{ + (props?: P, ...children: ReactNode[]): ReactDOMElement

; + } + + type HTMLFactory = DOMFactory; + type SVGFactory = DOMFactory; + + // + // React Nodes + // http://facebook.github.io/react/docs/glossary.html + // ---------------------------------------------------------------------- + + type ReactText = string | number; + type ReactChild = ReactElementBase | ReactText; + + // Should be Array but type aliases cannot be recursive + type ReactFragment = Array; + type ReactNode = ReactChild | ReactFragment | boolean; + + // + // Top Level API + // ---------------------------------------------------------------------- + + function createClass( + spec: ComponentSpec): ClassicComponentClass; + + function createFactory

( + type: string): DOMFactory

; + function createFactory

( + type: ClassicComponentClass | string): ClassicFactory

; + function createFactory

( + type: ComponentClass): Factory

; + + function createElement

( + type: string, + props?: P, + ...children: ReactNode[]): ReactDOMElement

; + function createElement

( + type: ClassicComponentClass | string, + props?: P, + ...children: ReactNode[]): ReactClassicElement

; + function createElement

( + type: ComponentClass, + props?: P, + ...children: ReactNode[]): ReactElement

; + + function render

( + element: ReactDOMElement

, + container: Element, + callback?: () => any): DOMComponent

; + function render( + element: ReactClassicElement

, + container: Element, + callback?: () => any): ClassicComponent; + function render( + element: ReactElement

, + container: Element, + callback?: () => any): Component; + + function unmountComponentAtNode(container: Element): boolean; + function renderToString(element: ReactElementBase): string; + function renderToStaticMarkup(element: ReactElementBase): string; + function isValidElement(object: {}): boolean; + function initializeTouchEvents(shouldUseTouch: boolean): void; + + function findDOMNode( + componentOrElement: Component | Element): TElement; + function findDOMNode( + componentOrElement: Component | Element): Element; + + var DOM: ReactDOM; + var PropTypes: ReactPropTypes; + var Children: ReactChildren; + + // + // Component API + // ---------------------------------------------------------------------- + + // Base component for plain JS classes + class Component implements ComponentLifecycle { + constructor(props: P, context: C); + setState(state: S, callback?: () => any): void; + forceUpdate(): void; + props: P; + state: S; + context: C; + refs: { + [key: string]: Component + }; + } + + interface ClassicComponent extends Component { + replaceState(nextState: S, callback?: () => any): void; + getDOMNode(): TElement; + getDOMNode(): Element; + isMounted(): boolean; + getInitialState?(): S; + setProps(nextProps: P, callback?: () => any): void; + replaceProps(nextProps: P, callback?: () => any): void; + } + + interface DOMComponent

extends ClassicComponent { + tagName: string; + } + + type HTMLComponent = DOMComponent; + type SVGComponent = DOMComponent; + + interface ChildContextProvider { + getChildContext(): CC; + } + + // + // Class Interfaces + // ---------------------------------------------------------------------- + + interface ComponentClassBase { + propTypes?: ValidationMap

; + contextTypes?: ValidationMap; + childContextTypes?: ValidationMap<{}>; + } + + interface ComponentClass extends ComponentClassBase { + new(props?: P, context?: C): Component; + defaultProps?: P; + } + + interface ClassicComponentClass extends ComponentClassBase { + new(props?: P, context?: C): ClassicComponent; + getDefaultProps?(): P; + displayName?: string; + } + + // + // Component Specs and Lifecycle + // ---------------------------------------------------------------------- + + interface ComponentLifecycle { + componentWillMount?(): void; + componentDidMount?(): void; + componentWillReceiveProps?(nextProps: P, nextContext: C): void; + shouldComponentUpdate?(nextProps: P, nextState: S, nextContext: C): boolean; + componentWillUpdate?(nextProps: P, nextState: S, nextContext: C): void; + componentDidUpdate?(prevProps: P, prevState: S, prevContext: C): void; + componentWillUnmount?(): void; + } + + interface Mixin extends ComponentLifecycle { + mixins?: Mixin; + statics?: { + [key: string]: any; + }; + + displayName?: string; + propTypes?: ValidationMap; + contextTypes?: ValidationMap; + childContextTypes?: ValidationMap + + getInitialState?(): S; + getDefaultProps?(): P; + } + + interface ComponentSpec extends Mixin { + render(): ReactElementBase; + } + + // + // Event System + // ---------------------------------------------------------------------- + + interface SyntheticEvent { + bubbles: boolean; + cancelable: boolean; + currentTarget: EventTarget; + defaultPrevented: boolean; + eventPhase: number; + isTrusted: boolean; + nativeEvent: Event; + preventDefault(): void; + stopPropagation(): void; + target: EventTarget; + timeStamp: Date; + type: string; + } + + interface ClipboardEvent extends SyntheticEvent { + clipboardData: DataTransfer; + } + + interface KeyboardEvent extends SyntheticEvent { + altKey: boolean; + charCode: number; + ctrlKey: boolean; + getModifierState(key: string): boolean; + key: string; + keyCode: number; + locale: string; + location: number; + metaKey: boolean; + repeat: boolean; + shiftKey: boolean; + which: number; + } + + interface FocusEvent extends SyntheticEvent { + relatedTarget: EventTarget; + } + + interface FormEvent extends SyntheticEvent { + } + + interface MouseEvent extends SyntheticEvent { + altKey: boolean; + button: number; + buttons: number; + clientX: number; + clientY: number; + ctrlKey: boolean; + getModifierState(key: string): boolean; + metaKey: boolean; + pageX: number; + pageY: number; + relatedTarget: EventTarget; + screenX: number; + screenY: number; + shiftKey: boolean; + } + + interface TouchEvent extends SyntheticEvent { + altKey: boolean; + changedTouches: TouchList; + ctrlKey: boolean; + getModifierState(key: string): boolean; + metaKey: boolean; + shiftKey: boolean; + targetTouches: TouchList; + touches: TouchList; + } + + interface UIEvent extends SyntheticEvent { + detail: number; + view: AbstractView; + } + + interface WheelEvent extends SyntheticEvent { + deltaMode: number; + deltaX: number; + deltaY: number; + deltaZ: number; + } + + // + // Event Handler Types + // ---------------------------------------------------------------------- + + interface EventHandler { + (event: E): void; + } + + interface ClipboardEventHandler extends EventHandler {} + interface KeyboardEventHandler extends EventHandler {} + interface FocusEventHandler extends EventHandler {} + interface FormEventHandler extends EventHandler {} + interface MouseEventHandler extends EventHandler {} + interface TouchEventHandler extends EventHandler {} + interface UIEventHandler extends EventHandler {} + interface WheelEventHandler extends EventHandler {} + + // + // Attributes + // ---------------------------------------------------------------------- + + interface ReactAttributes { + children?: ReactNode; + key?: number | string; + ref?: string; + + // Event Attributes + onCopy?: ClipboardEventHandler; + onCut?: ClipboardEventHandler; + onPaste?: ClipboardEventHandler; + onKeyDown?: KeyboardEventHandler; + onKeyPress?: KeyboardEventHandler; + onKeyUp?: KeyboardEventHandler; + onFocus?: FocusEventHandler; + onBlur?: FocusEventHandler; + onChange?: FormEventHandler; + onInput?: FormEventHandler; + onSubmit?: FormEventHandler; + onClick?: MouseEventHandler; + onDoubleClick?: MouseEventHandler; + onDrag?: MouseEventHandler; + onDragEnd?: MouseEventHandler; + onDragEnter?: MouseEventHandler; + onDragExit?: MouseEventHandler; + onDragLeave?: MouseEventHandler; + onDragOver?: MouseEventHandler; + onDragStart?: MouseEventHandler; + onDrop?: MouseEventHandler; + onMouseDown?: MouseEventHandler; + onMouseEnter?: MouseEventHandler; + onMouseLeave?: MouseEventHandler; + onMouseMove?: MouseEventHandler; + onMouseOut?: MouseEventHandler; + onMouseOver?: MouseEventHandler; + onMouseUp?: MouseEventHandler; + onTouchCancel?: TouchEventHandler; + onTouchEnd?: TouchEventHandler; + onTouchMove?: TouchEventHandler; + onTouchStart?: TouchEventHandler; + onScroll?: UIEventHandler; + onWheel?: WheelEventHandler; + + dangerouslySetInnerHTML?: { + __html: string; + }; + } + + interface CSSProperties { + columnCount?: number; + flex?: number | string; + flexGrow?: number; + flexShrink?: number; + fontWeight?: number; + lineClamp?: number; + lineHeight?: number; + opacity?: number; + order?: number; + orphans?: number; + widows?: number; + zIndex?: number; + zoom?: number; + + // SVG-related properties + fillOpacity?: number; + strokeOpacity?: number; + } + + interface HTMLAttributes extends ReactAttributes { + accept?: string; + acceptCharset?: string; + accessKey?: string; + action?: string; + allowFullScreen?: boolean; + allowTransparency?: boolean; + alt?: string; + async?: boolean; + autoComplete?: boolean; + autoFocus?: boolean; + autoPlay?: boolean; + cellPadding?: number | string; + cellSpacing?: number | string; + charSet?: string; + checked?: boolean; + classID?: string; + className?: string; + cols?: number; + colSpan?: number; + content?: string; + contentEditable?: boolean; + contextMenu?: string; + controls?: any; + coords?: string; + crossOrigin?: string; + data?: string; + dateTime?: string; + defer?: boolean; + dir?: string; + disabled?: boolean; + download?: any; + draggable?: boolean; + encType?: string; + form?: string; + formNoValidate?: boolean; + frameBorder?: number | string; + height?: number | string; + hidden?: boolean; + href?: string; + hrefLang?: string; + htmlFor?: string; + httpEquiv?: string; + icon?: string; + id?: string; + label?: string; + lang?: string; + list?: string; + loop?: boolean; + manifest?: string; + max?: number | string; + maxLength?: number; + media?: string; + mediaGroup?: string; + method?: string; + min?: number | string; + multiple?: boolean; + muted?: boolean; + name?: string; + noValidate?: boolean; + open?: boolean; + pattern?: string; + placeholder?: string; + poster?: string; + preload?: string; + radioGroup?: string; + readOnly?: boolean; + rel?: string; + required?: boolean; + role?: string; + rows?: number; + rowSpan?: number; + sandbox?: string; + scope?: string; + scrollLeft?: number; + scrolling?: string; + scrollTop?: number; + seamless?: boolean; + selected?: boolean; + shape?: string; + size?: number; + sizes?: string; + span?: number; + spellCheck?: boolean; + src?: string; + srcDoc?: string; + srcSet?: string; + start?: number; + step?: number | string; + style?: CSSProperties; + tabIndex?: number; + target?: string; + title?: string; + type?: string; + useMap?: string; + value?: string; + width?: number | string; + wmode?: string; + + // Non-standard Attributes + autoCapitalize?: boolean; + autoCorrect?: boolean; + property?: string; + itemProp?: string; + itemScope?: boolean; + itemType?: string; + } + + interface SVGAttributes extends ReactAttributes { + cx?: SVGLength | SVGAnimatedLength; + cy?: any; + d?: string; + dx?: SVGLength | SVGAnimatedLength; + dy?: SVGLength | SVGAnimatedLength; + fill?: any; // SVGPaint | string + fillOpacity?: number | string; + fontFamily?: string; + fontSize?: number | string; + fx?: SVGLength | SVGAnimatedLength; + fy?: SVGLength | SVGAnimatedLength; + gradientTransform?: SVGTransformList | SVGAnimatedTransformList; + gradientUnits?: string; + markerEnd?: string; + markerMid?: string; + markerStart?: string; + offset?: number | string; + opacity?: number | string; + patternContentUnits?: string; + patternUnits?: string; + points?: string; + preserveAspectRatio?: string; + r?: SVGLength | SVGAnimatedLength; + rx?: SVGLength | SVGAnimatedLength; + ry?: SVGLength | SVGAnimatedLength; + spreadMethod?: string; + stopColor?: any; // SVGColor | string + stopOpacity?: number | string; + stroke?: any; // SVGPaint + strokeDasharray?: string; + strokeLinecap?: string; + strokeOpacity?: number | string; + strokeWidth?: SVGLength | SVGAnimatedLength; + textAnchor?: string; + transform?: SVGTransformList | SVGAnimatedTransformList; + version?: string; + viewBox?: string; + x1?: SVGLength | SVGAnimatedLength; + x2?: SVGLength | SVGAnimatedLength; + x?: SVGLength | SVGAnimatedLength; + y1?: SVGLength | SVGAnimatedLength; + y2?: SVGLength | SVGAnimatedLength + y?: SVGLength | SVGAnimatedLength; + } + + // + // React.DOM + // ---------------------------------------------------------------------- + + interface ReactDOM { + // HTML + a: HTMLFactory; + abbr: HTMLFactory; + address: HTMLFactory; + area: HTMLFactory; + article: HTMLFactory; + aside: HTMLFactory; + audio: HTMLFactory; + b: HTMLFactory; + base: HTMLFactory; + bdi: HTMLFactory; + bdo: HTMLFactory; + big: HTMLFactory; + blockquote: HTMLFactory; + body: HTMLFactory; + br: HTMLFactory; + button: HTMLFactory; + canvas: HTMLFactory; + caption: HTMLFactory; + cite: HTMLFactory; + code: HTMLFactory; + col: HTMLFactory; + colgroup: HTMLFactory; + data: HTMLFactory; + datalist: HTMLFactory; + dd: HTMLFactory; + del: HTMLFactory; + details: HTMLFactory; + dfn: HTMLFactory; + dialog: HTMLFactory; + div: HTMLFactory; + dl: HTMLFactory; + dt: HTMLFactory; + em: HTMLFactory; + embed: HTMLFactory; + fieldset: HTMLFactory; + figcaption: HTMLFactory; + figure: HTMLFactory; + footer: HTMLFactory; + form: HTMLFactory; + h1: HTMLFactory; + h2: HTMLFactory; + h3: HTMLFactory; + h4: HTMLFactory; + h5: HTMLFactory; + h6: HTMLFactory; + head: HTMLFactory; + header: HTMLFactory; + hr: HTMLFactory; + html: HTMLFactory; + i: HTMLFactory; + iframe: HTMLFactory; + img: HTMLFactory; + input: HTMLFactory; + ins: HTMLFactory; + kbd: HTMLFactory; + keygen: HTMLFactory; + label: HTMLFactory; + legend: HTMLFactory; + li: HTMLFactory; + link: HTMLFactory; + main: HTMLFactory; + map: HTMLFactory; + mark: HTMLFactory; + menu: HTMLFactory; + menuitem: HTMLFactory; + meta: HTMLFactory; + meter: HTMLFactory; + nav: HTMLFactory; + noscript: HTMLFactory; + object: HTMLFactory; + ol: HTMLFactory; + optgroup: HTMLFactory; + option: HTMLFactory; + output: HTMLFactory; + p: HTMLFactory; + param: HTMLFactory; + picture: HTMLFactory; + pre: HTMLFactory; + progress: HTMLFactory; + q: HTMLFactory; + rp: HTMLFactory; + rt: HTMLFactory; + ruby: HTMLFactory; + s: HTMLFactory; + samp: HTMLFactory; + script: HTMLFactory; + section: HTMLFactory; + select: HTMLFactory; + small: HTMLFactory; + source: HTMLFactory; + span: HTMLFactory; + strong: HTMLFactory; + style: HTMLFactory; + sub: HTMLFactory; + summary: HTMLFactory; + sup: HTMLFactory; + table: HTMLFactory; + tbody: HTMLFactory; + td: HTMLFactory; + textarea: HTMLFactory; + tfoot: HTMLFactory; + th: HTMLFactory; + thead: HTMLFactory; + time: HTMLFactory; + title: HTMLFactory; + tr: HTMLFactory; + track: HTMLFactory; + u: HTMLFactory; + ul: HTMLFactory; + "var": HTMLFactory; + video: HTMLFactory; + wbr: HTMLFactory; + + // SVG + circle: SVGFactory; + defs: SVGFactory; + ellipse: SVGFactory; + g: SVGFactory; + line: SVGFactory; + linearGradient: SVGFactory; + mask: SVGFactory; + path: SVGFactory; + pattern: SVGFactory; + polygon: SVGFactory; + polyline: SVGFactory; + radialGradient: SVGFactory; + rect: SVGFactory; + stop: SVGFactory; + svg: SVGFactory; + text: SVGFactory; + tspan: SVGFactory; + } + + // + // React.PropTypes + // ---------------------------------------------------------------------- + + interface Validator { + (object: T, key: string, componentName: string): Error; + } + + interface Requireable extends Validator { + isRequired: Validator; + } + + interface ValidationMap { + [key: string]: Validator; + } + + interface ReactPropTypes { + any: Requireable; + array: Requireable; + bool: Requireable; + func: Requireable; + number: Requireable; + object: Requireable; + string: Requireable; + node: Requireable; + element: Requireable; + instanceOf(expectedClass: {}): Requireable; + oneOf(types: any[]): Requireable; + oneOfType(types: Validator[]): Requireable; + arrayOf(type: Validator): Requireable; + objectOf(type: Validator): Requireable; + shape(type: ValidationMap): Requireable; + } + + // + // React.Children + // ---------------------------------------------------------------------- + + interface ReactChildren { + map(children: ReactNode, fn: (child: ReactChild) => T): { [key:string]: T }; + forEach(children: ReactNode, fn: (child: ReactChild) => any): void; + count(children: ReactNode): number; + only(children: ReactNode): ReactChild; + } + + // + // React.addons + // ---------------------------------------------------------------------- + + export var addons: { + CSSTransitionGroup: CSSTransitionGroup; + LinkedStateMixin: LinkedStateMixin; + PureRenderMixin: PureRenderMixin; + TransitionGroup: TransitionGroup; + + batchedUpdates(callback: (a: A, b: B) => any, a: A, b: B): void; + batchedUpdates(callback: (a: A) => any, a: A): void; + batchedUpdates(callback: () => any): void; + + // deprecated: use petehunt/react-classset or JedWatson/classnames + classSet(cx: { [key: string]: boolean }): string; + classSet(...classList: string[]): string; + + cloneWithProps

(element: ReactElement

, props: P): ReactElement

; + + update(value: any[], spec: UpdateArraySpec): any[]; + update(value: {}, spec: UpdateSpec): any; + + // Development tools + Perf: ReactPerf; + TestUtils: ReactTestUtils; + }; + + // + // React.addons (Transitions) + // ---------------------------------------------------------------------- + + type ReactType = ComponentClass | string; + + interface TransitionGroupProps { + component?: ReactType; + childFactory?: (child: ReactElement) => ReactElement; + } + + interface CSSTransitionGroupProps extends TransitionGroupProps { + transitionName: string; + transitionAppear?: boolean; + transitionEnter?: boolean; + transitionLeave?: boolean; + } + + type CSSTransitionGroup = + ComponentClass; + type TransitionGroup = + ComponentClass; + + // + // React.addons (Mixins) + // ---------------------------------------------------------------------- + + interface ReactLink { + value: T; + requestChange(newValue: T): void; + } + + interface LinkedStateMixin extends Mixin { + linkState(key: string): ReactLink; + } + + interface PureRenderMixin extends Mixin { + } + + // + // Reat.addons.update + // ---------------------------------------------------------------------- + + interface UpdateSpec { + $set: any; + $merge: {}; + $apply(value: any): any; + // [key: string]: UpdateSpec; + } + + interface UpdateArraySpec extends UpdateSpec { + $push?: any[]; + $unshift?: any[]; + $splice?: any[][]; + } + + // + // React.addons.Perf + // ---------------------------------------------------------------------- + + interface ComponentPerfContext { + current: string; + owner: string; + } + + interface NumericPerfContext { + [key: string]: number; + } + + interface Measurements { + exclusive: NumericPerfContext; + inclusive: NumericPerfContext; + render: NumericPerfContext; + counts: NumericPerfContext; + writes: NumericPerfContext; + displayNames: { + [key: string]: ComponentPerfContext; + }; + totalTime: number; + } + + interface ReactPerf { + start(): void; + stop(): void; + printInclusive(measurements: Measurements[]): void; + printExclusive(measurements: Measurements[]): void; + printWasted(measurements: Measurements[]): void; + printDOM(measurements: Measurements[]): void; + getLastMeasurements(): Measurements[]; + } + + // + // React.addons.TestUtils + // ---------------------------------------------------------------------- + + interface MockedComponentClass { + new(): any; + } + + interface ReactTestUtils { + Simulate: Simulate; + + renderIntoDocument

(element: ReactElement

): Component; + renderIntoDocument>(element: ReactElement): C; + + mockComponent(mocked: MockedComponentClass, mockTagName?: string): ReactTestUtils; + + isElementOfType(element: ReactElement, type: ReactType): boolean; + isTextComponent(instance: Component): boolean; + isDOMComponent(instance: Component): boolean; + isCompositeComponent(instance: Component): boolean; + isCompositeComponentWithType( + instance: Component, + type: ComponentClass): boolean; + + findAllInRenderedTree( + tree: Component, + fn: (i: Component) => boolean): Component; + + scryRenderedDOMComponentsWithClass( + tree: Component, + className: string): DOMComponent[]; + findRenderedDOMComponentWithClass( + tree: Component, + className: string): DOMComponent; + + scryRenderedDOMComponentsWithTag( + tree: Component, + tagName: string): DOMComponent[]; + findRenderedDOMComponentWithTag( + tree: Component, + tagName: string): DOMComponent; + + scryRenderedComponentsWithType( + tree: Component, + type: ComponentClass): Component[]; + scryRenderedComponentsWithType>( + tree: Component, + type: ComponentClass): C[]; + + findRenderedComponentWithType( + tree: Component, + type: ComponentClass): Component; + findRenderedComponentWithType>( + tree: Component, + type: ComponentClass): C; + } + + interface SyntheticEventData { + altKey?: boolean; + button?: number; + buttons?: number; + clientX?: number; + clientY?: number; + changedTouches?: TouchList; + charCode?: boolean; + clipboardData?: DataTransfer; + ctrlKey?: boolean; + deltaMode?: number; + deltaX?: number; + deltaY?: number; + deltaZ?: number; + detail?: number; + getModifierState?(key: string): boolean; + key?: string; + keyCode?: number; + locale?: string; + location?: number; + metaKey?: boolean; + pageX?: number; + pageY?: number; + relatedTarget?: EventTarget; + repeat?: boolean; + screenX?: number; + screenY?: number; + shiftKey?: boolean; + targetTouches?: TouchList; + touches?: TouchList; + view?: AbstractView; + which?: number; + } + + interface EventSimulator { + (element: Element, eventData?: SyntheticEventData): void; + (descriptor: Component, eventData?: SyntheticEventData): void; + } + + interface Simulate { + blur: EventSimulator; + change: EventSimulator; + click: EventSimulator; + cut: EventSimulator; + doubleClick: EventSimulator; + drag: EventSimulator; + dragEnd: EventSimulator; + dragEnter: EventSimulator; + dragExit: EventSimulator; + dragLeave: EventSimulator; + dragOver: EventSimulator; + dragStart: EventSimulator; + drop: EventSimulator; + focus: EventSimulator; + input: EventSimulator; + keyDown: EventSimulator; + keyPress: EventSimulator; + keyUp: EventSimulator; + mouseDown: EventSimulator; + mouseEnter: EventSimulator; + mouseLeave: EventSimulator; + mouseMove: EventSimulator; + mouseOut: EventSimulator; + mouseOver: EventSimulator; + mouseUp: EventSimulator; + paste: EventSimulator; + scroll: EventSimulator; + submit: EventSimulator; + touchCancel: EventSimulator; + touchEnd: EventSimulator; + touchMove: EventSimulator; + touchStart: EventSimulator; + wheel: EventSimulator; + } + + // + // Browser Interfaces + // https://github.com/nikeee/2048-typescript/blob/master/2048/js/touch.d.ts + // ---------------------------------------------------------------------- + + interface AbstractView { + styleMedia: StyleMedia; + document: Document; + } + + interface Touch { + identifier: number; + target: EventTarget; + screenX: number; + screenY: number; + clientX: number; + clientY: number; + pageX: number; + pageY: number; + } + + interface TouchList { + [index: number]: Touch; + length: number; + item(index: number): Touch; + identifiedTouch(identifier: number): Touch; + } +} + From 42c7718ad5ad711eae79c2f8d2c10e8fd7c491a7 Mon Sep 17 00:00:00 2001 From: "EWOUT-QMINO\\Ewout" Date: Tue, 10 Feb 2015 08:55:17 +0100 Subject: [PATCH 009/185] Added return types where necessary. --- jointjs/jointjs.d.ts | 39 ++++++++++++++++++++------------------- rappid/rappid.d.ts | 14 +++++++------- 2 files changed, 27 insertions(+), 26 deletions(-) diff --git a/jointjs/jointjs.d.ts b/jointjs/jointjs.d.ts index 483523d67..5d2257ffd 100644 --- a/jointjs/jointjs.d.ts +++ b/jointjs/jointjs.d.ts @@ -17,24 +17,25 @@ declare module joint { } class Graph extends Backbone.Model { - initialize(); - fromJSON(json:any); - clear(); - addCell(cell:Cell); - addCells(cells:Cell[]); + addCell(cell:Cell) : void; + addCells(cells:Cell[]) : void; + initialize() : void; + fromJSON(json:any) : void; + toJSON() : Object; + clear() : void; getConnectedLinks(cell:Cell, opt?:any):Link[]; - disconnectLinks(cell:Cell); - removeLinks(cell:Cell); + disconnectLinks(cell:Cell) : void; + removeLinks(cell:Cell) : void; findModelsFromPoint(point:{x : number; y: number}):Element[]; } class Cell extends Backbone.Model { - toJSON(); - remove(options?:any); - toFront(); - toBack(); - embed(cell:Cell); - unembed(cell:Cell); + toJSON() : Object; + remove(options?:any) : void; + toFront() : void; + toBack() : void; + embed(cell:Cell) : void; + unembed(cell:Cell) : void; getEmbeddedCells():Cell[]; clone(opt?:any):Backbone.Model; // @todo: return can either be Cell or Cell[]. attr(attrs:any):Cell; @@ -69,7 +70,7 @@ declare module joint { class Paper extends Backbone.View { options:IOptions; - setDimensions(width:number, height:number); + setDimensions(width:number, height:number) : void; scale(sx:number, sy?:number, ox?:number, oy?:number):Paper; rotate(deg:number, ox?:number, oy?:number):Paper; // @todo not released yet though it's in the source code already findView(el:any):CellView; @@ -80,15 +81,15 @@ declare module joint { } class ElementView extends CellView { - scale(sx:number, sy:number); + scale(sx:number, sy:number) : void; } class CellView extends Backbone.View { getBBox():{ x: number; y: number; width: number; height: number; }; - highlight(el?:any); - unhighlight(el?:any); - findMagnet(el:any); - getSelector(el:any); + highlight(el?:any): void; + unhighlight(el?:any): void; + findMagnet(el:any): void; + getSelector(el:any): void; pointerdblclick(evt:any, x:number, y:number):void; pointerclick(evt:any, x:number, y:number):void; diff --git a/rappid/rappid.d.ts b/rappid/rappid.d.ts index 2b3aaf4e2..9cc438884 100644 --- a/rappid/rappid.d.ts +++ b/rappid/rappid.d.ts @@ -25,14 +25,14 @@ declare module joint{ model : Backbone.Collection }); - createSelectionBox(cellView:joint.dia.CellView); - destroySelectionBox(cellView:joint.dia.CellView); - startSelecting(evt:any); - cancelSelection(); + createSelectionBox(cellView:joint.dia.CellView) : void; + destroySelectionBox(cellView:joint.dia.CellView) : void; + startSelecting(evt:any) : void; + cancelSelection() : void; - addHandle(handle:Handle); - removeHandle(name:string); - changeHandle(name:string, handle:Handle); + addHandle(handle:Handle) : void; + removeHandle(name:string) : void; + changeHandle(name:string, handle:Handle) : void; } } } \ No newline at end of file From 24ef5a1d8aaa61548a42e54891f86023d06c3f5a Mon Sep 17 00:00:00 2001 From: "EWOUT-QMINO\\Ewout" Date: Tue, 10 Feb 2015 09:04:47 +0100 Subject: [PATCH 010/185] Fixed Element rotate (and also updated to current jointjs api) --- jointjs/jointjs.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jointjs/jointjs.d.ts b/jointjs/jointjs.d.ts index 5d2257ffd..5917f1811 100644 --- a/jointjs/jointjs.d.ts +++ b/jointjs/jointjs.d.ts @@ -45,7 +45,7 @@ declare module joint { position(x:number, y:number):Element; translate(tx:number, ty?:number):Element; resize(width:number, height:number):Element; - rotate(angle:number, absolute):Element; + rotate(angle:number, options : {absolute : boolean; origin: {x:number;y:number}}):Element; } interface IDefaults { From 7aa6024ba2db7b2e5b8ccee44168c6d362ddb37b Mon Sep 17 00:00:00 2001 From: "EWOUT-QMINO\\Ewout" Date: Tue, 10 Feb 2015 09:08:35 +0100 Subject: [PATCH 011/185] Removed snapToGrid as it doesn't seem to be part of the public JointJS API. --- jointjs/jointjs.d.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/jointjs/jointjs.d.ts b/jointjs/jointjs.d.ts index 5917f1811..cf5efdc5b 100644 --- a/jointjs/jointjs.d.ts +++ b/jointjs/jointjs.d.ts @@ -1,7 +1,6 @@ // Type definitions for Joint JS 0.9.3 // Project: http://www.jointjs.com/ -// Definitions by: Aidan Reel , -// David Durman , Ewout Van Gossum +// Definitions by: Aidan Reel , David Durman , Ewout Van Gossum // Definitions: https://github.com/borisyankov/DefinitelyTyped /// @@ -77,7 +76,6 @@ declare module joint { findViewByModel(modelOrId:any):CellView; findViewsFromPoint(p:{ x: number; y: number; }):CellView[]; findViewsInArea(r:{ x: number; y: number; width: number; height: number; }):CellView[]; - snapToGrid(p):{ x: number; y: number; }; } class ElementView extends CellView { From 427d97003e0cb8754a63fb9c6577606322c70634 Mon Sep 17 00:00:00 2001 From: Wim Looman Date: Thu, 12 Feb 2015 16:22:00 +1300 Subject: [PATCH 012/185] Change leaflet to use interfaces to allow for plugins --- leaflet/leaflet.d.ts | 669 +++++++++++++++++++++++-------------------- 1 file changed, 356 insertions(+), 313 deletions(-) diff --git a/leaflet/leaflet.d.ts b/leaflet/leaflet.d.ts index ff90fb479..61ba2b3b9 100644 --- a/leaflet/leaflet.d.ts +++ b/leaflet/leaflet.d.ts @@ -36,19 +36,21 @@ declare module L { */ export function bounds(points: Point[]): Bounds; - export class Bounds { + export var Bounds: { /** * Creates a Bounds object from two coordinates (usually top-left and bottom-right * corners). */ - constructor(topLeft: Point, bottomRight: Point); - + new(topLeft: Point, bottomRight: Point): Bounds; + /** * Creates a Bounds object defined by the points it contains. */ - constructor(points: Point[]); + new(points: Point[]): Bounds; + }; + export interface Bounds { /** * Extends the bounds to contain the given point. */ @@ -98,74 +100,74 @@ declare module L { declare module L { - export class Browser { + module Browser { /** * true for all Internet Explorer versions. */ - static ie: boolean; + export var ie: boolean; /** * true for Internet Explorer 6. */ - static ie6: boolean; + export var ie6: boolean; /** * true for Internet Explorer 6. */ - static ie7: boolean; + export var ie7: boolean; /** * true for webkit-based browsers like Chrome and Safari (including mobile * versions). */ - static webkit: boolean; + export var webkit: boolean; /** * true for webkit-based browsers that support CSS 3D transformations. */ - static webkit3d: boolean; + export var webkit3d: boolean; /** * true for Android mobile browser. */ - static android: boolean; + export var android: boolean; /** * true for old Android stock browsers (2 and 3). */ - static android23: boolean; + export var android23: boolean; /** * true for modern mobile browsers (including iOS Safari and different Android * browsers). */ - static mobile: boolean; + export var mobile: boolean; /** * true for mobile webkit-based browsers. */ - static mobileWebkit: boolean; + export var mobileWebkit: boolean; /** * true for mobile Opera. */ - static mobileOpera: boolean; + export var mobileOpera: boolean; /** * true for all browsers on touch devices. */ - static touch: boolean; + export var touch: boolean; /** * true for browsers with Microsoft touch model (e.g. IE10). */ - static msTouch: boolean; + export var msTouch: boolean; /** * true for devices with Retina screens. */ - static retina: boolean; + export var retina: boolean; } } @@ -179,14 +181,15 @@ declare module L { */ function circle(latlng: LatLng, radius: number, options?: PathOptions): Circle; - export class Circle extends Path { - + export var Circle: { /** * Instantiates a circle object given a geographical point, a radius in meters * and optionally an options object. */ - constructor(latlng: LatLng, radius: number, options?: PathOptions); - + new(latlng: LatLng, radius: number, options?: PathOptions): Circle; + }; + + export interface Circle extends Path { /** * Returns the current geographical position of the circle. */ @@ -224,15 +227,17 @@ declare module L { */ function circleMarker(latlng: LatLng, options?: PathOptions): CircleMarker; - export class CircleMarker extends Circle { + export var CircleMarker: { /** * Instantiates a circle marker given a geographical point and optionally * an options object. The default radius is 10 and can be altered by passing a * "radius" member in the path options object. */ - constructor(latlng: LatLng, options?: PathOptions); + new(latlng: LatLng, options?: PathOptions): CircleMarker; + }; + export interface CircleMarker extends Circle { /** * Sets the position of a circle marker to a new location. */ @@ -281,34 +286,62 @@ declare module L { * L.Class powers the OOP facilities of Leaflet and is used to create * almost all of the Leaflet classes documented. */ - export class Class { + module Class { /** * You use L.Class.extend to define new classes, but you can use the * same method on any class to inherit from it. */ - static extend(options: ClassExtendOptions): any; + function extend(options: ClassExtendOptions): any; /** * You can also use the following shortcut when you just need to make * one additional method call. */ - static addInitHook(methodName: string, ...args: any[]): void; + function addInitHook(methodName: string, ...args: any[]): void; } -} - - - +} + declare module L { - - export class Control extends Class implements IControl { - + export var Control: { /** * Creates a control with the given options. */ - constructor(options?: ControlOptions); + new(options?: ControlOptions): Control; + Zoom: { + /** + * Creates a zoom control. + */ + new(options?: ZoomOptions): Control.Zoom; + }; + + Attribution: { + /** + * Creates an attribution control. + */ + new(options?: AttributionOptions): Control.Attribution; + }; + + Layers: { + /** + * Creates an attribution control with the given layers. Base layers will be + * switched with radio buttons, while overlays will be switched with checkboxes. + */ + new(baseLayers?: any, overlays?: any, options?: LayersOptions): Control.Layers; + }; + + Scale: { + /** + * Creates an scale control with the given options. + */ + new(options?: ScaleOptions): Control.Scale; + }; + + }; + + export interface Control extends IControl { /** * Sets the position of the control. See control positions. */ @@ -352,22 +385,10 @@ declare module L { } module Control { - - export class Zoom extends L.Control { - - /** - * Creates a zoom control. - */ - constructor(options?: ZoomOptions); + export interface Zoom extends L.Control { } - export class Attribution extends L.Control { - - /** - * Creates an attribution control. - */ - constructor(options?: AttributionOptions); - + export interface Attribution extends L.Control { /** * Sets the text before the attributions. */ @@ -385,14 +406,7 @@ declare module L { } - export class Layers extends L.Control implements IEventPowered { - - /** - * Creates an attribution control with the given layers. Base layers will be - * switched with radio buttons, while overlays will be switched with checkboxes. - */ - constructor(baseLayers?: any, overlays?: any, options?: LayersOptions); - + export interface Layers extends L.Control, IEventPowered { /** * Adds a base layer (radio button entry) with the given name to the control. */ @@ -426,43 +440,39 @@ declare module L { off(eventMap?: any, context?: any): Layers; } - export class Scale extends L.Control { - - /** - * Creates an scale control with the given options. - */ - constructor(options?: ScaleOptions); - + export interface Scale extends L.Control { } } - export class control { - + export interface control { /** * Creates a control with the given options. */ function (options?: ControlOptions): Control; + } + + module control { /** * Creates a zoom control. */ - static zoom(options?: ZoomOptions): L.Control.Zoom; + export function zoom(options?: ZoomOptions): L.Control.Zoom; /** * Creates an attribution control. */ - static attribution(options?: AttributionOptions): L.Control.Attribution; + export function attribution(options?: AttributionOptions): L.Control.Attribution; /** * Creates an attribution control with the given layers. Base layers will be * switched with radio buttons, while overlays will be switched with checkboxes. */ - static layers(baseLayers?: any, overlays?: any, options?: LayersOptions): L.Control.Layers; + export function layers(baseLayers?: any, overlays?: any, options?: LayersOptions): L.Control.Layers; /** * Creates an scale control with the given options. */ - static scale(options?: ScaleOptions): L.Control.Scale; + export function scale(options?: ScaleOptions): L.Control.Scale; } } @@ -482,32 +492,32 @@ declare module L { declare module L { - export class CRS { + module CRS { /** * The most common CRS for online maps, used by almost all free and commercial * tile providers. Uses Spherical Mercator projection. Set in by default in * Map's crs option. */ - static EPSG3857: ICRS; + export var EPSG3857: ICRS; /** * A common CRS among GIS enthusiasts. Uses simple Equirectangular projection. */ - static EPSG4326: ICRS; + export var EPSG4326: ICRS; /** * Rarely used by some commercial tile providers. Uses Elliptical Mercator * projection. */ - static EPSG3395: ICRS; + export var EPSG3395: ICRS; /** * A simple CRS that maps longitude and latitude into x and y directly. May be * used for maps of flat surfaces (e.g. game maps). Note that the y axis should * still be inverted (going from bottom to top). */ - static Simple: ICRS; + export var Simple: ICRS; } } @@ -519,12 +529,14 @@ declare module L { */ function divIcon(options: DivIconOptions): DivIcon; - export class DivIcon extends Icon { - + export var DivIcon: { /** * Creates a div icon instance with the given options. */ - constructor(options: DivIconOptions); + new(options: DivIconOptions): DivIcon; + }; + + export interface DivIcon extends Icon { } } @@ -564,20 +576,20 @@ declare module L { declare module L { - export class DomEvent { + export interface DomEvent { /** * Adds a listener fn to the element's DOM event of the specified type. this keyword * inside the listener will point to context, or to the element if not specified. */ - static addListener(el: HTMLElement, type: string, fn: (e: Event) => void, context?: any): DomEvent; - static on(el: HTMLElement, type: string, fn: (e: Event) => void, context?: any): DomEvent; + addListener(el: HTMLElement, type: string, fn: (e: Event) => void, context?: any): DomEvent; + on(el: HTMLElement, type: string, fn: (e: Event) => void, context?: any): DomEvent; /** * Removes an event listener from the element. */ - static removeListener(el: HTMLElement, type: string, fn: (e: Event) => void, context?: any): DomEvent; - static off(el: HTMLElement, type: string, fn: (e: Event) => void, context?: any): DomEvent; + removeListener(el: HTMLElement, type: string, fn: (e: Event) => void, context?: any): DomEvent; + off(el: HTMLElement, type: string, fn: (e: Event) => void, context?: any): DomEvent; /** * Stop the given event from propagation to parent elements. Used inside the @@ -587,116 +599,118 @@ declare module L { * L.DomEvent.stopPropagation(e); * }); */ - static stopPropagation(e: Event): DomEvent; + stopPropagation(e: Event): DomEvent; /** * Prevents the default action of the event from happening (such as following * a link in the href of the a element, or doing a POST request with page reload * when form is submitted). Use it inside listener functions. */ - static preventDefault(e: Event): DomEvent; + preventDefault(e: Event): DomEvent; /** * Does stopPropagation and preventDefault at the same time. */ - static stop(e: Event): DomEvent; + stop(e: Event): DomEvent; /** * Adds stopPropagation to the element's 'click', 'doubleclick', 'mousedown' * and 'touchstart' events. */ - static disableClickPropagation(el: HTMLElement): DomEvent; + disableClickPropagation(el: HTMLElement): DomEvent; /** * Gets normalized mouse position from a DOM event relative to the container * or to the whole page if not specified. */ - static getMousePosition(e: Event, container?: HTMLElement): Point; + getMousePosition(e: Event, container?: HTMLElement): Point; /** * Gets normalized wheel delta from a mousewheel DOM event. */ - static getWheelDelta(e: Event): number; + getWheelDelta(e: Event): number; } + + export var DomEvent: DomEvent; } declare module L { - export class DomUtil { + module DomUtil { /** * Returns an element with the given id if a string was passed, or just returns * the element if it was passed directly. */ - static get(id: string): HTMLElement; + export function get(id: string): HTMLElement; /** * Returns the value for a certain style attribute on an element, including * computed values or values set through CSS. */ - static getStyle(el: HTMLElement, style: string): string; + export function getStyle(el: HTMLElement, style: string): string; /** * Returns the offset to the viewport for the requested element. */ - static getViewportOffset(el: HTMLElement): Point; + export function getViewportOffset(el: HTMLElement): Point; /** * Creates an element with tagName, sets the className, and optionally appends * it to container element. */ - static create(tagName: string, className: string, container?: HTMLElement): HTMLElement; + export function create(tagName: string, className: string, container?: HTMLElement): HTMLElement; /** * Makes sure text cannot be selected, for example during dragging. */ - static disableTextSelection(): void; + export function disableTextSelection(): void; /** * Makes text selection possible again. */ - static enableTextSelection(): void; + export function enableTextSelection(): void; /** * Returns true if the element class attribute contains name. */ - static hasClass(el: HTMLElement, name: string): boolean; + export function hasClass(el: HTMLElement, name: string): boolean; /** * Adds name to the element's class attribute. */ - static addClass(el: HTMLElement, name: string): void; + export function addClass(el: HTMLElement, name: string): void; /** * Removes name from the element's class attribute. */ - static removeClass(el: HTMLElement, name: string): void; + export function removeClass(el: HTMLElement, name: string): void; /** * Set the opacity of an element (including old IE support). Value must be from * 0 to 1. */ - static setOpacity(el: HTMLElement, value: number): void; + export function setOpacity(el: HTMLElement, value: number): void; /** * Goes through the array of style names and returns the first name that is a valid * style name for an element. If no such name is found, it returns false. Useful * for vendor-prefixed styles like transform. */ - static testProp(props: string[]): any; + export function testProp(props: string[]): any; /** * Returns a CSS transform string to move an element by the offset provided in * the given point. Uses 3D translate on WebKit for hardware-accelerated transforms * and 2D on other browsers. */ - static getTranslateString(point: Point): string; + export function getTranslateString(point: Point): string; /** * Returns a CSS transform string to scale an element (with the given scale origin). */ - static getScaleString(scale: number, origin: Point): string; + export function getScaleString(scale: number, origin: Point): string; /** * Sets the position of an element to coordinates specified by point, using @@ -704,22 +718,22 @@ declare module L { * Leaflet internally to position its layers). Forces top/left positioning * if disable3D is true. */ - static setPosition(el: HTMLElement, point: Point, disable3D?: boolean): void; + export function setPosition(el: HTMLElement, point: Point, disable3D?: boolean): void; /** * Returns the coordinates of an element previously positioned with setPosition. */ - static getPosition(el: HTMLElement): Point; + export function getPosition(el: HTMLElement): Point; /** * Vendor-prefixed transition style name (e.g. 'webkitTransition' for WebKit). */ - static TRANSITION: string; + export var TRANSITION: string; /** * Vendor-prefixed transform style name. */ - static TRANSFORM: string; + export var TRANSFORM: string; } } @@ -732,14 +746,16 @@ declare module L { */ function draggable(element: HTMLElement, dragHandle?: HTMLElement): Draggable; - export class Draggable extends Class implements IEventPowered { - + export var Draggable: { /** * Creates a Draggable object for moving the given element when you start dragging * the dragHandle element (equals the element itself by default). */ - constructor(element: HTMLElement, dragHandle?: HTMLElement); - + new(element: HTMLElement, dragHandle?: HTMLElement): Draggable; + }; + + + export interface Draggable extends IEventPowered { /** * Enables the dragging ability. */ @@ -778,13 +794,15 @@ declare module L { */ function featureGroup(layers?: T[]): FeatureGroup; - export class FeatureGroup extends LayerGroup implements ILayer, IEventPowered> { + export var FeatureGroup: { /** * Create a layer group, optionally given an initial set of layers. */ - constructor(layers?: T[]); - + new(layers?: T[]): FeatureGroup; + }; + + export interface FeatureGroup extends LayerGroup, ILayer, IEventPowered> { /** * Binds a popup with a particular HTML content to a click on any layer from the * group that has a bindPopup method. @@ -892,15 +910,36 @@ declare module L { */ function geoJson(geojson?: any, options?: GeoJSONOptions): GeoJSON; - export class GeoJSON extends FeatureGroup { - + export var GeoJSON: { /** * Creates a GeoJSON layer. Optionally accepts an object in GeoJSON format * to display on the map (you can alternatively add it later with addData method) * and an options object. */ - constructor(geojson?: any, options?: GeoJSONOptions); - + new(geojson?: any, options?: GeoJSONOptions): GeoJSON; + + /** + * Creates a layer from a given GeoJSON feature. + */ + geometryToLayer(featureData: GeoJSON, pointToLayer?: (featureData: any, latlng: LatLng) => ILayer): ILayer; + + /** + * Creates a LatLng object from an array of 2 numbers (latitude, longitude) + * used in GeoJSON for points. If reverse is set to true, the numbers will be interpreted + * as (longitude, latitude). + */ + coordsToLatlng(coords: number[], reverse?: boolean): LatLng; + + /** + * Creates a multidimensional array of LatLng objects from a GeoJSON coordinates + * array. levelsDeep specifies the nesting level (0 is for an array of points, + * 1 for an array of arrays of points, etc., 0 by default). If reverse is set to + * true, the numbers will be interpreted as (longitude, latitude). + */ + coordsToLatlngs(coords: number[], levelsDeep?: number, reverse?: boolean): LatLng[]; + }; + + export interface GeoJSON extends FeatureGroup { /** * Adds a GeoJSON object to the layer. */ @@ -921,30 +960,9 @@ declare module L { * useful for resetting style after hover events. */ resetStyle(layer: Path): GeoJSON; - - /** - * Creates a layer from a given GeoJSON feature. - */ - static geometryToLayer(featureData: GeoJSON, pointToLayer?: (featureData: any, latlng: LatLng) => ILayer): ILayer; - - /** - * Creates a LatLng object from an array of 2 numbers (latitude, longitude) - * used in GeoJSON for points. If reverse is set to true, the numbers will be interpreted - * as (longitude, latitude). - */ - static coordsToLatlng(coords: number[], reverse?: boolean): LatLng; - - /** - * Creates a multidimensional array of LatLng objects from a GeoJSON coordinates - * array. levelsDeep specifies the nesting level (0 is for an array of points, - * 1 for an array of arrays of points, etc., 0 by default). If reverse is set to - * true, the numbers will be interpreted as (longitude, latitude). - */ - static coordsToLatlngs(coords: number[], levelsDeep?: number, reverse?: boolean): LatLng[]; - } } - + declare module L { export interface GeoJSONOptions { /** @@ -989,28 +1007,31 @@ declare module L { */ function icon(options: IconOptions): Icon; - export class Icon extends Class { - + export var Icon: { /** * Creates an icon instance with the given options. */ - constructor(options: IconOptions); + new(options: IconOptions): Icon; + + Default: { + /** + * Creates a default icon instance with the given options. + */ + new(options?: IconOptions): Icon.Default; + + imagePath: string; + }; + }; + + export interface Icon { } module Icon { - /** * L.Icon.Default extends L.Icon and is the blue icon Leaflet uses * for markers by default. */ - export class Default extends Icon { - - /** - * Creates a default icon instance with the given options. - */ - constructor(options?: IconOptions); - - static imagePath: string; + export interface Default extends Icon { } } } @@ -1252,7 +1273,7 @@ declare module L { enabled(): boolean; } - export class Handler extends Class { + export interface Handler { initialize(map: Map): void; } } @@ -1277,7 +1298,7 @@ declare module L { } declare module L { - export module Mixin { + module Mixin { export interface LeafletMixinEvents extends IEventPowered { } @@ -1293,14 +1314,15 @@ declare module L { */ function imageOverlay(imageUrl: string, bounds: LatLngBounds, options?: ImageOverlayOptions): ImageOverlay; - export class ImageOverlay extends Class implements ILayer { - + export var ImageOverlay: { /** * Instantiates an image overlay object given the URL of the image and the geographical * bounds it is tied to. */ - constructor(imageUrl: string, bounds: LatLngBounds, options?: ImageOverlayOptions); + new(imageUrl: string, bounds: LatLngBounds, options?: ImageOverlayOptions): ImageOverlay; + }; + export interface ImageOverlay extends ILayer { /** * Adds the overlay to the map. */ @@ -1385,7 +1407,6 @@ declare module L { } declare module L { - /** * Creates an object representing a geographical point with the given latitude * and longitude. @@ -1398,20 +1419,42 @@ declare module L { */ function latLng(coords: number[]): LatLng; - export class LatLng { + export var LatLng: { + /** + * Creates an object representing a geographical point with the given latitude + * and longitude. + */ + new(latitude: number, longitude: number): LatLng; /** * Creates an object representing a geographical point with the given latitude * and longitude. */ - constructor(latitude: number, longitude: number); - - /** - * Creates an object representing a geographical point with the given latitude - * and longitude. - */ - constructor(coords: number[]); + new(coords: number[]): LatLng; + /** + * A multiplier for converting degrees into radians. + * + * Value: Math.PI / 180. + */ + DEG_TO_RAD: number; + + /** + * A multiplier for converting radians into degrees. + * + * Value: 180 / Math.PI. + */ + RAD_TO_DEG: number; + + /** + * Max margin of error for the equality check. + * + * Value: 1.0E-9. + */ + MAX_MARGIN: number; + }; + + export interface LatLng { /** * Returns the distance (in meters) to the given LatLng calculated using the * Haversine formula. See description on wikipedia @@ -1444,30 +1487,9 @@ declare module L { * Longitude in degrees. */ lng: number; - - /** - * A multiplier for converting degrees into radians. - * - * Value: Math.PI / 180. - */ - static DEG_TO_RAD: number; - - /** - * A multiplier for converting radians into degrees. - * - * Value: 180 / Math.PI. - */ - static RAD_TO_DEG: number; - - /** - * Max margin of error for the equality check. - * - * Value: 1.0E-9. - */ - static MAX_MARGIN: number; } } - + declare module L { /** @@ -1482,20 +1504,21 @@ declare module L { */ function latLngBounds(latlngs: LatLng[]): LatLngBounds; - export class LatLngBounds { - + export var LatLngBounds: { /** * Creates a LatLngBounds object by defining south-west and north-east corners * of the rectangle. */ - constructor(southWest: LatLng, northEast: LatLng); - + new(southWest: LatLng, northEast: LatLng): LatLngBounds; + /** * Creates a LatLngBounds object defined by the geographical points it contains. * Very useful for zooming the map to fit a particular set of locations with fitBounds. */ - constructor(latlngs: LatLng[]); + new(latlngs: LatLng[]): LatLngBounds; + }; + export interface LatLngBounds { /** * Extends the bounds to contain the given point. */ @@ -1579,13 +1602,15 @@ declare module L { */ function layerGroup(layers?: T[]): LayerGroup; - export class LayerGroup extends Class implements ILayer { + export var LayerGroup: { /** * Create a layer group, optionally given an initial set of layers. */ - constructor(layers?: T[]); - + new(layers?: T[]): LayerGroup; + }; + + export interface LayerGroup extends ILayer { /** * Adds the group of layers to the map. */ @@ -1886,7 +1911,7 @@ declare module L { declare module L { - export class LineUtil { + module LineUtil { /** * Dramatically reduces the number of points in a polyline while retaining @@ -1896,24 +1921,24 @@ declare module L { * (lesser value means higher quality but slower and with more points). Also * released as a separated micro-library Simplify.js. */ - static simplify(points: Point[], tolerance: number): Point[]; + export function simplify(points: Point[], tolerance: number): Point[]; /** * Returns the distance between point p and segment p1 to p2. */ - static pointToSegmentDistance(p: Point, p1: Point, p2: Point): number; + export function pointToSegmentDistance(p: Point, p1: Point, p2: Point): number; /** * Returns the closest point from a point p on a segment p1 to p2. */ - static closestPointOnSegment(p: Point, p1: Point, p2: Point): number; + export function closestPointOnSegment(p: Point, p1: Point, p2: Point): number; /** * Clips the segment a to b by rectangular bounds (modifying the segment points * directly!). Used by Leaflet to only show polyline points that are on the screen * or near, increasing performance. */ - static clipSegment(a: Point, b: Point, bounds: Bounds): void; + export function clipSegment(a: Point, b: Point, bounds: Bounds): void; } } @@ -1985,15 +2010,15 @@ declare module L { */ function map(id: string, options?: MapOptions): Map; - export class Map extends Class implements IEventPowered { + export var Map: { /** * Instantiates a map object given a div element and optionally an * object literal with map options described below. * * @constructor */ - constructor(id: HTMLElement, options?: MapOptions); + new(id: HTMLElement, options?: MapOptions): Map; /** * Instantiates a map object given a div element id and optionally an @@ -2001,8 +2026,10 @@ declare module L { * * @constructor */ - constructor(id: string, options?: MapOptions); + new(id: string, options?: MapOptions): Map; + }; + export interface Map extends IEventPowered { // Methods for Modifying Map State /** @@ -2357,7 +2384,7 @@ declare module L { off(eventMap?: any, context?: any): Map; } } - + declare module L { export interface MapOptions { @@ -2647,14 +2674,15 @@ declare module L { */ function marker(latlng: LatLng, options?: MarkerOptions): Marker; - export class Marker extends Class implements ILayer, IEventPowered { - + var Marker: { /** * Instantiates a Marker object given a geographical point and optionally * an options object. */ - constructor(latlng: LatLng, options?: MarkerOptions); - + new(latlng: LatLng, options?: MarkerOptions): Marker; + }; + + export interface Marker extends ILayer, IEventPowered { /** * Adds the marker to the map. */ @@ -2877,15 +2905,16 @@ declare module L { */ function multiPolygon(latlngs: LatLng[][], options?: PolylineOptions): MultiPolygon; - export class MultiPolygon extends FeatureGroup { - + export var MultiPolylgon: { /** * Instantiates a multi-polyline object given an array of latlngs arrays (one * for each individual polygon) and optionally an options object (the same * as for MultiPolyline). */ - constructor(latlngs: LatLng[][], options?: PolylineOptions); - + new(latlngs: LatLng[][], options?: PolylineOptions): MultiPolygon; + }; + + export interface MultiPolygon extends FeatureGroup { /** * Replace all polygons and their paths with the given array of arrays * of geographical points. @@ -2917,14 +2946,15 @@ declare module L { */ function multiPolyline(latlngs: LatLng[][], options?: PolylineOptions): MultiPolyline; - export class MultiPolyline extends FeatureGroup { - + export var MultiPolyline: { /** * Instantiates a multi-polyline object given an array of arrays of geographical * points (one for each individual polyline) and optionally an options object. */ - constructor(latlngs: LatLng[][], options?: PolylineOptions); + new(latlngs: LatLng[][], options?: PolylineOptions): MultiPolyline; + }; + export interface MultiPolyline extends FeatureGroup { /** * Replace all polygons and their paths with the given array of arrays * of geographical points. @@ -2986,7 +3016,7 @@ declare module L { declare module L { - export class Path extends Class implements ILayer, IEventPowered { + export interface Path extends ILayer, IEventPowered { /** * Adds the layer to the map. @@ -3049,34 +3079,6 @@ declare module L { * the path uses. */ redraw(): Path; - - /** - * True if SVG is used for vector rendering (true for most modern browsers). - */ - static SVG: boolean; - - /** - * True if VML is used for vector rendering (IE 6-8). - */ - static VML: boolean; - - /** - * True if Canvas is used for vector rendering (Android 2). You can also force - * this by setting global variable L_PREFER_CANVAS to true before the Leaflet - * include on your page — sometimes it can increase performance dramatically - * when rendering thousands of circle markers, but currently suffers from - * a bug that causes removing such layers to be extremely slow. - */ - static CANVAS: boolean; - - /** - * How much to extend the clip area around the map view (relative to its size, - * e.g. 0.5 is half the screen in each direction). Smaller values mean that you - * will see clipped ends of paths while you're dragging the map, and bigger values - * decrease drawing performance. - */ - static CLIP_PADDING: number; - //////////// //////////// /** @@ -3109,8 +3111,37 @@ declare module L { on(eventMap: any, context?: any): Path; off(eventMap?: any, context?: any): Path; } + + module Path { + /** + * True if SVG is used for vector rendering (true for most modern browsers). + */ + export var SVG: boolean; + + /** + * True if VML is used for vector rendering (IE 6-8). + */ + export var VML: boolean; + + /** + * True if Canvas is used for vector rendering (Android 2). You can also force + * this by setting global variable L_PREFER_CANVAS to true before the Leaflet + * include on your page — sometimes it can increase performance dramatically + * when rendering thousands of circle markers, but currently suffers from + * a bug that causes removing such layers to be extremely slow. + */ + export var CANVAS: boolean; + + /** + * How much to extend the clip area around the map view (relative to its size, + * e.g. 0.5 is half the screen in each direction). Smaller values mean that you + * will see clipped ends of paths while you're dragging the map, and bigger values + * decrease drawing performance. + */ + export var CLIP_PADDING: number; + } } - + declare module L { export interface PathOptions { @@ -3215,14 +3246,15 @@ declare module L { */ function point(x: number, y: number, round?: boolean): Point; - export class Point { - + export var Point: { /** * Creates a Point object with the given x and y coordinates. If optional round * is set to true, rounds the x and y values. */ - constructor(x: number, y: number, round?: boolean); + new(x: number, y: number, round?: boolean): Point; + }; + export interface Point { /** * Returns the result of addition of the current and the given points. */ @@ -3292,8 +3324,8 @@ declare module L { */ function polygon(latlngs: LatLng[], options?: PolylineOptions): Polygon; - export class Polygon extends Polyline { + export var Polygon: { /** * Instantiates a polygon object given an array of geographical points and * optionally an options object (the same as for Polyline). You can also create @@ -3301,7 +3333,10 @@ declare module L { * latlngs array representing the exterior ring while the remaining represent * the holes inside. */ - constructor(latlngs: LatLng[], options?: PolylineOptions); + new(latlngs: LatLng[], options?: PolylineOptions): Polygon; + }; + + export interface Polygon extends Polyline { } } @@ -3313,14 +3348,15 @@ declare module L { */ function polyline(latlngs: LatLng[], options?: PolylineOptions): Polyline; - export class Polyline extends Path { - + export var Polyline: { /** * Instantiates a polyline object given an array of geographical points and * optionally an options object. */ - constructor(latlngs: LatLng[], options?: PolylineOptions); - + new(latlngs: LatLng[], options?: PolylineOptions): Polyline; + }; + + export interface Polyline extends Path { /** * Adds a given point to the polyline. */ @@ -3378,7 +3414,7 @@ declare module L { declare module L { - export class PolyUtil { + module PolyUtil { /** * Clips the polygon geometry defined by the given points by rectangular bounds. @@ -3386,7 +3422,7 @@ declare module L { * increasing performance. Note that polygon points needs different algorithm * for clipping than polyline, so there's a seperate method for it. */ - static clipPolygon(points: Point[], bounds: Bounds): Point[]; + export function clipPolygon(points: Point[], bounds: Bounds): Point[]; } } @@ -3399,15 +3435,16 @@ declare module L { */ function popup(options?: PopupOptions, source?: any): Popup; - export class Popup extends Class implements ILayer { - + export var Popup: { /** * Instantiates a Popup object given an optional options object that describes * its appearance and location and an optional object that is used to tag the * popup with a reference to the source object to which it refers. */ - constructor(options?: PopupOptions, source?: any); - + new(options?: PopupOptions, source?: any): Popup; + }; + + export interface Popup extends ILayer { /** * Adds the popup to the map. */ @@ -3557,13 +3594,14 @@ declare module L { declare module L { - export class PosAnimation extends Class implements IEventPowered { - + export var PosAnimation: { /** * Creates a PosAnimation object. */ - constructor(); - + new(): PosAnimation; + }; + + export interface PosAnimation extends IEventPowered { /** * Run an animation of a given element to a new position, optionally setting * duration in seconds (0.25 by default) and easing linearity factor (3rd argument @@ -3592,21 +3630,21 @@ declare module L { declare module L { - export class Projection { + module Projection { /** * Spherical Mercator projection — the most common projection for online maps, * used by almost all free and commercial tile providers. Assumes that Earth * is a sphere. Used by the EPSG:3857 CRS. */ - static SphericalMercator: IProjection; + export var SphericalMercator: IProjection; /** * Elliptical Mercator projection — more complex than Spherical Mercator. * Takes into account that Earth is a geoid, not a perfect sphere. Used by the * EPSG:3395 CRS. */ - static Mercator: IProjection; + export var Mercator: IProjection; /** * Equirectangular, or Plate Carree projection — the most simple projection, @@ -3614,7 +3652,7 @@ declare module L { * Also suitable for flat worlds, e.g. game maps. Used by the EPSG:3395 and Simple * CRS. */ - static LonLat: IProjection; + export var LonLat: IProjection; } } @@ -3626,14 +3664,15 @@ declare module L { */ function rectangle(bounds: LatLngBounds, options?: PathOptions): Rectangle; - export class Rectangle extends Polygon { - + export var Rectangle: { /** * Instantiates a rectangle object with the given geographical bounds and * optionally an options object. */ - constructor(bounds: LatLngBounds, options?: PathOptions); - + new(bounds: LatLngBounds, options?: PathOptions): Rectangle; + }; + + export interface Rectangle extends Polygon { /** * Redraws the rectangle with the passed bounds. */ @@ -3682,14 +3721,30 @@ declare module L { declare module L { - export class TileLayer implements ILayer, IEventPowered { - + export var TileLayer: { /** * Instantiates a tile layer object given a URL template and optionally an options * object. */ - constructor(urlTemplate: string, options?: TileLayerOptions); - + new(urlTemplate: string, options?: TileLayerOptions): TileLayer; + + WMS: { + /** + * Instantiates a WMS tile layer object given a base URL of the WMS service and + * a WMS parameters/options object. + */ + new(baseUrl: string, options: WMSOptions): TileLayer.WMS; + }; + + Canvas: { + /** + * Instantiates a Canvas tile layer object given an options object (optionally). + */ + new(options?: TileLayerOptions): TileLayer.Canvas; + }; + }; + + export interface TileLayer extends ILayer, IEventPowered { /** * Adds the layer to the map. */ @@ -3764,15 +3819,7 @@ declare module L { } module TileLayer { - - export class WMS extends TileLayer { - - /** - * Instantiates a WMS tile layer object given a base URL of the WMS service and - * a WMS parameters/options object. - */ - constructor(baseUrl: string, options: WMSOptions); - + export interface WMS extends TileLayer { /** * Merges an object with the new parameters and re-requests tiles on the current * screen (unless noRedraw was set to true). @@ -3780,13 +3827,7 @@ declare module L { setParams(params: WMS, noRedraw?: boolean): WMS; } - export class Canvas { - - /** - * Instantiates a Canvas tile layer object given an options object (optionally). - */ - constructor(options?: TileLayerOptions); - + export interface Canvas { /** * You need to define this method after creating the instance to draw tiles; * canvas is the actual canvas tile on which you can draw, tilePoint represents @@ -3966,16 +4007,16 @@ declare module L { reuseTiles?: boolean; } } - + declare module L { - - export class Transformation { - + export var Transformation: { /** * Creates a transformation object with the given coefficients. */ - constructor(a: number, b: number, c: number, d: number); - + new(a: number, b: number, c: number, d: number): Transformation; + }; + + export interface Transformation { /** * Returns a transformed point, optionally multiplied by the given scale. * Only accepts real L.Point instances, not arrays. @@ -3992,24 +4033,24 @@ declare module L { declare module L { - export class Util { + module Util { /** * Merges the properties of the src object (or multiple objects) into dest object * and returns the latter. Has an L.extend shortcut. */ - static extend(dest: any, ...sources: any[]): any; + export function extend(dest: any, ...sources: any[]): any; /** * Returns a function which executes function fn with the given scope obj (so * that this keyword refers to obj inside the function code). Has an L.bind shortcut. */ - static bind(fn: T, obj: any): T; + export function bind(fn: T, obj: any): T; /** * Applies a unique key to the object and returns that key. Has an L.stamp shortcut. */ - static stamp(obj: any): string; + export function stamp(obj: any): string; /** * Returns a wrapper around the function fn that makes sure it's called not more @@ -4018,58 +4059,58 @@ declare module L { * the map), optionally passing the scope (context) in which the function will * be called. */ - static limitExecByInterval(fn: T, time: number, context?: any): T; + export function limitExecByInterval(fn: T, time: number, context?: any): T; /** * Returns a function which always returns false. */ - static falseFn(): () => boolean; + export function falseFn(): () => boolean; /** * Returns the number num rounded to digits decimals. */ - static formatNum(num: number, digits: number): number; + export function formatNum(num: number, digits: number): number; /** * Trims and splits the string on whitespace and returns the array of parts. */ - static splitWords(str: string): string[]; + export function splitWords(str: string): string[]; /** * Merges the given properties to the options of the obj object, returning the * resulting options. See Class options. Has an L.setOptions shortcut. */ - static setOptions(obj: any, options: any): any; + export function setOptions(obj: any, options: any): any; /** * Converts an object into a parameter URL string, e.g. {a: "foo", b: "bar"} * translates to '?a=foo&b=bar'. */ - static getParamString(obj: any): string; + export function getParamString(obj: any): string; /** * Simple templating facility, creates a string by applying the values of the * data object of a form {a: 'foo', b: 'bar', …} to a template string of the form * 'Hello {a}, {b}' — in this example you will get 'Hello foo, bar'. */ - static template(str: string, data: any): string; + export function template(str: string, data: any): string; /** * Returns true if the given object is an array. */ - static isArray(obj: any): boolean; + export function isArray(obj: any): boolean; /** * Trims the whitespace from both ends of the string and returns the result. */ - static trim(str: string): string; + export function trim(str: string): string; /** * Data URI string containing a base64-encoded empty GIF image. Used as a hack * to free memory from unused images on WebKit-powered mobile devices (by setting * image src to this string). */ - static emptyImageUrl: string; + export var emptyImageUrl: string; } } @@ -4182,3 +4223,5 @@ declare var L_DISABLE_3D: boolean; declare module "leaflet" { export = L; } + +// vim: et ts=4 sw=4 From 66597850ba9b562d3d1f24a34d1c6be643bbdabc Mon Sep 17 00:00:00 2001 From: Wim Looman Date: Thu, 12 Feb 2015 16:46:14 +1300 Subject: [PATCH 013/185] Add definitions for Leaflet.label --- leaflet-label/leaflet-label-tests.ts | 140 +++++++++++++++++++++++++++ leaflet-label/leaflet-label.d.ts | 70 ++++++++++++++ 2 files changed, 210 insertions(+) create mode 100644 leaflet-label/leaflet-label-tests.ts create mode 100644 leaflet-label/leaflet-label.d.ts diff --git a/leaflet-label/leaflet-label-tests.ts b/leaflet-label/leaflet-label-tests.ts new file mode 100644 index 000000000..884f5f67e --- /dev/null +++ b/leaflet-label/leaflet-label-tests.ts @@ -0,0 +1,140 @@ +/// + +var map: L.Map; +var label: L.Label; + +// Icon +var icon: L.Icon = new L.Icon({ labelAnchor: L.point(1, 1) }); + +// CircleMarker +var circleMarker: L.CircleMarker = new L.CircleMarker(new L.LatLng(0, 0), { labelAnchor: L.point(1, 1) }); + +circleMarker = circleMarker.bindLabel('test', { + className: 'thingy', + clickable: true, + direction: 'right', + noHide: false, + offset: new L.Point(0, 0), + opacity: 0.5, + zoomAnimation: true, +}); + +circleMarker.showLabel(); +circleMarker.hideLabel(); +circleMarker.setLabelNoHide(true); +circleMarker.updateLabelContent('test2'); +label = circleMarker.getLabel() +circleMarker = circleMarker.unbindLabel(); + +// Marker +var marker = new L.Marker(new L.LatLng(0, 0)); + +marker = marker.bindLabel('test', { + className: 'thingy', + clickable: true, + direction: 'right', + noHide: false, + offset: new L.Point(0, 0), + opacity: 0.5, + zoomAnimation: true, +}); + +marker.showLabel(); +marker.hideLabel(); +marker.setLabelNoHide(true); +marker.updateLabelContent('test2'); +label = marker.getLabel() +marker = marker.unbindLabel(); +marker.setOpacity(0.5); +marker.setOpacity(0.5, true); + +// Path +var path: L.Path = new L.Polyline([L.latLng(0, 0)]); + +path = path.bindLabel('test', { + className: 'thingy', + clickable: true, + direction: 'right', + noHide: false, + offset: new L.Point(0, 0), + opacity: 0.5, + zoomAnimation: true, +}); + +path.updateLabelContent('test2'); + +path = path.unbindLabel(); + +// Label + +label.setOpacity(0.7); +label.updateZIndex(5); +label.setLatLng(new L.LatLng(3, 3)); +label.setContent('thing'); +label.close(); + +// Examples from the README +var example: () => void; + +example = () => { + L.marker(L.latLng(-37.7772, 175.2606)).bindLabel('Look revealing label!').addTo(map); +}; + +example = () => { + L.polyline([ + L.latLng(-37.7612, 175.2756), + L.latLng(-37.7702, 175.2796), + L.latLng(-37.7802, 175.2750), + ]).bindLabel('Even polylines can have labels.').addTo(map); +}; + +example = () => { + L.marker(L.latLng(-37.785, 175.263)) + .bindLabel('A sweet static label!', { noHide: true }) + .addTo(map); +}; + +example = () => { + var myIcon = L.icon({ + iconUrl: 'my-icon.png', + iconSize: L.point(20, 20), + iconAnchor: L.point(10, 10), + labelAnchor: L.point(6, 0) // as I want the label to appear 2px past the icon (10 + 2 - 6) + }); + L.marker(L.latLng(-37.7772, 175.2606), { + icon: myIcon + }).bindLabel('My label', { + noHide: true, + direction: 'auto' + }); +}; + +example = () => { + var myIcon = L.icon({ + iconUrl: 'my-icon.png', + iconSize: L.point(20, 20), + iconAnchor: L.point(10, 10), + labelAnchor: L.point(6, 0) // as I want the label to appear 2px past the icon (10 + 2 - 6) + }); + L.marker(L.latLng(-37.7772, 175.2606), { + icon: myIcon + }).bindLabel('Look revealing label!').addTo(map); +}; + +example = () => { + var markerLabel = L.marker(L.latLng(-37.7772, 175.2606)).bindLabel('Look revealing label!').addTo(map); + + // Sets opacity of marker to 0.3 and opacity of label to 1 + markerLabel.setOpacity(0.3); + + // Sets opacity of marker to 0.3 and opacity of label to 0.3 + markerLabel.setOpacity(0.3, true); + + // Sets opacity of marker to 0 and opacity of label to 0 + markerLabel.setOpacity(0); + markerLabel.setOpacity(0, true); + + // Sets opacity of marker to 1 and opacity of label to 1 + markerLabel.setOpacity(1); + markerLabel.setOpacity(1, true); +}; diff --git a/leaflet-label/leaflet-label.d.ts b/leaflet-label/leaflet-label.d.ts new file mode 100644 index 000000000..b08996025 --- /dev/null +++ b/leaflet-label/leaflet-label.d.ts @@ -0,0 +1,70 @@ +// Type definitions for Leaflet.label v0.2.1 +// Project: https://github.com/Leaflet/Leaflet.label +// Definitions by: Wim Looman +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module L { + export interface IconOptions { + labelAnchor?: Point; + } + + export interface CircleMarkerOptions { + labelAnchor?: Point; + } + + export interface Marker { + showLabel(): Marker; + hideLabel(): Marker; + setLabelNoHide(noHide: boolean): void; + bindLabel(content: string, options?: LabelOptions): Marker; + unbindLabel(): Marker; + updateLabelContent(content: string): void; + getLabel(): Label; + setOpacity(opacity: number, labelHasSemiTransparency: boolean): void; + } + + export interface CircleMarker { + showLabel(): CircleMarker; + hideLabel(): CircleMarker; + setLabelNoHide(noHide: boolean): void; + bindLabel(content: string, options?: LabelOptions): CircleMarker; + unbindLabel(): CircleMarker; + updateLabelContent(content: string): void; + getLabel(): Label; + } + + export interface FeatureGroup { + clearLayers(): FeatureGroup; + bindLabel(content: string, options?: LabelOptions): FeatureGroup; + unbindLabel(): FeatureGroup; + updateLabelContent(content: string): FeatureGroup; + } + + export interface Path { + bindLabel(content: string, options?: LabelOptions): Path; + unbindLabel(): Path; + updateLabelContent(content: string): void; + } + + export interface LabelOptions { + className?: string; + clickable?: boolean; + direction?: string; // 'left' | 'right' | 'auto'; + noHide?: boolean; + offset?: Point; + opacity?: number; + zoomAnimation?: boolean; + } + + export interface Label extends IEventPowered

+ interface ReactElement

extends ReactElementBase, P> {} interface ReactClassicElement

diff --git a/react/react-addons-0.13.0-tests.ts b/react/future/react-addons-0.13.0-tests.ts similarity index 100% rename from react/react-addons-0.13.0-tests.ts rename to react/future/react-addons-0.13.0-tests.ts diff --git a/react/react-addons-0.13.0.d.ts b/react/future/react-addons-0.13.0.d.ts similarity index 99% rename from react/react-addons-0.13.0.d.ts rename to react/future/react-addons-0.13.0.d.ts index 8c4886c52..dd06aa1e9 100644 --- a/react/react-addons-0.13.0.d.ts +++ b/react/future/react-addons-0.13.0.d.ts @@ -1,4 +1,4 @@ -// Type definitions for ReactWithAddons 0.13.0 +// Type definitions for ReactWithAddons v0.13.0 (external module) // Project: http://facebook.github.io/react/ // Definitions by: Asana , AssureSign // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -15,7 +15,7 @@ declare module "react/addons" { ref: string; } - interface ReactElement

+ interface ReactElement

extends ReactElementBase, P> {} interface ReactClassicElement

diff --git a/react/future/react-addons-global-0.13.0.d.ts b/react/future/react-addons-global-0.13.0.d.ts new file mode 100644 index 000000000..733ba54a5 --- /dev/null +++ b/react/future/react-addons-global-0.13.0.d.ts @@ -0,0 +1,259 @@ +// Type definitions for ReactWithAddons v0.13.0 (internal module) +// Project: http://facebook.github.io/react/ +// Definitions by: Asana , AssureSign +// Definitions: https://github.com/borisyankov/DefinitelyTyped +/// + +declare module React { + // + // React.addons + // ---------------------------------------------------------------------- + + export var addons: { + CSSTransitionGroup: CSSTransitionGroup; + LinkedStateMixin: LinkedStateMixin; + PureRenderMixin: PureRenderMixin; + TransitionGroup: TransitionGroup; + + batchedUpdates(callback: (a: A, b: B) => any, a: A, b: B): void; + batchedUpdates(callback: (a: A) => any, a: A): void; + batchedUpdates(callback: () => any): void; + + // deprecated: use petehunt/react-classset or JedWatson/classnames + classSet(cx: { [key: string]: boolean }): string; + classSet(...classList: string[]): string; + + cloneWithProps

(element: ReactElement

, props: P): ReactElement

; + + update(value: any[], spec: UpdateArraySpec): any[]; + update(value: {}, spec: UpdateSpec): any; + + // Development tools + Perf: ReactPerf; + TestUtils: ReactTestUtils; + }; + + // + // React.addons (Transitions) + // ---------------------------------------------------------------------- + + type ReactType = ComponentClass | string; + + interface TransitionGroupProps { + component?: ReactType; + childFactory?: (child: ReactElement) => ReactElement; + } + + interface CSSTransitionGroupProps extends TransitionGroupProps { + transitionName: string; + transitionAppear?: boolean; + transitionEnter?: boolean; + transitionLeave?: boolean; + } + + type CSSTransitionGroup = + ComponentClass; + type TransitionGroup = + ComponentClass; + + // + // React.addons (Mixins) + // ---------------------------------------------------------------------- + + interface ReactLink { + value: T; + requestChange(newValue: T): void; + } + + interface LinkedStateMixin extends Mixin { + linkState(key: string): ReactLink; + } + + interface PureRenderMixin extends Mixin { + } + + // + // Reat.addons.update + // ---------------------------------------------------------------------- + + interface UpdateSpec { + $set: any; + $merge: {}; + $apply(value: any): any; + // [key: string]: UpdateSpec; + } + + interface UpdateArraySpec extends UpdateSpec { + $push?: any[]; + $unshift?: any[]; + $splice?: any[][]; + } + + // + // React.addons.Perf + // ---------------------------------------------------------------------- + + interface ComponentPerfContext { + current: string; + owner: string; + } + + interface NumericPerfContext { + [key: string]: number; + } + + interface Measurements { + exclusive: NumericPerfContext; + inclusive: NumericPerfContext; + render: NumericPerfContext; + counts: NumericPerfContext; + writes: NumericPerfContext; + displayNames: { + [key: string]: ComponentPerfContext; + }; + totalTime: number; + } + + interface ReactPerf { + start(): void; + stop(): void; + printInclusive(measurements: Measurements[]): void; + printExclusive(measurements: Measurements[]): void; + printWasted(measurements: Measurements[]): void; + printDOM(measurements: Measurements[]): void; + getLastMeasurements(): Measurements[]; + } + + // + // React.addons.TestUtils + // ---------------------------------------------------------------------- + + interface MockedComponentClass { + new(): any; + } + + interface ReactTestUtils { + Simulate: Simulate; + + renderIntoDocument

(element: ReactElement

): Component; + renderIntoDocument>(element: ReactElement): C; + + mockComponent(mocked: MockedComponentClass, mockTagName?: string): ReactTestUtils; + + isElementOfType(element: ReactElement, type: ReactType): boolean; + isTextComponent(instance: Component): boolean; + isDOMComponent(instance: Component): boolean; + isCompositeComponent(instance: Component): boolean; + isCompositeComponentWithType( + instance: Component, + type: ComponentClass): boolean; + + findAllInRenderedTree( + tree: Component, + fn: (i: Component) => boolean): Component; + + scryRenderedDOMComponentsWithClass( + tree: Component, + className: string): DOMComponent[]; + findRenderedDOMComponentWithClass( + tree: Component, + className: string): DOMComponent; + + scryRenderedDOMComponentsWithTag( + tree: Component, + tagName: string): DOMComponent[]; + findRenderedDOMComponentWithTag( + tree: Component, + tagName: string): DOMComponent; + + scryRenderedComponentsWithType( + tree: Component, + type: ComponentClass): Component[]; + scryRenderedComponentsWithType>( + tree: Component, + type: ComponentClass): C[]; + + findRenderedComponentWithType( + tree: Component, + type: ComponentClass): Component; + findRenderedComponentWithType>( + tree: Component, + type: ComponentClass): C; + } + + interface SyntheticEventData { + altKey?: boolean; + button?: number; + buttons?: number; + clientX?: number; + clientY?: number; + changedTouches?: TouchList; + charCode?: boolean; + clipboardData?: DataTransfer; + ctrlKey?: boolean; + deltaMode?: number; + deltaX?: number; + deltaY?: number; + deltaZ?: number; + detail?: number; + getModifierState?(key: string): boolean; + key?: string; + keyCode?: number; + locale?: string; + location?: number; + metaKey?: boolean; + pageX?: number; + pageY?: number; + relatedTarget?: EventTarget; + repeat?: boolean; + screenX?: number; + screenY?: number; + shiftKey?: boolean; + targetTouches?: TouchList; + touches?: TouchList; + view?: AbstractView; + which?: number; + } + + interface EventSimulator { + (element: Element, eventData?: SyntheticEventData): void; + (descriptor: Component, eventData?: SyntheticEventData): void; + } + + interface Simulate { + blur: EventSimulator; + change: EventSimulator; + click: EventSimulator; + cut: EventSimulator; + doubleClick: EventSimulator; + drag: EventSimulator; + dragEnd: EventSimulator; + dragEnter: EventSimulator; + dragExit: EventSimulator; + dragLeave: EventSimulator; + dragOver: EventSimulator; + dragStart: EventSimulator; + drop: EventSimulator; + focus: EventSimulator; + input: EventSimulator; + keyDown: EventSimulator; + keyPress: EventSimulator; + keyUp: EventSimulator; + mouseDown: EventSimulator; + mouseEnter: EventSimulator; + mouseLeave: EventSimulator; + mouseMove: EventSimulator; + mouseOut: EventSimulator; + mouseOver: EventSimulator; + mouseUp: EventSimulator; + paste: EventSimulator; + scroll: EventSimulator; + submit: EventSimulator; + touchCancel: EventSimulator; + touchEnd: EventSimulator; + touchMove: EventSimulator; + touchStart: EventSimulator; + wheel: EventSimulator; + } +} + diff --git a/react/future/react-global-0.13.0.d.ts b/react/future/react-global-0.13.0.d.ts new file mode 100644 index 000000000..996d09d3a --- /dev/null +++ b/react/future/react-global-0.13.0.d.ts @@ -0,0 +1,747 @@ +// Type definitions for React v0.13.0 (internal module) +// Project: http://facebook.github.io/react/ +// Definitions by: Asana , AssureSign +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module React { + // + // React Elements + // ---------------------------------------------------------------------- + + interface ReactElementBase { + type: T; + props: P; + key: number | string; + ref: string; + } + + interface ReactElement

+ extends ReactElementBase, P> {} + + interface ReactClassicElement

+ extends ReactElementBase | string, P> {} + + interface ReactDOMElement

// subtype of ReactClassicElement + extends ReactElementBase {} + + type ReactHTMLElement = ReactDOMElement; + type ReactSVGElement = ReactDOMElement; + + // + // Factories + // ---------------------------------------------------------------------- + + interface Factory

{ + (props?: P, ...children: ReactNode[]): ReactElement

; + } + + interface ClassicFactory

{ + (props?: P, ...children: ReactNode[]): ReactClassicElement

; + } + + interface DOMFactory

{ + (props?: P, ...children: ReactNode[]): ReactDOMElement

; + } + + type HTMLFactory = DOMFactory; + type SVGFactory = DOMFactory; + + // + // React Nodes + // http://facebook.github.io/react/docs/glossary.html + // ---------------------------------------------------------------------- + + type ReactText = string | number; + type ReactChild = ReactElementBase | ReactText; + + // Should be Array but type aliases cannot be recursive + type ReactFragment = Array; + type ReactNode = ReactChild | ReactFragment | boolean; + + // + // Top Level API + // ---------------------------------------------------------------------- + + function createClass( + spec: ComponentSpec): ClassicComponentClass; + + function createFactory

( + type: string): DOMFactory

; + function createFactory

( + type: ClassicComponentClass | string): ClassicFactory

; + function createFactory

( + type: ComponentClass): Factory

; + + function createElement

( + type: string, + props?: P, + ...children: ReactNode[]): ReactDOMElement

; + function createElement

( + type: ClassicComponentClass | string, + props?: P, + ...children: ReactNode[]): ReactClassicElement

; + function createElement

( + type: ComponentClass, + props?: P, + ...children: ReactNode[]): ReactElement

; + + function render

( + element: ReactDOMElement

, + container: Element, + callback?: () => any): DOMComponent

; + function render( + element: ReactClassicElement

, + container: Element, + callback?: () => any): ClassicComponent; + function render( + element: ReactElement

, + container: Element, + callback?: () => any): Component; + + function unmountComponentAtNode(container: Element): boolean; + function renderToString(element: ReactElementBase): string; + function renderToStaticMarkup(element: ReactElementBase): string; + function isValidElement(object: {}): boolean; + function initializeTouchEvents(shouldUseTouch: boolean): void; + + function findDOMNode( + componentOrElement: Component | Element): TElement; + function findDOMNode( + componentOrElement: Component | Element): Element; + + var DOM: ReactDOM; + var PropTypes: ReactPropTypes; + var Children: ReactChildren; + + // + // Component API + // ---------------------------------------------------------------------- + + // Base component for plain JS classes + class Component implements ComponentLifecycle { + constructor(props: P, context: C); + setState(state: S, callback?: () => any): void; + forceUpdate(): void; + props: P; + state: S; + context: C; + refs: { + [key: string]: Component + }; + } + + interface ClassicComponent extends Component { + replaceState(nextState: S, callback?: () => any): void; + getDOMNode(): TElement; + getDOMNode(): Element; + isMounted(): boolean; + getInitialState?(): S; + setProps(nextProps: P, callback?: () => any): void; + replaceProps(nextProps: P, callback?: () => any): void; + } + + interface DOMComponent

extends ClassicComponent { + tagName: string; + } + + type HTMLComponent = DOMComponent; + type SVGComponent = DOMComponent; + + interface ChildContextProvider { + getChildContext(): CC; + } + + // + // Class Interfaces + // ---------------------------------------------------------------------- + + interface ComponentClassBase { + propTypes?: ValidationMap

; + contextTypes?: ValidationMap; + childContextTypes?: ValidationMap<{}>; + } + + interface ComponentClass extends ComponentClassBase { + new(props?: P, context?: C): Component; + defaultProps?: P; + } + + interface ClassicComponentClass extends ComponentClassBase { + new(props?: P, context?: C): ClassicComponent; + getDefaultProps?(): P; + displayName?: string; + } + + // + // Component Specs and Lifecycle + // ---------------------------------------------------------------------- + + interface ComponentLifecycle { + componentWillMount?(): void; + componentDidMount?(): void; + componentWillReceiveProps?(nextProps: P, nextContext: C): void; + shouldComponentUpdate?(nextProps: P, nextState: S, nextContext: C): boolean; + componentWillUpdate?(nextProps: P, nextState: S, nextContext: C): void; + componentDidUpdate?(prevProps: P, prevState: S, prevContext: C): void; + componentWillUnmount?(): void; + } + + interface Mixin extends ComponentLifecycle { + mixins?: Mixin; + statics?: { + [key: string]: any; + }; + + displayName?: string; + propTypes?: ValidationMap; + contextTypes?: ValidationMap; + childContextTypes?: ValidationMap + + getInitialState?(): S; + getDefaultProps?(): P; + } + + interface ComponentSpec extends Mixin { + render(): ReactElementBase; + } + + // + // Event System + // ---------------------------------------------------------------------- + + interface SyntheticEvent { + bubbles: boolean; + cancelable: boolean; + currentTarget: EventTarget; + defaultPrevented: boolean; + eventPhase: number; + isTrusted: boolean; + nativeEvent: Event; + preventDefault(): void; + stopPropagation(): void; + target: EventTarget; + timeStamp: Date; + type: string; + } + + interface ClipboardEvent extends SyntheticEvent { + clipboardData: DataTransfer; + } + + interface KeyboardEvent extends SyntheticEvent { + altKey: boolean; + charCode: number; + ctrlKey: boolean; + getModifierState(key: string): boolean; + key: string; + keyCode: number; + locale: string; + location: number; + metaKey: boolean; + repeat: boolean; + shiftKey: boolean; + which: number; + } + + interface FocusEvent extends SyntheticEvent { + relatedTarget: EventTarget; + } + + interface FormEvent extends SyntheticEvent { + } + + interface MouseEvent extends SyntheticEvent { + altKey: boolean; + button: number; + buttons: number; + clientX: number; + clientY: number; + ctrlKey: boolean; + getModifierState(key: string): boolean; + metaKey: boolean; + pageX: number; + pageY: number; + relatedTarget: EventTarget; + screenX: number; + screenY: number; + shiftKey: boolean; + } + + interface TouchEvent extends SyntheticEvent { + altKey: boolean; + changedTouches: TouchList; + ctrlKey: boolean; + getModifierState(key: string): boolean; + metaKey: boolean; + shiftKey: boolean; + targetTouches: TouchList; + touches: TouchList; + } + + interface UIEvent extends SyntheticEvent { + detail: number; + view: AbstractView; + } + + interface WheelEvent extends SyntheticEvent { + deltaMode: number; + deltaX: number; + deltaY: number; + deltaZ: number; + } + + // + // Event Handler Types + // ---------------------------------------------------------------------- + + interface EventHandler { + (event: E): void; + } + + interface ClipboardEventHandler extends EventHandler {} + interface KeyboardEventHandler extends EventHandler {} + interface FocusEventHandler extends EventHandler {} + interface FormEventHandler extends EventHandler {} + interface MouseEventHandler extends EventHandler {} + interface TouchEventHandler extends EventHandler {} + interface UIEventHandler extends EventHandler {} + interface WheelEventHandler extends EventHandler {} + + // + // Props / DOM Attributes + // ---------------------------------------------------------------------- + + interface Props { + children?: ReactNode; + key?: number | string; + ref?: string; + } + + interface DOMAttributes extends Props { + onCopy?: ClipboardEventHandler; + onCut?: ClipboardEventHandler; + onPaste?: ClipboardEventHandler; + onKeyDown?: KeyboardEventHandler; + onKeyPress?: KeyboardEventHandler; + onKeyUp?: KeyboardEventHandler; + onFocus?: FocusEventHandler; + onBlur?: FocusEventHandler; + onChange?: FormEventHandler; + onInput?: FormEventHandler; + onSubmit?: FormEventHandler; + onClick?: MouseEventHandler; + onDoubleClick?: MouseEventHandler; + onDrag?: MouseEventHandler; + onDragEnd?: MouseEventHandler; + onDragEnter?: MouseEventHandler; + onDragExit?: MouseEventHandler; + onDragLeave?: MouseEventHandler; + onDragOver?: MouseEventHandler; + onDragStart?: MouseEventHandler; + onDrop?: MouseEventHandler; + onMouseDown?: MouseEventHandler; + onMouseEnter?: MouseEventHandler; + onMouseLeave?: MouseEventHandler; + onMouseMove?: MouseEventHandler; + onMouseOut?: MouseEventHandler; + onMouseOver?: MouseEventHandler; + onMouseUp?: MouseEventHandler; + onTouchCancel?: TouchEventHandler; + onTouchEnd?: TouchEventHandler; + onTouchMove?: TouchEventHandler; + onTouchStart?: TouchEventHandler; + onScroll?: UIEventHandler; + onWheel?: WheelEventHandler; + + dangerouslySetInnerHTML?: { + __html: string; + }; + } + + interface CSSProperties { + columnCount?: number; + flex?: number | string; + flexGrow?: number; + flexShrink?: number; + fontWeight?: number; + lineClamp?: number; + lineHeight?: number; + opacity?: number; + order?: number; + orphans?: number; + widows?: number; + zIndex?: number; + zoom?: number; + + // SVG-related properties + fillOpacity?: number; + strokeOpacity?: number; + } + + interface HTMLAttributes extends DOMAttributes { + accept?: string; + acceptCharset?: string; + accessKey?: string; + action?: string; + allowFullScreen?: boolean; + allowTransparency?: boolean; + alt?: string; + async?: boolean; + autoComplete?: boolean; + autoFocus?: boolean; + autoPlay?: boolean; + cellPadding?: number | string; + cellSpacing?: number | string; + charSet?: string; + checked?: boolean; + classID?: string; + className?: string; + cols?: number; + colSpan?: number; + content?: string; + contentEditable?: boolean; + contextMenu?: string; + controls?: any; + coords?: string; + crossOrigin?: string; + data?: string; + dateTime?: string; + defer?: boolean; + dir?: string; + disabled?: boolean; + download?: any; + draggable?: boolean; + encType?: string; + form?: string; + formNoValidate?: boolean; + frameBorder?: number | string; + height?: number | string; + hidden?: boolean; + href?: string; + hrefLang?: string; + htmlFor?: string; + httpEquiv?: string; + icon?: string; + id?: string; + label?: string; + lang?: string; + list?: string; + loop?: boolean; + manifest?: string; + max?: number | string; + maxLength?: number; + media?: string; + mediaGroup?: string; + method?: string; + min?: number | string; + multiple?: boolean; + muted?: boolean; + name?: string; + noValidate?: boolean; + open?: boolean; + pattern?: string; + placeholder?: string; + poster?: string; + preload?: string; + radioGroup?: string; + readOnly?: boolean; + rel?: string; + required?: boolean; + role?: string; + rows?: number; + rowSpan?: number; + sandbox?: string; + scope?: string; + scrollLeft?: number; + scrolling?: string; + scrollTop?: number; + seamless?: boolean; + selected?: boolean; + shape?: string; + size?: number; + sizes?: string; + span?: number; + spellCheck?: boolean; + src?: string; + srcDoc?: string; + srcSet?: string; + start?: number; + step?: number | string; + style?: CSSProperties; + tabIndex?: number; + target?: string; + title?: string; + type?: string; + useMap?: string; + value?: string; + width?: number | string; + wmode?: string; + + // Non-standard Attributes + autoCapitalize?: boolean; + autoCorrect?: boolean; + property?: string; + itemProp?: string; + itemScope?: boolean; + itemType?: string; + } + + interface SVGAttributes extends DOMAttributes { + cx?: SVGLength | SVGAnimatedLength; + cy?: any; + d?: string; + dx?: SVGLength | SVGAnimatedLength; + dy?: SVGLength | SVGAnimatedLength; + fill?: any; // SVGPaint | string + fillOpacity?: number | string; + fontFamily?: string; + fontSize?: number | string; + fx?: SVGLength | SVGAnimatedLength; + fy?: SVGLength | SVGAnimatedLength; + gradientTransform?: SVGTransformList | SVGAnimatedTransformList; + gradientUnits?: string; + markerEnd?: string; + markerMid?: string; + markerStart?: string; + offset?: number | string; + opacity?: number | string; + patternContentUnits?: string; + patternUnits?: string; + points?: string; + preserveAspectRatio?: string; + r?: SVGLength | SVGAnimatedLength; + rx?: SVGLength | SVGAnimatedLength; + ry?: SVGLength | SVGAnimatedLength; + spreadMethod?: string; + stopColor?: any; // SVGColor | string + stopOpacity?: number | string; + stroke?: any; // SVGPaint + strokeDasharray?: string; + strokeLinecap?: string; + strokeOpacity?: number | string; + strokeWidth?: SVGLength | SVGAnimatedLength; + textAnchor?: string; + transform?: SVGTransformList | SVGAnimatedTransformList; + version?: string; + viewBox?: string; + x1?: SVGLength | SVGAnimatedLength; + x2?: SVGLength | SVGAnimatedLength; + x?: SVGLength | SVGAnimatedLength; + y1?: SVGLength | SVGAnimatedLength; + y2?: SVGLength | SVGAnimatedLength + y?: SVGLength | SVGAnimatedLength; + } + + // + // React.DOM + // ---------------------------------------------------------------------- + + interface ReactDOM { + // HTML + a: HTMLFactory; + abbr: HTMLFactory; + address: HTMLFactory; + area: HTMLFactory; + article: HTMLFactory; + aside: HTMLFactory; + audio: HTMLFactory; + b: HTMLFactory; + base: HTMLFactory; + bdi: HTMLFactory; + bdo: HTMLFactory; + big: HTMLFactory; + blockquote: HTMLFactory; + body: HTMLFactory; + br: HTMLFactory; + button: HTMLFactory; + canvas: HTMLFactory; + caption: HTMLFactory; + cite: HTMLFactory; + code: HTMLFactory; + col: HTMLFactory; + colgroup: HTMLFactory; + data: HTMLFactory; + datalist: HTMLFactory; + dd: HTMLFactory; + del: HTMLFactory; + details: HTMLFactory; + dfn: HTMLFactory; + dialog: HTMLFactory; + div: HTMLFactory; + dl: HTMLFactory; + dt: HTMLFactory; + em: HTMLFactory; + embed: HTMLFactory; + fieldset: HTMLFactory; + figcaption: HTMLFactory; + figure: HTMLFactory; + footer: HTMLFactory; + form: HTMLFactory; + h1: HTMLFactory; + h2: HTMLFactory; + h3: HTMLFactory; + h4: HTMLFactory; + h5: HTMLFactory; + h6: HTMLFactory; + head: HTMLFactory; + header: HTMLFactory; + hr: HTMLFactory; + html: HTMLFactory; + i: HTMLFactory; + iframe: HTMLFactory; + img: HTMLFactory; + input: HTMLFactory; + ins: HTMLFactory; + kbd: HTMLFactory; + keygen: HTMLFactory; + label: HTMLFactory; + legend: HTMLFactory; + li: HTMLFactory; + link: HTMLFactory; + main: HTMLFactory; + map: HTMLFactory; + mark: HTMLFactory; + menu: HTMLFactory; + menuitem: HTMLFactory; + meta: HTMLFactory; + meter: HTMLFactory; + nav: HTMLFactory; + noscript: HTMLFactory; + object: HTMLFactory; + ol: HTMLFactory; + optgroup: HTMLFactory; + option: HTMLFactory; + output: HTMLFactory; + p: HTMLFactory; + param: HTMLFactory; + picture: HTMLFactory; + pre: HTMLFactory; + progress: HTMLFactory; + q: HTMLFactory; + rp: HTMLFactory; + rt: HTMLFactory; + ruby: HTMLFactory; + s: HTMLFactory; + samp: HTMLFactory; + script: HTMLFactory; + section: HTMLFactory; + select: HTMLFactory; + small: HTMLFactory; + source: HTMLFactory; + span: HTMLFactory; + strong: HTMLFactory; + style: HTMLFactory; + sub: HTMLFactory; + summary: HTMLFactory; + sup: HTMLFactory; + table: HTMLFactory; + tbody: HTMLFactory; + td: HTMLFactory; + textarea: HTMLFactory; + tfoot: HTMLFactory; + th: HTMLFactory; + thead: HTMLFactory; + time: HTMLFactory; + title: HTMLFactory; + tr: HTMLFactory; + track: HTMLFactory; + u: HTMLFactory; + ul: HTMLFactory; + "var": HTMLFactory; + video: HTMLFactory; + wbr: HTMLFactory; + + // SVG + circle: SVGFactory; + defs: SVGFactory; + ellipse: SVGFactory; + g: SVGFactory; + line: SVGFactory; + linearGradient: SVGFactory; + mask: SVGFactory; + path: SVGFactory; + pattern: SVGFactory; + polygon: SVGFactory; + polyline: SVGFactory; + radialGradient: SVGFactory; + rect: SVGFactory; + stop: SVGFactory; + svg: SVGFactory; + text: SVGFactory; + tspan: SVGFactory; + } + + // + // React.PropTypes + // ---------------------------------------------------------------------- + + interface Validator { + (object: T, key: string, componentName: string): Error; + } + + interface Requireable extends Validator { + isRequired: Validator; + } + + interface ValidationMap { + [key: string]: Validator; + } + + interface ReactPropTypes { + any: Requireable; + array: Requireable; + bool: Requireable; + func: Requireable; + number: Requireable; + object: Requireable; + string: Requireable; + node: Requireable; + element: Requireable; + instanceOf(expectedClass: {}): Requireable; + oneOf(types: any[]): Requireable; + oneOfType(types: Validator[]): Requireable; + arrayOf(type: Validator): Requireable; + objectOf(type: Validator): Requireable; + shape(type: ValidationMap): Requireable; + } + + // + // React.Children + // ---------------------------------------------------------------------- + + interface ReactChildren { + map(children: ReactNode, fn: (child: ReactChild) => T): { [key:string]: T }; + forEach(children: ReactNode, fn: (child: ReactChild) => any): void; + count(children: ReactNode): number; + only(children: ReactNode): ReactChild; + } + + // + // Browser Interfaces + // https://github.com/nikeee/2048-typescript/blob/master/2048/js/touch.d.ts + // ---------------------------------------------------------------------- + + interface AbstractView { + styleMedia: StyleMedia; + document: Document; + } + + interface Touch { + identifier: number; + target: EventTarget; + screenX: number; + screenY: number; + clientX: number; + clientY: number; + pageX: number; + pageY: number; + } + + interface TouchList { + [index: number]: Touch; + length: number; + item(index: number): Touch; + identifiedTouch(identifier: number): Touch; + } +} + From 56c5256ed072e5855c519bf237e763be847aa9d5 Mon Sep 17 00:00:00 2001 From: Tim Bureck Date: Sun, 15 Feb 2015 13:38:42 +0100 Subject: [PATCH 019/185] TS 1.4.1 fixes in jBinary.d.ts --- jBinary/jBinary.d.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/jBinary/jBinary.d.ts b/jBinary/jBinary.d.ts index b9b28b0c7..98b0fc4d6 100644 --- a/jBinary/jBinary.d.ts +++ b/jBinary/jBinary.d.ts @@ -17,16 +17,16 @@ declare class jBinary constructor(data:jDataView, typeSet:Object); constructor(bufferSize:number, typeSet:Object); - read(type:string, offset:number = this.tell()):any; + read(type:string, offset?:number):any; readAll():any; - write(type:string, data:any, offset:number = this.tell()); - writeAll(data:any); + write(type:string, data:any, offset?:number):number; + writeAll(data:any):number; tell():number; seek(position:number, callback):number; skip(count:number, callback):number; - slice(start:number, end:number, forceCopy:boolean = false):jBinary; - as(typeSet:Object, modifyOriginal:boolean = false):jBinary; + slice(start:number, end:number, forceCopy?:boolean):jBinary; + as(typeSet:Object, modifyOriginal?:boolean):jBinary; } \ No newline at end of file From a78835ccff389eecc080b8f6a67a600183f1c417 Mon Sep 17 00:00:00 2001 From: Tim Bureck Date: Sun, 15 Feb 2015 13:44:43 +0100 Subject: [PATCH 020/185] Fixed missing type hinting for callback parameters in seek() and skip() methods in jBinary.d.ts --- jBinary/jBinary.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jBinary/jBinary.d.ts b/jBinary/jBinary.d.ts index 98b0fc4d6..cf57d5f77 100644 --- a/jBinary/jBinary.d.ts +++ b/jBinary/jBinary.d.ts @@ -24,8 +24,8 @@ declare class jBinary writeAll(data:any):number; tell():number; - seek(position:number, callback):number; - skip(count:number, callback):number; + seek(position:number, callback: (prop:jBinary, data:any) => any):number; + skip(count:number, callback: (prop:jBinary, data:any) => any):number; slice(start:number, end:number, forceCopy?:boolean):jBinary; as(typeSet:Object, modifyOriginal?:boolean):jBinary; From 328a83158ea694e005f94f8af722e6ec84e3f26d Mon Sep 17 00:00:00 2001 From: Yuichi Murata Date: Sun, 15 Feb 2015 23:21:20 +0900 Subject: [PATCH 021/185] Added eventemitter3/eventemitter3.d.ts(0.1.6). --- eventemitter3/eventemitter3-test.ts | 65 ++++++++++++++++++ eventemitter3/eventemitter3.d.ts | 100 ++++++++++++++++++++++++++++ 2 files changed, 165 insertions(+) create mode 100644 eventemitter3/eventemitter3-test.ts create mode 100644 eventemitter3/eventemitter3.d.ts diff --git a/eventemitter3/eventemitter3-test.ts b/eventemitter3/eventemitter3-test.ts new file mode 100644 index 000000000..05138ab34 --- /dev/null +++ b/eventemitter3/eventemitter3-test.ts @@ -0,0 +1,65 @@ +/// +'use strict'; + +import EventEmitter = require('eventemitter3'); + +class EventEmitterTest { + v: EventEmitter; + + constructor() { + this.v = new EventEmitter(); + this.v = new EventEmitter.EventEmitter(); + this.v = new EventEmitter.EventEmitter2(); + this.v = new EventEmitter.EventEmitter3(); + } + + listeners() { + var v1: Function[] = this.v.listeners('click'); + } + + emit() { + var v1: boolean = this.v.emit('click'); + var v2: boolean = this.v.emit('click', 1); + var v3: boolean = this.v.emit('click', 1, '1'); + var v4: boolean = this.v.emit('click', 1, '1', true); + var v5: boolean = this.v.emit('click', 1, '1', true, new Date()); + } + + on() { + var fn = () => console.log(1); + var v1: EventEmitter = this.v.on('click', fn); + var v2: EventEmitter = this.v.on('click', fn, this); + } + + once() { + var fn = () => console.log(1); + var v1: EventEmitter = this.v.once('click', fn); + var v2: EventEmitter = this.v.once('click', fn, this); + } + + removeListener() { + var fn = () => console.log(1); + var v1: EventEmitter = this.v.removeListener('click', fn); + var v2: EventEmitter = this.v.removeListener('click', fn, true); + } + + removeAllListeners() { + var v1: EventEmitter = this.v.removeAllListeners('click'); + } + + off() { + var fn = () => console.log(1); + var v1: EventEmitter = this.v.off('click', fn); + var v2: EventEmitter = this.v.off('click', fn, true); + } + + addListener() { + var fn = () => console.log(1); + var v1: EventEmitter = this.v.addListener('click', fn); + var v2: EventEmitter = this.v.addListener('click', fn, this); + } + + setMaxListeners() { + var v1: EventEmitter = this.v.setMaxListeners(); + } +} diff --git a/eventemitter3/eventemitter3.d.ts b/eventemitter3/eventemitter3.d.ts new file mode 100644 index 000000000..60f6e6e93 --- /dev/null +++ b/eventemitter3/eventemitter3.d.ts @@ -0,0 +1,100 @@ +// Type definitions for EventEmitter3 0.1.6 +// Project: https://github.com/primus/eventemitter3 +// Definitions by: Yuichi Murata +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module EventEmitter3 { + export class EventEmitter { + /** + * Minimal EventEmitter interface that is molded against the Node.js + * EventEmitter interface. + * + * @constructor + * @api public + */ + constructor(); + + /** + * Return a list of assigned event listeners. + * + * @param {String} event The events that should be listed. + * @returns {Array} + * @api public + */ + listeners(event: string): Function[]; + + /** + * Emit an event to all registered event listeners. + * + * @param {String} event The name of the event. + * @returns {Boolean} Indication if we've emitted an event. + * @api public + */ + emit(event: string, ...args: any[]): boolean; + + /** + * Register a new EventListener for the given event. + * + * @param {String} event Name of the event. + * @param {Functon} fn Callback function. + * @param {Mixed} context The context of the function. + * @api public + */ + on(event: string, fn: Function, context?: any): EventEmitter; + + /** + * Add an EventListener that's only called once. + * + * @param {String} event Name of the event. + * @param {Function} fn Callback function. + * @param {Mixed} context The context of the function. + * @api public + */ + once(event: string, fn: Function, context?: any): EventEmitter; + + /** + * Remove event listeners. + * + * @param {String} event The event we want to remove. + * @param {Function} fn The listener that we need to find. + * @param {Boolean} once Only remove once listeners. + * @api public + */ + removeListener(event: string, fn: Function, once?: boolean): EventEmitter; + + /** + * Remove all listeners or only the listeners for the specified event. + * + * @param {String} event The event want to remove all listeners for. + * @api public + */ + removeAllListeners(event: string): EventEmitter; + + // + // Alias methods names because people roll like that. + // + off(event: string, fn: Function, once?: boolean): EventEmitter; + addListener(event: string, fn: Function, context?: any): EventEmitter; + + // + // This function doesn't apply anymore. + // + setMaxListeners(): EventEmitter; + } + export module EventEmitter { + // + // Expose the module. + // + export class EventEmitter extends EventEmitter3.EventEmitter {} + export class EventEmitter2 extends EventEmitter3.EventEmitter {} + export class EventEmitter3 extends EventEmitter3.EventEmitter {} + } +} + +declare module 'eventemitter3' { + // + // Expose the module. + // + class EventEmitter extends EventEmitter3.EventEmitter {} + export = EventEmitter; +} From 7eb96af79380fa622cceefef0b5b144e7d4c5180 Mon Sep 17 00:00:00 2001 From: Wim Looman Date: Mon, 16 Feb 2015 16:48:02 +1300 Subject: [PATCH 022/185] Add in constructor for label --- leaflet-label/leaflet-label-tests.ts | 2 ++ leaflet-label/leaflet-label.d.ts | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/leaflet-label/leaflet-label-tests.ts b/leaflet-label/leaflet-label-tests.ts index 884f5f67e..57a2feb45 100644 --- a/leaflet-label/leaflet-label-tests.ts +++ b/leaflet-label/leaflet-label-tests.ts @@ -67,6 +67,8 @@ path = path.unbindLabel(); // Label +label = new L.Label(); + label.setOpacity(0.7); label.updateZIndex(5); label.setLatLng(new L.LatLng(3, 3)); diff --git a/leaflet-label/leaflet-label.d.ts b/leaflet-label/leaflet-label.d.ts index b08996025..38bb43d7a 100644 --- a/leaflet-label/leaflet-label.d.ts +++ b/leaflet-label/leaflet-label.d.ts @@ -58,6 +58,12 @@ declare module L { zoomAnimation?: boolean; } + export interface LabelStatic extends ClassStatic { + new(options?: LabelOptions): Label; + } + + export var Label: LabelStatic; + export interface Label extends IEventPowered

(type: React.ComponentClass

| string, + props: P, children: React.ReactNode): React.ReactElement

; + } + + interface Module { + (reactObj: ReactLikeObject): CreateElement + } + + interface CreateElement { + /** + * Renders an HTML element from the given spec string, with children but without + * extra props. + * @param specString A string that defines a component in a way that resembles + * CSS selectors. Eg. "input:email#foo.bar.baz[name=email][required]" + * @param children A single React node (string or ReactElement) or array of nodes. + * Note that unlike with React itself, multiple children must be placed into an array. + */ + (specString: string, children: React.ReactNode): React.ReactHTMLElement + + /** + * Renders an HTML element from the given spec string, with optional props + * and children + * @param specString A string that defines a component in a way that resembles + * CSS selectors. Eg. "input:email#foo.bar.baz[name=email][required]" + * @param props Object of html attribute key-value pairs + * @param children A single React node (string or ReactElement) or array of nodes. + * Note that unlike with React itself, multiple children must be placed into an array. + */ + (specString: string, props?: React.HTMLAttributes, children?: React.ReactNode): React.ReactHTMLElement + + + /** + * Renders a React component, with children but no props + * @param component A plain React component (created from React.createClass()) or + * component factory (created from React.createFactory()) + * @param children A single React node (string or ReactElement) or array of nodes. + * Note that unlike with React itself, multiple children must be placed into an array. + */ +

(component: React.ComponentClass

, children: React.ReactNode): React.ReactElement

+ + /** + * Renders a React component, with optional props and children + * @param component A plain React component (created from React.createClass()) or + * component factory (created from React.createFactory()) + * @param props Props object to pass to the component + * @param children A single React node (string or ReactElement) or array of nodes. + * Note that unlike with React itself, multiple children must be placed into an array. + */ +

(component: React.ComponentClass

, props?: P, children?: React.ReactNode): React.ReactElement

+ } + + var exports: Module + export = exports +} From 36f2213157fa535f5c4aef66da98559e9823e25c Mon Sep 17 00:00:00 2001 From: NN Date: Sun, 22 Feb 2015 13:53:32 +0200 Subject: [PATCH 059/185] Update chrome.d.ts MessageSender has more properties. https://developer.chrome.com/extensions/runtime#type-MessageSender onMessage can be more type safe. It receives only objects serialized in JSON from native. --- chrome/chrome.d.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/chrome/chrome.d.ts b/chrome/chrome.d.ts index f6faf0cc2..e77f744fa 100755 --- a/chrome/chrome.d.ts +++ b/chrome/chrome.d.ts @@ -1524,8 +1524,11 @@ declare module chrome.runtime { } interface MessageSender { - id: string; + id?: string; tab?: chrome.tabs.Tab; + frameId?: number; + url?: string; + tlsChannelId?: string; } interface PlatformInfo { @@ -1538,7 +1541,7 @@ declare module chrome.runtime { postMessage: Function; sender?: MessageSender; onDisconnect: chrome.events.Event; - onMessage: chrome.events.Event; + onMessage: PortMessageEvent; name: string; } @@ -1550,6 +1553,10 @@ declare module chrome.runtime { version: string; } + interface PortMessageEvent extends chrome.events.Event { + addListener(callback: (message: Object, port: Port) => void): void; + } + interface ExtensionMessageEvent extends chrome.events.Event { addListener(callback: (message: any, sender: MessageSender, sendResponse: Function) => void): void; } From bf7b74abf3b6635d4371d5655a139d8efdcb8d54 Mon Sep 17 00:00:00 2001 From: vvakame Date: Sun, 22 Feb 2015 23:21:10 +0900 Subject: [PATCH 060/185] add archy definitions --- archy/archy-tests.ts | 32 ++++++++++++++++++++++++++++++++ archy/archy.d.ts | 21 +++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 archy/archy-tests.ts create mode 100644 archy/archy.d.ts diff --git a/archy/archy-tests.ts b/archy/archy-tests.ts new file mode 100644 index 000000000..b2f62384f --- /dev/null +++ b/archy/archy-tests.ts @@ -0,0 +1,32 @@ +/// + +import archy = require("archy"); + +var opts: archy.Options = { +}; + +var data: archy.Data = { + label: 'beep', + nodes: [ + 'ity', + { + label: 'boop', + nodes: [ + { + label: 'o_O', + nodes: [ + { + label: 'oh', + nodes: ['hello', 'puny'] + }, + 'human' + ] + }, + 'party\ntime!' + ] + } + ] +}; + +var str = archy(data); +console.log(str); diff --git a/archy/archy.d.ts b/archy/archy.d.ts new file mode 100644 index 000000000..c7145e628 --- /dev/null +++ b/archy/archy.d.ts @@ -0,0 +1,21 @@ +// Type definitions for archy +// Project: https://github.com/substack/node-archy +// Definitions by: vvakame +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module "archy" { + function archy(obj: archy.Data, prefix?: string, opts?: archy.Options): string; + function archy(obj: string, prefix?: string, opts?: archy.Options): string; + + module archy { + interface Data { + label?: string; + nodes?: Data[]; + } + interface Options { + unicode?: boolean; + } + } + + export = archy; +} From b3def0f8abb4511e46b682837e3fcf6ce8483515 Mon Sep 17 00:00:00 2001 From: vvakame Date: Sun, 22 Feb 2015 23:25:14 +0900 Subject: [PATCH 061/185] improve archy definition --- archy/archy.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/archy/archy.d.ts b/archy/archy.d.ts index c7145e628..3d989a895 100644 --- a/archy/archy.d.ts +++ b/archy/archy.d.ts @@ -9,8 +9,8 @@ declare module "archy" { module archy { interface Data { - label?: string; - nodes?: Data[]; + label: string; + nodes?: (Data | string)[]; } interface Options { unicode?: boolean; From 444a9922099647d2cff4f06f84665894ef52875f Mon Sep 17 00:00:00 2001 From: Lokesh Peta Date: Sun, 22 Feb 2015 18:58:13 +0000 Subject: [PATCH 062/185] Revert "first d.ts for ionic framework" This reverts commit d8e4e619a5a2209afe4051433b700afd2e717133. --- ionic/cordova.d.ts | 41 ---- ionic/ionic.base.d.ts | 124 ---------- ionic/ionic.d.ts | 398 ------------------------------- ionic/ionic.domUtil.d.ts | 88 ------- ionic/ionic.eventController.d.ts | 114 --------- ionic/ionic.platform.d.ts | 103 -------- ionic/ionic.popover.d.ts | 82 ------- ionic/ionic.popup.d.ts | 219 ----------------- ionic/ionic.scroll.d.ts | 106 -------- ionic/ionic.sideMenus.d.ts | 71 ------ ionic/ionic.slideBox.d.ts | 62 ----- 11 files changed, 1408 deletions(-) delete mode 100644 ionic/cordova.d.ts delete mode 100644 ionic/ionic.base.d.ts delete mode 100644 ionic/ionic.d.ts delete mode 100644 ionic/ionic.domUtil.d.ts delete mode 100644 ionic/ionic.eventController.d.ts delete mode 100644 ionic/ionic.platform.d.ts delete mode 100644 ionic/ionic.popover.d.ts delete mode 100644 ionic/ionic.popup.d.ts delete mode 100644 ionic/ionic.scroll.d.ts delete mode 100644 ionic/ionic.sideMenus.d.ts delete mode 100644 ionic/ionic.slideBox.d.ts diff --git a/ionic/cordova.d.ts b/ionic/cordova.d.ts deleted file mode 100644 index c99a124df..000000000 --- a/ionic/cordova.d.ts +++ /dev/null @@ -1,41 +0,0 @@ -/// - -interface Cordova -{ - plugins: Plugins; -} - -interface Plugins -{ - Keyboard: Ionic.Keyboard; -} - -declare module Ionic -{ - interface Keyboard - { - /** - * Hide the keyboard accessory bar with the next, previous and done buttons. - * - * @param hide - */ - hideKeyboardAccessoryBar(hide: boolean): void; - - /** - * Close the keyboard if it is open. - */ - close(): void; - - /** - * Disable native scrolling, useful if you are using JavaScript to scroll - * - * @param disbale - */ - disableScroll(disbale: boolean): void; - - /** - * Whether or not the keyboard is currently visible. - */ - isVisible: boolean; - } -} \ No newline at end of file diff --git a/ionic/ionic.base.d.ts b/ionic/ionic.base.d.ts deleted file mode 100644 index 0ca53a2d8..000000000 --- a/ionic/ionic.base.d.ts +++ /dev/null @@ -1,124 +0,0 @@ -/// - -declare module Ionic { - - interface IBase { - Platform: IPlatform; - DomUtil: IDomUtil; - EventController: IEventController; - - //#region EventController Aliases - /** - * @param eventType The event to trigger - * @param data The data for the event. Hint: pass in {target: targetElement} - * @param bubbles Whether the event should bubble up the DOM - * @param cancelable Whether the event should be cancelable - */ - trigger(eventType: string, data: Object, bubbles?: boolean, cancelable?: boolean): void; - - /** - * Listen to an event on an element. - * - * @param type The event to listen for - * @param callback The listener to be called - * @param element The element to listen for the event on - */ - on(type: string, callback: () => void, element: Element): void; - - - /** - * Remove an event listener - * - * @param type The event to listen for - * @param callback The listener to be called - * @param element The element to listen for the event on - */ - off(type: string, callback: () => void, element: Element): void; - - /** - * Add an event listener for a gesture on an element. - * - * @param eventType The gesture event to listen for - * @param callback The function to call when the gesture happens - * @param element The angular element to listen for the event on - */ - onGesture(eventType: string, callback: () => void, element: Element): void; - onGesture(eventType: "hold", callback: () => void, element: Element): void; - onGesture(eventType: "tap", callback: () => void, element: Element): void; - onGesture(eventType: "doubletap", callback: () => void, element: Element): void; - onGesture(eventType: "drag", callback: () => void, element: Element): void; - onGesture(eventType: "dragstart", callback: () => void, element: Element): void; - onGesture(eventType: "dragend", callback: () => void, element: Element): void; - onGesture(eventType: "dragup", callback: () => void, element: Element): void; - onGesture(eventType: "dragdown", callback: () => void, element: Element): void; - onGesture(eventType: "dragleft", callback: () => void, element: Element): void; - onGesture(eventType: "dragright", callback: () => void, element: Element): void; - onGesture(eventType: "swipe", callback: () => void, element: Element): void; - onGesture(eventType: "swipeup", callback: () => void, element: Element): void; - onGesture(eventType: "swipedown", callback: () => void, element: Element): void; - onGesture(eventType: "swipeleft", callback: () => void, element: Element): void; - onGesture(eventType: "swiperight", callback: () => void, element: Element): void; - onGesture(eventType: "transform", callback: () => void, element: Element): void; - onGesture(eventType: "transformstart", callback: () => void, element: Element): void; - onGesture(eventType: "transformend", callback: () => void, element: Element): void; - onGesture(eventType: "rotate", callback: () => void, element: Element): void; - onGesture(eventType: "pinch", callback: () => void, element: Element): void; - onGesture(eventType: "pinchin", callback: () => void, element: Element): void; - onGesture(eventType: "pinchout", callback: () => void, element: Element): void; - onGesture(eventType: "touch", callback: () => void, element: Element): void; - onGesture(eventType: "release", callback: () => void, element: Element): void; - - /** - * Remove an event listener for a gesture on an element. - * - * @param eventType The gesture event - * @param callback The listener that was added earlier - * @param element The element the listener was added on - */ - offGesture(eventType: string, callback: () => void, element: Element): void; - offGesture(eventType: "hold", callback: () => void, element: Element): void; - offGesture(eventType: "tap", callback: () => void, element: Element): void; - offGesture(eventType: "doubletap", callback: () => void, element: Element): void; - offGesture(eventType: "drag", callback: () => void, element: Element): void; - offGesture(eventType: "dragstart", callback: () => void, element: Element): void; - offGesture(eventType: "dragend", callback: () => void, element: Element): void; - offGesture(eventType: "dragup", callback: () => void, element: Element): void; - offGesture(eventType: "dragdown", callback: () => void, element: Element): void; - offGesture(eventType: "dragleft", callback: () => void, element: Element): void; - offGesture(eventType: "dragright", callback: () => void, element: Element): void; - offGesture(eventType: "swipe", callback: () => void, element: Element): void; - offGesture(eventType: "swipeup", callback: () => void, element: Element): void; - offGesture(eventType: "swipedown", callback: () => void, element: Element): void; - offGesture(eventType: "swipeleft", callback: () => void, element: Element): void; - offGesture(eventType: "swiperight", callback: () => void, element: Element): void; - offGesture(eventType: "transform", callback: () => void, element: Element): void; - offGesture(eventType: "transformstart", callback: () => void, element: Element): void; - offGesture(eventType: "transformend", callback: () => void, element: Element): void; - offGesture(eventType: "rotate", callback: () => void, element: Element): void; - offGesture(eventType: "pinch", callback: () => void, element: Element): void; - offGesture(eventType: "pinchin", callback: () => void, element: Element): void; - offGesture(eventType: "pinchout", callback: () => void, element: Element): void; - offGesture(eventType: "touch", callback: () => void, element: Element): void; - offGesture(eventType: "release", callback: () => void, element: Element): void; - - //#endregion - - //#region DomUtil Aliases - - /** - * Calls requestAnimationFrame, or a polyfill if not available. - * - * @param callback The function to call when the next frame happens - */ - requestAnimationFrame(callback: () => void): void; - - /** - * When given a callback, if that callback is called 100 times between animation frames, adding Throttle will make it only run the last of the 100 calls. - * - * @param callback a function which will be throttled to requestAnimationFrame - */ - animationFrameThrottle(callback: () => void): void; - - //#endregion - } -} \ No newline at end of file diff --git a/ionic/ionic.d.ts b/ionic/ionic.d.ts deleted file mode 100644 index 3bcbf560c..000000000 --- a/ionic/ionic.d.ts +++ /dev/null @@ -1,398 +0,0 @@ -// Type definitions for Ionic -// Project: https://github.com/driftyco/ionic -// Definitions by: Lokesh Peta -// Definitions: https://github.com/borisyankov/DefinitelyTyped - -/// -/// -/// -/// -/// -/// -/// -/// -/// - -/** - * Define a global ionic object - */ -declare module Ionic { - - //#region Config Provider - /** - * Angular service: $ionicConfigProvider - * - * $ionicConfigProvider can be used during the configuration phase of your app to change how Ionic works. - */ - interface IConfigProvider { - /** - * Set whether Ionic should prefetch all templateUrls defined in $stateProvider.state. Default true. - * If set to false, the user will have to wait for a template to be fetched the first time he/she is going to a a new page. - * - * @param shouldPrefetch Whether Ionic should prefetch templateUrls defined in $stateProvider.state(). Default true. - */ - prefetchTemplates(shouldPrefetch: boolean): boolean; - } - //#endregion - - //#region Platform - - interface IDevice { - /** Get the version of Cordova running on the device. */ - cordova: string; - /** - * The device.model returns the name of the device's model or product. The value is set - * by the device manufacturer and may be different across versions of the same product. - */ - model: string; - /** device.name is deprecated as of version 2.3.0. Use device.model instead. */ - name: string; - /** Get the device's operating system name. */ - platform: string; - /** Get the device's Universally Unique Identifier (UUID). */ - uuid: string; - /** Get the operating system version. */ - version: string; - } - - //#region Ionic Position - - /** - * Angular service: $ionicPosition - * - * A set of utility methods that can be use to retrieve position of DOM elements. - * It is meant to be used where we need to absolute-position DOM elements in relation to other, existing elements (this is the case for tooltips, popovers, etc.). - */ - interface IPosition { - /** - * Get the current coordinates of the element, relative to the offset parent. Read-only equivalent of jQuery's position function. - * - * @param element The element to get the position of - */ - position(element: Element): { - top: number; - left: number; - width: number; - height: number; - } - - /** - * Get the current coordinates of the element, relative to the document. Read-only equivalent of jQuery's offset function. - * - * @param element The element to get offset of - */ - offset(element: Element): { - top: number; - left: number; - width: number; - height: number; - } - } - - //#endregion - - //#region Action Sheet - interface IActionSheetOptions { - /** - * Which buttons to show. Each button is an object with a text field. - */ - buttons?: Array<{ text: string }>; - - /** - * The title to show on the action sheet. - */ - titleText?: string; - - /** - * The text for a 'cancel' button on the action sheet. - */ - cancelText?: string; - - /** - * The text for a 'danger' on the action sheet. - */ - destructiveText?: string; - - /** - * Called if the cancel button is pressed, the backdrop is tapped or the hardware back button is pressed. - */ - cancel?: () => void; - - /** - * Called when one of the non-destructive buttons is clicked, with the index of the button that was clicked and the button object. - * Return true to close the action sheet, or false to keep it opened. - */ - buttonClicked?: () => boolean; - - /** - * Called when the destructive button is clicked. Return true to close the action sheet, or false to keep it opened. - */ - destructiveButtonClicked?: () => boolean; - - /** - * Whether to cancel the actionSheet when navigating to a new state. Default true. - */ - cancelOnStateChange?: boolean; - } - - /** - * Angular service: $ionicActionSheet - * - * The Action Sheet is a slide-up pane that lets the user choose from a set of options. Dangerous options are highlighted in red and made obvious. - * There are easy ways to cancel out of the action sheet, such as tapping the backdrop or even hitting escape on the keyboard for desktop testing. - */ - interface IActionSheet { - /** - * Load and return a new action sheet. - * A new isolated scope will be created for the action sheet and the new element will be appended into the body. - * - * Returns hideSheet, a function which, when called, hides & cancels the action sheet. - */ - show(options: IActionSheetOptions): () => void; - } - //#endregion - - //#region Backdrop - - /** - * Angular service: $ionicBackdrop - */ - interface IBackdrop { - /** - * Retains the backdrop. - */ - retain(): void; - - /** - * Releases the backdrop. - */ - release(): void; - } - //#endregion - - //#region Lists - - /** - * Angular service: $ionicListDelegate - * - * Delegate for controlling the ionList directive. - * Methods called directly on the $ionicListDelegate service will control all lists. Use the $getByHandle method to control specific ionList instances. - */ - interface IListDelegate { - /** - * Set whether or not this list is showing its reorder buttons. - * Returns whether the reorder buttons are shown. - */ - showReorder(showReorder?: boolean): boolean; - - /** - * Set whether or not this list is showing its delete buttons. - * Returns whether the delete buttons are shown. - */ - showDelete(showDelete?: boolean): boolean; - - /** - * Set whether or not this list is able to swipe to show option buttons. - * Returns whether the list is able to swipe to show option buttons. - */ - canSwipeItems(canSwipeItems?: boolean): boolean; - - /** - * Closes any option buttons on the list that are swiped open. - */ - closeOptionButtons(): void; - - /** - * Return delegate instance that controls only the ionTabs directives with delegate-handle matching the given handle. - */ - $getByHandle(handle: string): IListDelegate; - } - //#endregion - - //#region Loading - interface ILoadingOptions { - template?: string; - templateUrl?: string; - noBackdrop?: boolean; - delay?: number; - duration?: number; - } - - /** - * Angular service: $ionicLoading - * - * An overlay that can be used to indicate activity while blocking user interaction. - */ - interface ILoading { - show(opts?: ILoadingOptions): void; - - hide(): void; - } - //#endregion - - //#region Modals - - interface IModalOptions { - /** - * The scope to be a child of. Default: creates a child of $rootScope. - */ - scope?: ng.IScope; - - /** - * The animation to show & hide with. Default: 'slide-in-up' - */ - animation?: string; - - /** - * Whether to autofocus the first input of the modal when shown. Default: false. - */ - focusFirstInput?: boolean; - - /** - * Whether to close the modal on clicking the backdrop. Default: true. - */ - backdropClickToClose?: boolean; - - /** - * Whether the modal can be closed using the hardware back button on Android and similar devices. Default: true. - */ - hardwareBackButtonClose?: boolean; - } - - /** - * Angular service: $ionicModal - */ - interface IModal { - /** - * Creates a new modal controller instance. - * - * @param options An IModalOptions object - */ - initialize(options: IModalOptions): void; - - // TODO: add Promise object as returns - - /** - * Show this modal instance - * Returns a promise which is resolved when the modal is finished animating in - */ - show(): any; - - /** - * Hide this modal instance - * Returns a promise which is resolved when the modal is finished animating out - */ - hide(): any; - - /** - * Remove this modal instance from the DOM and clean up - * Returns a promise which is resolved when the modal is finished animating out - */ - remove(): any; - - /** - * Returns whether this modal is currently shown. - */ - isShown(): boolean; - } - - //#endregion - - //#region Navigation - - /** - * Angular service: $ionicNavBarDelegate - * - * Delegate for controlling the ionNavBar directive. - */ - interface INavBarDelegate { - /** - * Goes back in the view history - * - * @param event The event object (eg from a tap event) - */ - back(event?: Event): void; - - /** - * Aligns the title with the buttons in a given direction - * - * @param direction The direction to the align the title text towards. Available: 'left', 'right', 'center'. Default: 'center'. - */ - align(direction?: string): void; - align(direction: "left"): void; - align(direction: "right"): void; - align(direction: "center"): void; - - /** - * Set/get whether the ionNavBackButton is shown (if it exists). - * Returns whether the back button is shown - * - * @param show Whether to show the back button - */ - showBackButton(show?: boolean): boolean; - - /** - * Set/get whether the ionNavBar is shown - * Returns whether the bar is shown - * - * @param show whether to show the bar - */ - showBar(show?: boolean): boolean; - - /** - * Set the title for the ionNavBar - * - * @param title The new title to show - */ - setTitle(title: string): void; - - /** - * Change the title, transitioning the new title in and the old one out in a given direction - * - * @param title the new title to show - * @param direction the direction to transition the new title in. Available: 'forward', 'back'. - */ - changeTitle(title: string, direction: string): void; - changeTitle(title: string, direction: "forward"): void; - changeTitle(title: string, direction: "back"): void; - - /** - * Returns the current title of the navbar. - */ - getTitle(): string; - - /** - * Returns the previous title of the navbar. - */ - getPreviousTitle(): string; - - /** - * Return a delegate instance that controls only the navBars with delegate-handle matching the given handl - */ - $getByHandle(handle: string): INavBarDelegate; - } - - //#region Tabs - interface ITabsDelegate { - - /** - * Select the tab matching the given index. - * - * @param index Index of the tab to select. - */ - select(index: number): void; - - /** - * Returns the index of the selected tab, or -1. - */ - selectedIndex(): number; - - /** - * Return delegate instance that controls only the ionTabs directives with delegate-handle matching the given handle. - */ - $getByHandle(handle: string): ITabsDelegate; - } - //#endregion -} - -declare var ionic: Ionic.IBase; \ No newline at end of file diff --git a/ionic/ionic.domUtil.d.ts b/ionic/ionic.domUtil.d.ts deleted file mode 100644 index f6caec793..000000000 --- a/ionic/ionic.domUtil.d.ts +++ /dev/null @@ -1,88 +0,0 @@ - - -declare module Ionic { - /** - * ionic.DomUtil - */ - interface IDomUtil { - /** - * alias: ionic.requestAnimationFrame - * - * Calls requestAnimationFrame, or a polyfill if not available. - * - * @param callback The function to call when the next frame happens - */ - requestAnimationFrame(callback: () => void): void; - - /** - * alias: ionic.animationFrameThrottle - * - * When given a callback, if that callback is called 100 times between animation frames, adding Throttle will make it only run the last of the 100 calls. - * - * @param callback a function which will be throttled to requestAnimationFrame - */ - animationFrameThrottle(callback: () => void): void; - - /** - * Find an element's scroll offset within its container - * - * @param element The element to find the offset of - */ - getPositionInParent(element: Element): void; - - /** - * The Window.requestAnimationFrame() method tells the browser that you wish to perform an animation and requests that the browser - * call a specified function to update an animation before the next repaint. - * The method takes as an argument a callback to be invoked before the repaint. - * - * @param callback The function to be called - */ - ready(callback: () => void): void; - - /** - * Get a rect representing the bounds of the given textNode. - */ - getTextBounds(textNode: Element): { - left: number; - right: number; - top: number; - bottom: number; - width: number; - height: number; - }; - - /** - * Get the first index of a child node within the given element of the specified type. - * - * @param element The element to find the index of. - * @param type The nodeName to match children of element against. - */ - getChildIndex(element: Element, type: string): number; - - /** - * Returns the closest parent of element matching the className, or null. - * - * @param element - * @param className - */ - getParentWithClass(element: Element, className: string): Element - - /** - * Returns the closest parent or self matching the className, or null. - */ - getParentOrSelfWithClass(element: Element, className: string): Element; - - - /** - * Returns whether {x,y} fits within the rectangle defined by {x1,y1,x2,y2}. - * - * @param x - * @param y - * @param x1 - * @param y1 - * @param x2 - * @param y2 - */ - rectContains(x: number, y: number, x1: number, y1: number, x2: number, y2: number): boolean; - } -} \ No newline at end of file diff --git a/ionic/ionic.eventController.d.ts b/ionic/ionic.eventController.d.ts deleted file mode 100644 index 3aa06bbdb..000000000 --- a/ionic/ionic.eventController.d.ts +++ /dev/null @@ -1,114 +0,0 @@ -declare module Ionic { - - /** - * Angular service: $ionicGesture - */ - interface IEventController { - /** - * alias: ionic.trigger - * - * @param eventType The event to trigger - * @param data The data for the event. Hint: pass in {target: targetElement} - * @param bubbles Whether the event should bubble up the DOM - * @param cancel able Whether the event should be cancel able - */ - trigger(eventType: string, data: Object, bubbles?: boolean, cancelable?: boolean): void; - - /** - * alias: ionic.on - * - * Listen to an event on an element - * - * @param type The event to listen for - * @param callback The listener to be called - * @param element The element to listen for the event on - */ - on(type: string, callback: () => void, element: Element): void; - - /** - * alias: ionic.off - * - * Remove an event listener - * - * @param type The event to listen for - * @param callback The listener to be called - * @param element The element to listen for the event on - */ - off(type: string, callback: () => void, element: Element): void; - - /** - * alias: ionic.onGesture - * - * Add an event listener for a gesture on an element. - * - * @param eventType The gesture event to listen for - * @param callback The function to call when the gesture happens - * @param element The angular element to listen for the event on - */ - onGesture(eventType: string, callback: () => void, element: Element): void; - onGesture(eventType: "hold", callback: () => void, element: Element): void; - onGesture(eventType: "tap", callback: () => void, element: Element): void; - onGesture(eventType: "doubletap", callback: () => void, element: Element): void; - onGesture(eventType: "drag", callback: () => void, element: Element): void; - onGesture(eventType: "dragstart", callback: () => void, element: Element): void; - onGesture(eventType: "dragend", callback: () => void, element: Element): void; - onGesture(eventType: "dragup", callback: () => void, element: Element): void; - onGesture(eventType: "dragdown", callback: () => void, element: Element): void; - onGesture(eventType: "dragleft", callback: () => void, element: Element): void; - onGesture(eventType: "dragright", callback: () => void, element: Element): void; - onGesture(eventType: "swipe", callback: () => void, element: Element): void; - onGesture(eventType: "swipeup", callback: () => void, element: Element): void; - onGesture(eventType: "swipedown", callback: () => void, element: Element): void; - onGesture(eventType: "swipeleft", callback: () => void, element: Element): void; - onGesture(eventType: "swiperight", callback: () => void, element: Element): void; - onGesture(eventType: "transform", callback: () => void, element: Element): void; - onGesture(eventType: "transformstart", callback: () => void, element: Element): void; - onGesture(eventType: "transformend", callback: () => void, element: Element): void; - onGesture(eventType: "rotate", callback: () => void, element: Element): void; - onGesture(eventType: "pinch", callback: () => void, element: Element): void; - onGesture(eventType: "pinchin", callback: () => void, element: Element): void; - onGesture(eventType: "pinchout", callback: () => void, element: Element): void; - onGesture(eventType: "touch", callback: () => void, element: Element): void; - onGesture(eventType: "release", callback: () => void, element: Element): void; - - /** - * alias: ionic.offGesture - * - * Remove an event listener for a gesture on an element. - * - * @param eventType The gesture event - * @param callback The listener that was added earlier - * @param element The element the listener was added on - */ - offGesture(eventType: string, callback: () => void, element: Element): void; - offGesture(eventType: "hold", callback: () => void, element: Element): void; - offGesture(eventType: "tap", callback: () => void, element: Element): void; - offGesture(eventType: "doubletap", callback: () => void, element: Element): void; - offGesture(eventType: "drag", callback: () => void, element: Element): void; - offGesture(eventType: "dragstart", callback: () => void, element: Element): void; - offGesture(eventType: "dragend", callback: () => void, element: Element): void; - offGesture(eventType: "dragup", callback: () => void, element: Element): void; - offGesture(eventType: "dragdown", callback: () => void, element: Element): void; - offGesture(eventType: "dragleft", callback: () => void, element: Element): void; - offGesture(eventType: "dragright", callback: () => void, element: Element): void; - offGesture(eventType: "swipe", callback: () => void, element: Element): void; - offGesture(eventType: "swipeup", callback: () => void, element: Element): void; - offGesture(eventType: "swipedown", callback: () => void, element: Element): void; - offGesture(eventType: "swipeleft", callback: () => void, element: Element): void; - offGesture(eventType: "swiperight", callback: () => void, element: Element): void; - offGesture(eventType: "transform", callback: () => void, element: Element): void; - offGesture(eventType: "transformstart", callback: () => void, element: Element): void; - offGesture(eventType: "transformend", callback: () => void, element: Element): void; - offGesture(eventType: "rotate", callback: () => void, element: Element): void; - offGesture(eventType: "pinch", callback: () => void, element: Element): void; - offGesture(eventType: "pinchin", callback: () => void, element: Element): void; - offGesture(eventType: "pinchout", callback: () => void, element: Element): void; - offGesture(eventType: "touch", callback: () => void, element: Element): void; - offGesture(eventType: "release", callback: () => void, element: Element): void; - } - - /** - * Angular service: $ionicGesture - */ - interface IGesture extends IEventController { } -} \ No newline at end of file diff --git a/ionic/ionic.platform.d.ts b/ionic/ionic.platform.d.ts deleted file mode 100644 index 5cda22ac5..000000000 --- a/ionic/ionic.platform.d.ts +++ /dev/null @@ -1,103 +0,0 @@ - - -declare module Ionic { - - interface IPlatform { - //#region Properties - /** - * Whether the device is ready - */ - isReady: boolean; - - /** - * Whether the device is full screen. - */ - isFullScreen: boolean; - - /** - * An array of all platforms found. - */ - platforms: string[]; - - /** - * What grade the current platform is. - */ - grade: string; - //#endregion - - - /** - * Trigger a callback once the device is ready, or immediately if the device is already ready. - * This method can be run from anywhere and does not need to be wrapped by any additional methods. - * When the app is within a WebView (Cordova), it'll fire the callback once the device is ready. - * If the app is within a web browser, it'll fire the callback after window.load. - */ - ready(callback: () => void): void; - - /** - * Set the grade of the device: 'a', 'b', or 'c'. 'a' is the best (most css features enabled), - * 'c' is the worst. By default, sets the grade depending on the current device. - */ - setGrade(grade): void; - - /** - * Return the current device (given by Cordova). - */ - device(): IDevice; - - /** - * Check if we are running within a WebView (such as Cordova). - */ - isWebView(): boolean; - - /** - * Whether we are running on iPad. - */ - isIPad(): boolean; - - /** - * Whether we are running on iOS. - */ - isIOS(): boolean; - - /** - * Whether we are running on Android - */ - isAndroid(): boolean; - - /** - * Whether we are running on Windows Phone. - */ - isWindowsPhone(): boolean; - - /** - * The name of the current platform. - */ - platform(): string; - - /** - * The version of the current device platform. - */ - version(): string; - - /** - * Exit the application. - */ - exitApp(): void; - - /** - * Shows or hides the device status bar (in Cordova). - * - * @param showShould Whether or not to show the status bar. - */ - showStatusBar(shouldShow: boolean): void; - - /** - * Sets whether the app is full screen or not (in Cordova). - * - * @param showFullScreen Whether or not to set the app to full screen. Defaults to true. - * @param showStatusBar Whether or not to show the device's status bar. Defaults to false. - */ - fullScreen(showFullScreen: boolean, showStatusBar: boolean): void; - } -} \ No newline at end of file diff --git a/ionic/ionic.popover.d.ts b/ionic/ionic.popover.d.ts deleted file mode 100644 index d15ba3b06..000000000 --- a/ionic/ionic.popover.d.ts +++ /dev/null @@ -1,82 +0,0 @@ -declare module Ionic { - interface IPopoverOptions { - /** - * The scope to be a child of. Default: creates a child of $rootScope - */ - scope?: ng.IScope; - - /** - * Whether to autofocus the first input of the popover when shown. Default: false - */ - focusFirstInput?: boolean; - - /** - * Whether to close the popover on clicking the backdrop. Default: true - */ - backdropClickToClose?: boolean; - - /** - * Whether the popover can be closed using the hardware back button on Android and similar devices. Default: true - */ - hardwareBackButtonClose?: boolean; - } - - /** - * Angular service: $ionicPopover - * - * The Popover is a view that floats above an app’s content. - * Popovers provide an easy way to present or gather information from the user and are commonly used in the following situations: - * show more info about the current view, select a commonly used tool or configuration, present a list of actions to perform inside one of your views. - * Put the content of the popover inside of an element - */ - interface IPopover { - /** - * @param templateString The template string to use as the popovers's content - * @param Options to be passed to the initialize method - */ - fromTemplate(templateString: string, options: IPopoverOptions): IPopover; - - // TODO: promise - /** - * Returns a promise that will be resolved with an instance of an ionicPopover controller ($ionicPopover is built on top of $ionicPopover). - * - * @param templateUrl The url to load the template from - * @param Options to be passed to the initialize method - */ - fromTemplateUrl(templateUrl: string, options: IPopoverOptions): any; - - /** - * Creates a new popover controller instance - * - */ - initialize(options: IPopoverOptions): void; - - // TODO: promise - /** - * Show this popover instance. - * Returns a promise which is resolved when the popover is finished animating in. - * - * @param $event The $event or target element which the popover should align itself next to. - */ - show($event: any): any; - - // TODO: promise - /** - * Hide this popover instance. - * Returns a promise which is resolved when the popover is finished animating out. - */ - hide(): any; - - // TODO: promise - /** - * Remove this popover instance from the DOM and clean up. - * Returns a promise which is resolved when the popover is finished animating out. - */ - remove(): any; - - /** - * Returns whether this popover is currently shown. - */ - isShown(): boolean; - } -} \ No newline at end of file diff --git a/ionic/ionic.popup.d.ts b/ionic/ionic.popup.d.ts deleted file mode 100644 index 299d4b12b..000000000 --- a/ionic/ionic.popup.d.ts +++ /dev/null @@ -1,219 +0,0 @@ -declare module Ionic { - interface IPopupButton { - text: string; - type: string; - onTap(e: Event): void; - } - - interface IPopupOptions { - /** - * The title of the popup - */ - title: string; - - /** - * The sub-title of the popup - */ - subTitle?: string; - - /** - * The html template to place in the popup body - */ - template?: string; - - /** - * The URL of an html template to place in the popup body - */ - templateUrl?: string; - - /** - * A scope to link to the popup content - */ - scope?: ng.IScope; - - /** - * Buttons to place in the popup footer - */ - buttons?: Array; - } - - interface IPopupAlertOptions { - /** - * The title of the popup - */ - title: string; - - /** - * The sub-title of the popup - */ - subTitle?: string; - - /** - * The html template to place in the popup body - */ - template?: string; - - /** - * The URL of an html template to place in the popup body - */ - templateUrl?: string; - - /** - * The text of the OK button - */ - okText?: string; - - /** - * The type of the OK button - */ - okType?: string; - } - - interface IPopupConfirmOptions { - /** - * The title of the popup - */ - title: string; - - /** - * The sub-title of the popup - */ - subTitle?: string; - - /** - * The html template to place in the popup body - */ - template?: string; - - /** - * The URL of an html template to place in the popup body - */ - templateUrl?: string; - - /** - * The text of the Cancel button - */ - canelText?: string; - - /** - * The type of the Cancel button - */ - cancelType?: string; - - /** - * The text of the OK button - */ - okText?: string; - - /** - * The type of the OK button - */ - okType?: string; - } - - interface IPopupPromptOptions { - /** - * The title of the popup - */ - title: string; - - /** - * The sub-title of the popup - */ - subTitle?: string; - - /** - * The html template to place in the popup body - */ - template?: string; - - /** - * The URL of an html template to place in the popup body - */ - templateUrl?: string; - - /** - * The type of input of use - */ - inputType: string; - - /** - * A placeholder to use for the input - */ - inputPlaceholder: string; - - /** - * The text of the Cancel button - */ - canelText?: string; - - /** - * The type of the Cancel button - */ - cancelType?: string; - - /** - * The text of the OK button - */ - okText?: string; - - /** - * The type of the OK button - */ - okType?: string; - } - - /** - * Angular service: $ionicPopup - * - * The Ionic Popup service allows programmatically creating and showing popup windows that require the user to respond in order to continue. - * The popup system has support for more flexible versions of the built in alert(), prompt(), and confirm() functions that users are used to, - * in addition to allowing popups with completely custom content and look. - * An input can be given an autofocus attribute so it automatically receives focus when the popup first shows. - * However, depending on certain use-cases this can cause issues with the tap/click system, - * which is why Ionic prefers using the autofocus attribute as an opt-in feature and not the default. - */ - interface IPopup { - // TODO: promise - /** - * Show a complex popup. This is the master show function for all popups. - * A complex popup has a buttons array, with each button having a text and type field, in addition to an onTap function. - * The onTap function, called when the correspondingbutton on the popup is tapped, - * will by default close the popup and resolve the popup promise with its return value. - * If you wish to prevent the default and keep the popup open on button tap, call event.preventDefault() on the passed in tap event. - * - * Returns a promise which is resolved when the popup is closed. Has an additional close function, which can be used to programmatically close the popup. - * - * @param options The options for the new popup - */ - show(options: IPopupOptions): any; - - /** - * Show a simple alert popup with a message and one button that the user can tap to close the popup. - * - * Returns a promise which is resolved when the popup is closed. Has one additional function close, which can be called with any value to programmatically close the popup with the given value. - * - * @param options The options for showing the alert - */ - alert(options: IPopupAlertOptions): any; - - /** - * Show a simple confirm popup with a Cancel and OK button. - * Resolves the promise with true if the user presses the OK button, and false if the user presses the Cancel button. - * - * Returns a promise which is resolved when the popup is closed. Has one additional function close, which can be called with any value to programmatically close the popup with the given value. - * - * @parma options The options for showing the confirm popup - */ - confirm(options: IPopupConfirmOptions): any; - - /** - * Show a simple prompt popup, which has an input, OK button, and Cancel button. Resolves the promise with the value of the input if the user presses OK, and with undefined if the user presses Cancel. - * - * Returns a promise which is resolved when the popup is closed. Has one additional function close, which can be called with any value to programmatically close the popup with the given value. - * - * @param options The options for showing the prompt popup - */ - prompt(options: IPopupPromptOptions): any; - } -} \ No newline at end of file diff --git a/ionic/ionic.scroll.d.ts b/ionic/ionic.scroll.d.ts deleted file mode 100644 index 880bc2fe3..000000000 --- a/ionic/ionic.scroll.d.ts +++ /dev/null @@ -1,106 +0,0 @@ -declare module Ionic { - interface IScrollPosition { - /** - * The distance the user has scrolled from the left (starts at 0) - */ - left: number; - - /** - * The distance the user has scrolled from the top (starts at 0) - */ - top: number; - } - - /** - * Angular service: $ionicScrollDelegate - * - * Delegate for controlling scrollViews (created by ionContent and ionScroll directives). - * Methods called directly on the $ionicScrollDelegate service will control all scroll views. Use the $getByHandle method to control specific scrollViews. - */ - interface IScrollDelegate { - /** - * Tell the scrollView to recalculate the size of its container - */ - resize(): void; - - - /** - * @param shouldAnimate Whether the scroll should animate - */ - scrollTop(shouldAnimate?: boolean): void; - - - /** - * @param shouldAnimate Whether the scroll should animate - */ - scrollBottom(shouldAnimate?: boolean): void; - - - - /** - * @param left The x-value to scroll to - * @param top The y-value to scroll to - * @param shouldAnimate Whether the scroll should animate - */ - scrollTo(left: number, top: number, shouldAnimate?: boolean): void; - - /** - * @param left The x-offset to scroll by - * @param top The y-offset to scroll by - * @param shouldAnimate Whether the scroll should animate - */ - scrollBy(left: number, top: number, shouldAnimate?: boolean): void; - - /** - * @param level Level to zoom to - * @param animate Whether to animate the zoom - * @param originLeft Zoom in at given left coordinate - * @param originTop Zoom in at given top coordinate - */ - zoomTo(level: number, animate?: boolean, originLeft?: number, originTop?: number): void; - - /** - * @param factor The factor to zoom by - * @param animate Whether to animate the zoom - * @param originLeft Zoom in at given left coordinate - * @param originTop Zoom in at given top coordinate - */ - zoomBy(factor: number, animate?: boolean, originLeft?: number, originTop?: number): void; - - /** - * Returns the scroll position of this view - */ - getScrollPosition(): IScrollPosition; - - /** - * Tell the scrollView to scroll to the element with an id matching window.location.hash - * If no matching element is found, it will scroll to top - * - * @param shouldAnimate Whether the scroll should animate - */ - anchorScroll(shouldAnimate?: boolean): void; - - /** - * Returns the scrollView associated with this delegate. - */ - // TODO: define ScrollView object - getScrollView(): any; - - /** - * Stop remembering the scroll position for this scrollView - */ - forgetScrollPosition(): void; - - /** - * If this scrollView has an id associated with its scroll position, (through calling rememberScrollPosition), and that position is remembered, load the position and scroll to it. - * - * @param shouldAnimate Whether the scroll should animate - */ - scrollToRememberedPosition(shouldAnimate?: boolean): void; - - /** - * Return a delegate instance that controls only the scrollViews with delegate-handle matching the given handle. - */ - $getByHandle(handle: string): IScrollDelegate; - } -} \ No newline at end of file diff --git a/ionic/ionic.sideMenus.d.ts b/ionic/ionic.sideMenus.d.ts deleted file mode 100644 index 9cd132172..000000000 --- a/ionic/ionic.sideMenus.d.ts +++ /dev/null @@ -1,71 +0,0 @@ -declare module Ionic { - /** - * Angular service: $ionicSideMenuDelegate - * - * Delegate for controlling the ionSideMenus directive. - * Methods called directly on the $ionicSideMenuDelegate service will control all side menus. Use the $getByHandle method to control specific ionSideMenus instances. - */ - interface ISideMenuDelegate { - /** - * Toggle the left side menu (if it exists). - * - * @param isOpen Whether to open or close the menu. Default: Toggles the menu. - */ - toggleLeft(isOpen?: boolean): void; - - - /** - * Toggle the right side menu (if it exists). - * - * @param isOpen Whether to open or close the menu. Default: Toggles the menu. - */ - toggleRight(isOpen?: boolean): void; - - /** - * Gets the ratio of open amount over menu width. For example, a menu of width 100 that is opened by 50 pixels is 50% opened, and would return a ratio of 0.5. - * Returns 0 if nothing is open, between 0 and 1 if left menu is opened/opening, and between 0 and -1 if right menu is opened/opening. - */ - getOpenRatio(): number; - - /** - * Returns whether either the left or right menu is currently opened. - */ - isOpen(): boolean; - - /** - * Returns whether the left menu is currently opened. - */ - isOpenLeft(): boolean; - - /** - * Returns whether the right menu is currently opened. - */ - isOpenRight(): boolean; - - /** - * Returns whether the content can be dragged to open side menus. - * - * @param canDrag Set whether the content can or cannot be dragged to open side menus - */ - canDragContent(canDrag?: boolean): boolean; - - /** - * Returns whether the drag can start only from within the edge of screen threshold. - * - * @param value Set whether the content drag can only start if it is below a certain threshold distance from the edge of the screen. If a non-zero number is given, that many pixels is used as the maximum allowed distance from the edge that starts dragging the side menu. If 0 is given, the edge drag threshold is disabled, and dragging from anywhere on the content is allowed. - */ - edgeDragThreshold(value: boolean): boolean; - - /** - * Returns whether the drag can start only from within the edge of screen threshold. - * - * @param value Set whether the content drag can only start if it is below a certain threshold distance from the edge of the screen. If true is given, the default number of pixels (25) is used as the maximum allowed distance. If false is given, the edge drag threshold is disabled, and dragging from anywhere on the content is allowed. - */ - edgeDragThreshold(value: number): boolean; - - /** - * Return a delegate instance that controls only the ionSideMenus directives with delegate-handle matching the given handle. - */ - $getByHandle(handle: string): ISideMenuDelegate; - } -} \ No newline at end of file diff --git a/ionic/ionic.slideBox.d.ts b/ionic/ionic.slideBox.d.ts deleted file mode 100644 index 4b29c1ef2..000000000 --- a/ionic/ionic.slideBox.d.ts +++ /dev/null @@ -1,62 +0,0 @@ -declare module Ionic { - /** - * Angular service: $ionicSlideBoxDelegate - * - * Delegate that controls the ionSlideBox directive. - * Methods called directly on the $ionicSlideBoxDelegate service will control all slide boxes. Use the $getByHandle method to control specific slide box instances. - */ - interface ISlideBoxDelegate { - /** - * Update the slidebox (for example if using Angular with ng-repeat, resize it for the elements inside). - */ - update(): void; - - /** - * @param to The index to slide to - * @param speed The number of milliseconds for the change to take - */ - slide(to: number, speed?: number): void; - - /** - * Returns whether sliding is enabled. - * - * @param shouldEnable Whether to enable sliding the slidebox. - */ - enableSlide(shouldEnable?: boolean): boolean; - - /** - * Go to the previous slide. Wraps around if at the beginning. - */ - previous(): void; - - /** - * Go to the next slide. Wraps around if at the end. - */ - next(): void; - - /** - * Stop sliding. The slideBox will not move again until explicitly told to do so. - */ - stop(): void; - - /** - * Start sliding again if the slideBox was stopped. - */ - start(): void; - - /** - * Returns the index of the current slide. - */ - currentIndex(): number; - - /** - * Returns the number of slides there are currently. - */ - slidesCount(): number; - - /** - * Returns a delegate instance that controls only the ionSlideBox directives with delegate-handle matching the given handle. - */ - $getByHandle(handle: string): ISlideBoxDelegate; - } -} \ No newline at end of file From cc6f556e9dc97cbc59c907497ed5253be4679b64 Mon Sep 17 00:00:00 2001 From: Lokesh Peta Date: Sun, 22 Feb 2015 19:04:41 +0000 Subject: [PATCH 063/185] corrected file and folder name --- jquery.jqgrid/jquery.jqgrid-tests.ts => jqgrid/jqgrid-tests.ts | 2 +- jquery.jqgrid/jquery.jqgrid.d.ts => jqgrid/jqgrid.d.ts | 0 .../jqgrid.d.ts.tscparams | 0 3 files changed, 1 insertion(+), 1 deletion(-) rename jquery.jqgrid/jquery.jqgrid-tests.ts => jqgrid/jqgrid-tests.ts (84%) rename jquery.jqgrid/jquery.jqgrid.d.ts => jqgrid/jqgrid.d.ts (100%) rename jquery.jqgrid/jquery.jqgrid.d.ts.tscparams => jqgrid/jqgrid.d.ts.tscparams (100%) diff --git a/jquery.jqgrid/jquery.jqgrid-tests.ts b/jqgrid/jqgrid-tests.ts similarity index 84% rename from jquery.jqgrid/jquery.jqgrid-tests.ts rename to jqgrid/jqgrid-tests.ts index 04471c7de..64b7d7d7b 100644 --- a/jquery.jqgrid/jquery.jqgrid-tests.ts +++ b/jqgrid/jqgrid-tests.ts @@ -3,4 +3,4 @@ // Definitions: https://github.com/borisyankov/DefinitelyTyped /// -/// \ No newline at end of file +/// \ No newline at end of file diff --git a/jquery.jqgrid/jquery.jqgrid.d.ts b/jqgrid/jqgrid.d.ts similarity index 100% rename from jquery.jqgrid/jquery.jqgrid.d.ts rename to jqgrid/jqgrid.d.ts diff --git a/jquery.jqgrid/jquery.jqgrid.d.ts.tscparams b/jqgrid/jqgrid.d.ts.tscparams similarity index 100% rename from jquery.jqgrid/jquery.jqgrid.d.ts.tscparams rename to jqgrid/jqgrid.d.ts.tscparams From 79b981601b6c717edd034481b800a989344cf4bb Mon Sep 17 00:00:00 2001 From: Rogier Schouten Date: Mon, 23 Feb 2015 09:02:23 +0100 Subject: [PATCH 064/185] travis fix --- bitwise-xor/bitwise-xor-tests.ts | 1 - bitwise-xor/bitwise-xor.d.ts | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/bitwise-xor/bitwise-xor-tests.ts b/bitwise-xor/bitwise-xor-tests.ts index 9bd030fd1..66b67a7b5 100644 --- a/bitwise-xor/bitwise-xor-tests.ts +++ b/bitwise-xor/bitwise-xor-tests.ts @@ -1,5 +1,4 @@ -/// /// "use strict"; diff --git a/bitwise-xor/bitwise-xor.d.ts b/bitwise-xor/bitwise-xor.d.ts index 091789e7f..0db872f91 100644 --- a/bitwise-xor/bitwise-xor.d.ts +++ b/bitwise-xor/bitwise-xor.d.ts @@ -3,6 +3,7 @@ // Definitions by: Rogier Schouten // Definitions: https://github.com/borisyankov/DefinitelyTyped +/// declare module "bitwise-xor" { /** From f721912afcbf3de81e2ff8fd41975a46a431179e Mon Sep 17 00:00:00 2001 From: Lokesh Peta Date: Mon, 23 Feb 2015 10:23:03 +0000 Subject: [PATCH 065/185] corrected file and folder names --- jquery.maskedinput/jquery.maskedinput-tests.ts | 7 ------- maskedinput/maskedinput-tests.ts | 12 ++++++++++++ .../maskedinput.d.ts | 0 .../maskedinput.d.ts.tscparams | 0 4 files changed, 12 insertions(+), 7 deletions(-) delete mode 100644 jquery.maskedinput/jquery.maskedinput-tests.ts create mode 100644 maskedinput/maskedinput-tests.ts rename jquery.maskedinput/jquery.maskedinput.d.ts => maskedinput/maskedinput.d.ts (100%) rename jquery.maskedinput/jquery.maskedinput.d.ts.tscparams => maskedinput/maskedinput.d.ts.tscparams (100%) diff --git a/jquery.maskedinput/jquery.maskedinput-tests.ts b/jquery.maskedinput/jquery.maskedinput-tests.ts deleted file mode 100644 index a50b815bb..000000000 --- a/jquery.maskedinput/jquery.maskedinput-tests.ts +++ /dev/null @@ -1,7 +0,0 @@ -/// -/// - -$("#test").inputmask("9:000"); -$("#test").inputmask("9:000", { numeric: true }); - -var alies = $.inputmask.defaults.aliases; \ No newline at end of file diff --git a/maskedinput/maskedinput-tests.ts b/maskedinput/maskedinput-tests.ts new file mode 100644 index 000000000..ba9ff33e6 --- /dev/null +++ b/maskedinput/maskedinput-tests.ts @@ -0,0 +1,12 @@ +// Type definitions for Masked Input plugin for jQuery +// Project: http://digitalbush.com/projects/masked-input-plugin +// Definitions by: Lokesh Peta +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// +/// + +$("#test").inputmask("9:000"); +$("#test").inputmask("9:000", { numeric: true }); + +var alies = $.inputmask.defaults.aliases; \ No newline at end of file diff --git a/jquery.maskedinput/jquery.maskedinput.d.ts b/maskedinput/maskedinput.d.ts similarity index 100% rename from jquery.maskedinput/jquery.maskedinput.d.ts rename to maskedinput/maskedinput.d.ts diff --git a/jquery.maskedinput/jquery.maskedinput.d.ts.tscparams b/maskedinput/maskedinput.d.ts.tscparams similarity index 100% rename from jquery.maskedinput/jquery.maskedinput.d.ts.tscparams rename to maskedinput/maskedinput.d.ts.tscparams From e3882dcab88e258736e2e36fc4e61ef7d92d0429 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Morch=C3=B3n=20Poveda?= Date: Mon, 23 Feb 2015 12:47:24 +0100 Subject: [PATCH 066/185] Update gruntjs.d.ts From http://gruntjs.com/api/grunt.task#grunt.task.exists --- gruntjs/gruntjs.d.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gruntjs/gruntjs.d.ts b/gruntjs/gruntjs.d.ts index 7de19d016..ff672d368 100644 --- a/gruntjs/gruntjs.d.ts +++ b/gruntjs/gruntjs.d.ts @@ -790,6 +790,12 @@ declare module grunt { */ registerMultiTask(taskName: string, taskFunction: Function): void registerMultiTask(taskName: string, taskDescription: string, taskFunction: Function): void + + /** + * Check with the name, if a task exists in the registered tasks. + * @since 0.4.5 + */ + exists(name: string): boolean; } /** From 2c48e5c514a15a48ebfff860fc6f051a943d7605 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Morch=C3=B3n=20Poveda?= Date: Mon, 23 Feb 2015 12:55:09 +0100 Subject: [PATCH 067/185] Update gruntjs.d.ts From http://gruntjs.com/api/grunt.task#grunt.task.renametask --- gruntjs/gruntjs.d.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/gruntjs/gruntjs.d.ts b/gruntjs/gruntjs.d.ts index ff672d368..baea9dcfb 100644 --- a/gruntjs/gruntjs.d.ts +++ b/gruntjs/gruntjs.d.ts @@ -793,9 +793,19 @@ declare module grunt { /** * Check with the name, if a task exists in the registered tasks. + * @param name The task name to check. * @since 0.4.5 */ exists(name: string): boolean; + + /** + * Rename a task. This might be useful if you want to override the default behavior of a task, while retaining the old name. + * Note that if a task has been renamed, the this.name and this.nameArgs properties will change accordingly. + * @see ITask + * @param oldname The previous name of the task. + * @param newname The new name for the task. + */ + renameTask(oldname: string, newname: string): void } /** From d32418b336ac9fef21f8e5be6f4dba5dd064ea06 Mon Sep 17 00:00:00 2001 From: Rogier Schouten Date: Mon, 23 Feb 2015 16:01:52 +0100 Subject: [PATCH 068/185] Add typings for windows-service --- CONTRIBUTORS.md | 1 + windows-service/windows-service-tests.ts | 21 +++++++ windows-service/windows-service.d.ts | 74 ++++++++++++++++++++++++ 3 files changed, 96 insertions(+) create mode 100644 windows-service/windows-service-tests.ts create mode 100644 windows-service/windows-service.d.ts diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 019e8b502..e8804ad33 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -770,6 +770,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](websocket/websocket.d.ts) [websocket](https://github.com/Worlize/WebSocket-Node) by [Paul Loyd](https://github.com/loyd) * [:link:](when/when.d.ts) [When](https://github.com/cujojs/when) by [Derek Cicerone](https://github.com/derekcicerone), [Wim Looman](https://github.com/Nemo157) * [:link:](which/which.d.ts) [which](https://github.com/isaacs/node-which) by [vvakame](https://github.com/vvakame) +* [:link:](windows-service/windows-service.d.ts) [windows-service](https://bitbucket.org/stephenwvickers/node-windows-service) by [rogierschouten](https://github.com/rogierschouten) * [:link:](winjs/winjs.d.ts) [WinJS](http://try.buildwinjs.com) by [TypeScript samples](https://www.typescriptlang.org), [Adam Hewitt](https://github.com/adamhewitt627), [Craig Treasure](https://github.com/craigktreasure), [Jeff Fisher](https://github.com/xirzec) * [:link:](winrt/winrt.d.ts) [WinRT](http://msdn.microsoft.com/en-us/library/windows/apps/br211377.aspx) by [TypeScript samples](https://www.typescriptlang.org) * [:link:](winston/winston.d.ts) [winston](https://github.com/flatiron/winston) by [bonnici](https://github.com/bonnici), [Peter Harris](https://github.com/codeanimal) diff --git a/windows-service/windows-service-tests.ts b/windows-service/windows-service-tests.ts new file mode 100644 index 000000000..667a343d9 --- /dev/null +++ b/windows-service/windows-service-tests.ts @@ -0,0 +1,21 @@ +/// + +import stream = require("stream"); +import service = require("windows-service"); + +service.add("MyService"); +service.add("MyService", {programPath: "./service.js"}); + +var s: stream.Writable; +var t: stream.Writable; + +service.run(s, (): void => { + service.stop(0); +}); + +service.run(s, t, (): void => { + service.stop(0); +}); + +service.remove("MyService"); + diff --git a/windows-service/windows-service.d.ts b/windows-service/windows-service.d.ts new file mode 100644 index 000000000..a11666319 --- /dev/null +++ b/windows-service/windows-service.d.ts @@ -0,0 +1,74 @@ +// Type definitions for windows-service 1.0.4 +// Project: https://bitbucket.org/stephenwvickers/node-windows-service +// Definitions by: Rogier Schouten +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// +declare module "windows-service" { + import stream = require("stream"); + + /** + * Options for the add() function. + */ + export interface AddOptions { + /** + * The services display name, defaults to the name parameter + */ + displayName?: string; + /** + * The fully qualified path to the node binary used to run the service (i.e. c:\Program Files\nodejs\node.exe, defaults to the value of process.execPath + */ + nodePath?: string; + /** + * An array of strings specifying parameters to pass to nodePath, defaults to [] + */ + nodeArgs?: string[]; + /** + * The program to run using nodePath, defaults to the value of process.argv[1] + */ + programPath?: string; + /** + * An array of strings specifying parameters to pass to programPath, defaults to [] + */ + programArgs?: string[]; + } + + /** + * The add() function adds a Windows service. The service will be set to automatically start at boot time, but not started. + * The service can be started using the net start "My Service" command. An exception will be thrown if the service could + * not be added. The error will be an instance of the Error class. + * + * @param name The name parameter specifies the name of the created service. + * @param opts Options + */ + export function add(name: string, opts?: AddOptions): void; + + + /** + * The remove() function removes a Windows service. + * The name parameter specifies the name of the service to remove. This will be the same name parameter specified when adding the service. + * The service must be in a stopped state for it to be removed. The net stop "My Service" command can be used to stop the service before + * it is to be removed. + * An exception will be thrown if the service could not be removed. The error will be an instance of the Error class. + */ + export function remove(name: string): void; + + /** + * The run() function will connect the calling program to the Windows Service Control Manager, allowing the program to run as a Windows service. + * The programs process.stdout stream will be replaced with the stdoutLogStream parameter, and the programs process.stderr stream replaced with + * the stdoutLogStream parameter (this allows the redirection of all console.log() type calls to a service specific log file). If the stderrLogStream + * parameter is not specified the programs process.stderr stream will be replaced with the stdoutLogStream parameter. The callback function will be + * called when the service receives a stop request, e.g. because the Windows Service Controller was used to send a stop request to the service. + * The program should perform cleanup tasks and then call the service.stop() function. + */ + export function run(stdoutLogStream: stream.Writable, callback: () => void): void; + export function run(stdoutLogStream: stream.Writable, stderrLogStream: stream.Writable, callback: () => void): void; + + /** + * The stop() function will cause the service to stop, and the calling program to exit. + * Once the service has been stopped this function will terminate the program by calling the process.exit() function, passing to it the rcode + * parameter which defaults to 0. Before calling this function ensure the program has finished performing cleanup tasks. + * BE AWARE, THIS FUNCTION WILL NOT RETURN. + */ + export function stop(rcode?: number): void; +} From 68e963ebc28e0c93bdbc3cbbe44b912fc1410047 Mon Sep 17 00:00:00 2001 From: Rogier Schouten Date: Mon, 23 Feb 2015 17:03:30 +0100 Subject: [PATCH 069/185] Add typings for logrotate-stream --- CONTRIBUTORS.md | 1 + logrotate-stream/logrotate-stream-tests.ts | 10 +++++ logrotate-stream/logrotate-stream.d.ts | 46 ++++++++++++++++++++++ 3 files changed, 57 insertions(+) create mode 100644 logrotate-stream/logrotate-stream-tests.ts create mode 100644 logrotate-stream/logrotate-stream.d.ts diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 019e8b502..46f7aa30f 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -443,6 +443,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](log4javascript/log4javascript.d.ts) [log4javascript](http://log4javascript.org) by [Markus Wagner](https://github.com/Ritzlgrmft) * [:link:](log4js/log4js.d.ts) [log4js](https://github.com/nomiddlename/log4js-node) by [Kentaro Okuno](http://github.com/armorik83) * [:link:](logg/logg.d.ts) [logg](https://github.com/dpup/node-logg) by [Bret Little](https://github.com/blittle) +* [:link:](logrotate-stream/logrotate-stream.d.ts) [logrotate-stream](https://github.com/dstokes/logrotate-stream) by [rogierschouten](https://github.com/rogierschouten) * [:link:](long/long.d.ts) [Long.js](https://github.com/dcodeIO/Long.js) by [Toshihide Hara](https://github.com/kerug) * [:link:](lru-cache/lru-cache.d.ts) [lru-cache](https://github.com/isaacs/node-lru-cache) by [Bart van der Schoor](https://github.com/Bartvds) * [:link:](lscache/lscache.d.ts) [lscache](https://github.com/pamelafox/lscache) by [Chris Martinez](https://github.com/Chris-Martinezz) diff --git a/logrotate-stream/logrotate-stream-tests.ts b/logrotate-stream/logrotate-stream-tests.ts new file mode 100644 index 000000000..c7d4ed809 --- /dev/null +++ b/logrotate-stream/logrotate-stream-tests.ts @@ -0,0 +1,10 @@ +/// + +import stream = require("stream"); +import rotateStream = require("logrotate-stream"); + +var s: stream.Writable = rotateStream({ + file: "mylogfile.log", + size: "1m", + keep: 3 +}); diff --git a/logrotate-stream/logrotate-stream.d.ts b/logrotate-stream/logrotate-stream.d.ts new file mode 100644 index 000000000..97a290fdb --- /dev/null +++ b/logrotate-stream/logrotate-stream.d.ts @@ -0,0 +1,46 @@ +// Type definitions for logrotate-stream 0.2.5 +// Project: https://github.com/dstokes/logrotate-stream +// Definitions by: Rogier Schouten +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// +declare module "logrotate-stream" { + import stream = require("stream"); + + // wrapper to be able to use "export =" while also exporting the Options interface + module logrotateStream { + + /** + * Options object for the exported function. + */ + export interface Options { + /** + * The file log file to write data to. + */ + file: string; + /** + * The max file size of a log before rotation occurs. Supports 1024, 1k, 1m, 1g + */ + size: string; + /** + * The number of rotated log files to keep (including the primary log file). Additional logs are deleted no rotation. + */ + keep: number; + /** + * Optionally compress rotated files with gzip. + */ + compress?: boolean; + } + + } + + /** + * Create a rotating log stream. + * @returns a writable stream to a rotating log file + */ + function logrotateStream(opts: logrotateStream.Options): stream.Writable; + + + export = logrotateStream; +} + From 633d578646fe66bed2367b22a8060c763c2b4463 Mon Sep 17 00:00:00 2001 From: Matt Traynham Date: Mon, 23 Feb 2015 12:58:29 -0500 Subject: [PATCH 070/185] Moved existing dcjs definitions to 1.6.0 version --- dcjs/{dc.d.ts => dc-1.6.0.d.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename dcjs/{dc.d.ts => dc-1.6.0.d.ts} (100%) diff --git a/dcjs/dc.d.ts b/dcjs/dc-1.6.0.d.ts similarity index 100% rename from dcjs/dc.d.ts rename to dcjs/dc-1.6.0.d.ts From bb626a5db1b469df18919ab8b1ea22ca6cd0479b Mon Sep 17 00:00:00 2001 From: Matt Traynham Date: Mon, 23 Feb 2015 14:00:54 -0500 Subject: [PATCH 071/185] Updates dc.js type definitions to latest --- dcjs/dc-tests.ts | 411 +++++++++++++++++++++----------------------- dcjs/dc.d.ts | 433 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 629 insertions(+), 215 deletions(-) create mode 100644 dcjs/dc.d.ts diff --git a/dcjs/dc-tests.ts b/dcjs/dc-tests.ts index 60d3aa059..91b1dc77d 100644 --- a/dcjs/dc-tests.ts +++ b/dcjs/dc-tests.ts @@ -3,240 +3,221 @@ /// interface IYelpData { - city: string; - review_count: number; - name: string; - neighborhoods: string[]; - type: string; - business_id: string; - full_address: string; - state: string; - longitude: number; - stars: number; - latitude: number; - open: boolean; - categories: string[] + city: string; + review_count: number; + name: string; + neighborhoods: string[]; + type: string; + business_id: string; + full_address: string; + state: string; + longitude: number; + stars: number; + latitude: number; + open: boolean; + categories: string[] } interface IYelpDataExtended { - count: number; - review_sum: number; - star_sum: number; - review_avg: number; - star_avg: number; + count: number; + review_sum: number; + star_sum: number; + review_avg: number; + star_avg: number; } /******************************************************** -* * -* dj.js example using Yelp Kaggle Test Dataset * -* Eamonn O'Loughlin 9th May 2013 * -* * -********************************************************/ + * * + * dj.js example using Yelp Kaggle Test Dataset * + * Eamonn O'Loughlin 9th May 2013 * + * * + ********************************************************/ /******************************************************** -* * -* Step0: Load data from json file * -* * -********************************************************/ -d3.json("data/yelp_test_set_business.json", function (yelp_data:IYelpData[]) { - -/******************************************************** -* * -* Step1: Create the dc.js chart objects & ling to div * -* * -********************************************************/ -var bubbleChart = dc.bubbleChart("#dc-bubble-graph"); -var pieChart = dc.pieChart("#dc-pie-graph"); -var volumeChart = dc.barChart("#dc-volume-chart"); -var lineChart = dc.lineChart("#dc-line-chart"); -var dataTable = dc.dataTable("#dc-table-graph"); -var rowChart = dc.rowChart("#dc-row-graph"); + * * + * Step0: Load data from json file * + * * + ********************************************************/ +d3.json("data/yelp_test_set_business.json", (yelp_data:IYelpData[]) => { -/******************************************************** -* * -* Step2: Run data through crossfilter * -* * -********************************************************/ -var ndx = crossfilter(yelp_data); - -/******************************************************** -* * -* Step3: Create Dimension that we'll need * -* * -********************************************************/ + /******************************************************** + * * + * Step1: Create the dc.js chart objects & ling to div * + * * + ********************************************************/ + var bubbleChart: DC.BubbleChart = dc.bubbleChart("#dc-bubble-graph"); + var pieChart: DC.PieChart = dc.pieChart("#dc-pie-graph"); + var volumeChart: DC.BarChart = dc.barChart("#dc-volume-chart"); + var lineChart: DC.LineChart = dc.lineChart("#dc-line-chart"); + var dataTable: DC.DataTableWidget = dc.dataTable("#dc-table-graph"); + var rowChart: DC.RowChart = dc.rowChart("#dc-row-graph"); - // for volumechart - var cityDimension = ndx.dimension(function (d) { return d.city; }); - var cityGroup = cityDimension.group(); - var cityDimensionGroup = cityDimension.group().reduce( - //add - function(p: IYelpDataExtended,v:IYelpData){ - ++p.count; - p.review_sum += v.review_count; - p.star_sum += v.stars; - p.review_avg = p.review_sum / p.count; - p.star_avg = p.star_sum / p.count; - return p; - }, - //remove - function(p: IYelpDataExtended,v:IYelpData){ - --p.count; - p.review_sum -= v.review_count; - p.star_sum -= v.stars; - p.review_avg = p.review_sum / p.count; - p.star_avg = p.star_sum / p.count; - return p; - }, - //init - function(){ - return {count:0, review_sum: 0, star_sum: 0, review_avg: 0, star_avg: 0}; - } - ); + /******************************************************** + * * + * Step2: Run data through crossfilter * + * * + ********************************************************/ + var ndx: CrossFilter.CrossFilter = crossfilter(yelp_data); - // for pieChart - var startValue = ndx.dimension(function (d) { - return d.stars*1.0; - }); - var startValueGroup = startValue.group(); + /******************************************************** + * * + * Step3: Create Dimension that we'll need * + * * + ********************************************************/ - // For datatable - var businessDimension = ndx.dimension(function (d) { return d.business_id; }); -/******************************************************** -* * -* Step4: Create the Visualisations * -* * -********************************************************/ - - bubbleChart.width(650) - .height(300) - .dimension(cityDimension) - .group(cityDimensionGroup) - .transitionDuration(1500) - .colors(["#a60000","#ff0000", "#ff4040","#ff7373","#67e667","#39e639","#00cc00"]) - .colorDomain([-12000, 12000]) - - .x(d3.scale.linear().domain([0, 5.5])) - .y(d3.scale.linear().domain([0, 5.5])) - .r(d3.scale.linear().domain([0, 2500])) - .keyAccessor(function (p) { - return p.value.star_avg; - }) - .valueAccessor(function (p) { - return p.value.review_avg; - }) - .radiusValueAccessor(function (p) { - return p.value.count; - }) - .transitionDuration(1500) - .elasticY(true) - .yAxisPadding(1) - .xAxisPadding(1) - .label(function (p) { - return p.key; - }) - .renderLabel(true) - .renderlet(function (chart) { - rowChart.filter(chart.filter()); - }) - .on("postRedraw", function (chart) { - dc.events.trigger(function () { - rowChart.filter(chart.filter()); - }); - }); - ; + // for volumechart + var cityDimension: CrossFilter.Dimension = ndx.dimension((d: IYelpData) => d.city); + var cityGroup: CrossFilter.Group = cityDimension.group(); + var cityDimensionGroup: CrossFilter.Group = cityDimension.group().reduce( + //add + (p: IYelpDataExtended, v:IYelpData) => { + ++p.count; + p.review_sum += v.review_count; + p.star_sum += v.stars; + p.review_avg = p.review_sum / p.count; + p.star_avg = p.star_sum / p.count; + return p; + }, + //remove + (p: IYelpDataExtended, v:IYelpData) => { + --p.count; + p.review_sum -= v.review_count; + p.star_sum -= v.stars; + p.review_avg = p.review_sum / p.count; + p.star_avg = p.star_sum / p.count; + return p; + }, + //init + () => { + return {count: 0, review_sum: 0, star_sum: 0, review_avg: 0, star_avg: 0}; + } + ); + // for pieChart + var startValue: CrossFilter.Dimension = ndx.dimension((d: IYelpData) => d.stars * 1.0); + var startValueGroup: CrossFilter.Group = startValue.group(); -pieChart.width(200) - .height(200) - .transitionDuration(1500) - .dimension(startValue) - .group(startValueGroup) - .radius(90) - .minAngleForLabel(0) - .label(function(d) { return d.data.key; }) - .on("filtered", function (chart) { - dc.events.trigger(function () { - if(chart.filter()) { - console.log(chart.filter()); - volumeChart.filter([chart.filter()-.25,chart.filter()-(-0.25)]); - } - else volumeChart.filterAll(); - }); - }); + // For datatable + var businessDimension: CrossFilter.Dimension = ndx.dimension((d: IYelpData) => d.business_id); + /******************************************************** + * * + * Step4: Create the Visualisations * + * * + ********************************************************/ -volumeChart.width(230) - .height(200) - .dimension(startValue) - .group(startValueGroup) - .transitionDuration(1500) - .centerBar(true) - .gap(17) - .x(d3.scale.linear().domain([0.5, 5.5])) - .elasticY(true) - .on("filtered", function (chart) { - dc.events.trigger(function () { - if(chart.filter()) { - console.log(chart.filter()); - lineChart.filter(chart.filter()); - } - else - {lineChart.filterAll()} - }); - }) - .xAxis().tickFormat(function(v) {return v;}); + bubbleChart + .width(650) + .height(300) + .dimension(cityDimension) + .group(cityDimensionGroup) + .transitionDuration(1500) + .colors(["#a60000","#ff0000", "#ff4040","#ff7373","#67e667","#39e639","#00cc00"]) + .colorDomain([-12000, 12000]) + .x(d3.scale.linear().domain([0, 5.5])) + .y(d3.scale.linear().domain([0, 5.5])) + .r(d3.scale.linear().domain([0, 2500])) + .keyAccessor((p: any) => p.value.star_avg) + .valueAccessor((p: any) => p.value.review_avg) + .radiusValueAccessor((p: any) => p.value.count) + .transitionDuration(1500) + .elasticY(true) + .yAxisPadding(1) + .xAxisPadding(1) + .label((p: any) => p.key) + .renderLabel(true) + .renderlet((chart: DC.BubbleChart) => rowChart.filter(chart.filter())) + .on("postRedraw", (chart: DC.BubbleChart) => dc.events.trigger(() => rowChart.filter(chart.filter()))); -console.log(startValueGroup.top(1)[0].value); + pieChart + .width(200) + .height(200) + .transitionDuration(1500) + .dimension(startValue) + .group(startValueGroup) + .radius(90) + .minAngleForLabel(0) + .label((d: any) => d.data.key) + .on("filtered", (chart: DC.PieChart) => + dc.events.trigger(() => { + if (chart.filter()) { + console.log(chart.filter()); + volumeChart.filter([chart.filter()-.25,chart.filter()-(-0.25)]); + } + else volumeChart.filterAll(); + })); -lineChart.width(230) - .height(200) - .dimension(startValue) - .group(startValueGroup) - .x(d3.scale.linear().domain([0.5, 5.5])) - .valueAccessor(function(d) { - return d.value; - }) - .renderHorizontalGridLines(true) - .elasticY(true) - .xAxis().tickFormat(function(v) {return v;}); ; + volumeChart + .width(230) + .height(200) + .dimension(startValue) + .group(startValueGroup) + .transitionDuration(1500) + .centerBar(true) + .gap(17) + .x(d3.scale.linear().domain([0.5, 5.5])) + .elasticY(true) + .on("filtered", (chart: DC.BarChart) => + dc.events.trigger(() => { + if(chart.filter()) { + console.log(chart.filter()); + lineChart.filter(chart.filter()); + } + else { + lineChart.filterAll() + } + })) + .xAxis() + .tickFormat((v: string) => v); -rowChart.width(340) - .height(850) - .dimension(cityDimension) - .group(cityGroup) - .renderLabel(true) - .colors(["#a60000","#ff0000", "#ff4040","#ff7373","#67e667","#39e639","#00cc00"]) - .colorDomain([0, 0]) - .renderlet(function (chart) { - bubbleChart.filter(chart.filter()); - }) - .on("filtered", function (chart) { - dc.events.trigger(function () { - bubbleChart.filter(chart.filter()); - }); - }); + console.log(startValueGroup.top(1)[0].value); + lineChart + .width(230) + .height(200) + .dimension(startValue) + .group(startValueGroup) + .x(d3.scale.linear().domain([0.5, 5.5])) + .valueAccessor((d: any) => d.value) + .renderHorizontalGridLines(true) + .elasticY(true) + .xAxis() + .tickFormat((v: string) => v); -dataTable.width(800).height(800) - .dimension(businessDimension) - .group(function(d:Object) { return "List of all Selected Businesses" - }) - .size(100) - .columns([ - function(d) { return d.name; }, - function(d) { return d.city; }, - function(d) { return d.stars; }, - function(d) { return d.review_count; }, - function(d) { return 'Map"} - ]) - .sortBy(function(d){ return d.stars; }) - // (optional) sort order, :default ascending - .order(d3.ascending); -/******************************************************** -* * -* Step6: Render the Charts * -* * -********************************************************/ - - dc.renderAll(); + rowChart + .width(340) + .height(850) + .dimension(cityDimension) + .group(cityGroup) + .renderLabel(true) + .colors(["#a60000","#ff0000", "#ff4040","#ff7373","#67e667","#39e639","#00cc00"]) + .colorDomain([0, 0]) + .renderlet((chart: DC.RowChart) => bubbleChart.filter(chart.filter())) + .on("filtered", (chart: DC.RowChart) => + dc.events.trigger(() => + bubbleChart.filter(chart.filter()))); + + dataTable + .width(800) + .height(800) + .dimension(businessDimension) + .group((d: any) => "List of all Selected Businesses") + .size(100) + .columns([ + (d: IYelpData) => d.name, + (d: IYelpData) => d.city, + (d: IYelpData) => d.stars, + (d: IYelpData) => d.review_count, + (d: IYelpData) => 'Map" + ]) + .sortBy((d: IYelpData) => d.stars) + // (optional) sort order, :default ascending + .order(d3.ascending); + /******************************************************** + * * + * Step6: Render the Charts * + * * + ********************************************************/ + + dc.renderAll(); }); diff --git a/dcjs/dc.d.ts b/dcjs/dc.d.ts new file mode 100644 index 000000000..5a83b5c7c --- /dev/null +++ b/dcjs/dc.d.ts @@ -0,0 +1,433 @@ +// Type definitions for DCJS +// Project: https://github.com/dc-js/dc.js +// Definitions by: hans windhoff , matt traynham +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +// this makes only sense together with d3 and crossfilter so you need the d3.d.ts and crossfilter.d.ts files + +/// +/// + +declare module DC { + // helper for get/set situation + export interface IGetSet { + (): T; + (t: T): V; + } + + export interface IBiGetSet { + (): T; + (t: T, r?: R): V; + } + + export interface Accessor { + (datum: T, index?: number): V; + } + + export interface UnitFunction { + (start: number, end: number, domain?: Array): number|Array; + } + + export interface FloatPointUnits { + precision(precision: number): UnitFunction; + } + + export interface Units { + integers: UnitFunction; + ordinal: UnitFunction; + fp: FloatPointUnits; + } + + export interface Events { + trigger(fn: () => void, delay?: number): void; + } + + export interface Errors { + Exception(msg: string): void; + InvalidStateException(msg: string): void; + } + + export interface Filter { + isFiltered(value: any): boolean; + } + + export interface Filters { + RangedFilter(low: any, high: any): Filter; + TwoDimensionalFilter(arr: Array): Filter; + RangedTwoDimensionalFilter(arr: Array): Filter; + } + + export interface Logger { + enableDebugLog: boolean; + warn(msg: string): void; + debug(msg: string): void; + deprecate(fn: Function, msg: string): void; + } + + export interface Printers { + filters(filters: Array): string; + filter(filter: any): string; + } + + export interface Round { + floor(n: number): number; + ceil(n: number): number; + round(n: number): number; + } + + export interface Utils { + printSingleValue(filter: any): string; + add(l: any, r: any): any; + subtract(l: any, r: any): any; + isNumber(n: any): boolean; + isFloat(n: any): boolean; + isInteger(n: any): boolean; + isNegligible(n: any): boolean; + clamp(n: number, min: number, max: number): number; + uniqueId(): number; + nameToId(name: string): string; + appendOrSelect(parent: D3.Selection, selector: string, tag: any): D3.Selection; + safeNumber(n: any): number; + } + + export interface Legend { + x: IGetSet; + y: IGetSet; + gap: IGetSet; + itemHeight: IGetSet; + horizontal: IGetSet; + legendWidth: IGetSet; + itemWidth: IGetSet; + autoItemWidth: IGetSet; + render: () => void; + } + + export interface BaseMixin { + width: IGetSet; + height: IGetSet; + minWidth: IGetSet; + minHeight: IGetSet; + dimension: IGetSet; + data: IGetSet<(group: any) => Array, T>; + group: IGetSet; + ordering: IGetSet, T>; + filterAll(): void; + select(selector: D3.Selection|string): D3.Selection; + selectAll(selector: D3.Selection|string): D3.Selection; + anchor(anchor: BaseMixin|D3.Selection|string, chartGroup?: string): D3.Selection; + anchorName(): string; + svg: IGetSet; + resetSvg(): void; + filterPrinter: IGetSet<(filters: Array) => string, T>; + turnOnControls(): void; + turnOffControls(): void; + transitionDuration: IGetSet; + render(): void; + redraw(): void; + redrawGroup(): void; + hasFilterHandler: IGetSet<(filters: Array, filter: any) => boolean, T>; + hasFilter(filter?: any): boolean; + removeFilterHandler: IGetSet<(filters: Array) => Array, T>; + addFilterHandler: IGetSet<(filters: Array) => Array, T>; + resetFilterHandler: IGetSet<(filters: Array) => Array, T>; + filter: IGetSet; + filters(): Array; + onClick(datum: any): void; + filterHandler: IGetSet<(dimension: any, filter: any) => any, T>; + keyAccessor: IGetSet, T>; + valueAccessor: IGetSet, T>; + label: IGetSet, T>; + renderLabel: IGetSet; + title: IGetSet, T>; + renderTitle: IGetSet; + chartGroup: IGetSet; + expireCache(): T; + legend: IGetSet; + options(optionsObject: any): T; + renderlet(fn: (chart: T) => any): T; + on(event: string, fn: (chart: T) => any): T; + } + + export interface Margins { + left: number; + top: number; + right: number; + bottom: number; + } + + export interface MarginMixin { + margins: IGetSet + } + + export interface ColorMixin { + colors: IGetSet|Array, T>; + ordinalColors(r: Array): void; + linearColors(r: Array): void; + colorAccessor: IGetSet, T>; + colorDomain: IGetSet, T>; + calculateColorDomain(): void; + getColor(datum: any, index?: number): string; + colorCalculator: IGetSet, T>; + } + + export interface CoordinateGridMixin extends BaseMixin, MarginMixin, BaseMixin { + rangeChart: IGetSet, T>; + zoomScale: IGetSet, T>; + zoomOutRestrict: IGetSet; + g: IGetSet; + mouseZoomable: IGetSet; + chartBodyG(): D3.Selection; + x: IGetSet, T>; + xUnits: IGetSet; + xAxis: IGetSet; + elasticX: IGetSet; + xAxisPadding: IGetSet; + xUnitCount(): number; + useRightYAxis: IGetSet; + isOrdinal(): boolean; + xAxisLabel: IBiGetSet; + yAxisLabel: IBiGetSet; + y: IGetSet, T>; + yAxis: IGetSet; + elasticY: IGetSet; + renderHorizontalGridLines: IGetSet; + renderVerticalGridLines: IGetSet; + xAxisMin(): any; + xAxisMax(): any; + yAxisMin(): any; + yAxisMax(): any; + yAxisPadding: IGetSet; + round: IGetSet<(value: any) => any, T>; + clipPadding: IGetSet; + focus(range?: Array): void; + brushOn: IGetSet; + } + + export interface StackMixin { + stack(group: any, name?: string, accessor?: Accessor): void; + hidableStacks: IGetSet; + hideStack(name: string): void; + showStack(name: string): void; + // title(stackName: string, titleFn: Accessor); + stackLayout: IGetSet; + } + + export interface CapMixin { + cap: IGetSet; + othersLabel: IGetSet; + othersGrouper: IGetSet<(data: Array) => Array, T>; + } + + export interface BubbleMixin extends ColorMixin { + r: IGetSet, T>; + radiusValueAccessor: IGetSet, T>; + minRadiusWithLabel: IGetSet; + maxBubbleRelativeSize: IGetSet; + } + + export interface PieChart extends CapMixin, ColorMixin, BaseMixin { + slicesCap: IGetSet; + innerRadius: IGetSet; + radius: IGetSet; + cx: IGetSet; + cy: IGetSet; + minAngleForLabel: IGetSet; + } + + export interface BarChart extends StackMixin, CoordinateGridMixin { + centerBar: IGetSet; + barPadding: IGetSet; + outerPadding: IGetSet; + gap: IGetSet; + alwaysUseRounding: IGetSet; + } + + export interface RenderDataPointOptions { + fillOpacity: number; + strokeOpacity: number; + radius: number; + } + + export interface LineChart extends StackMixin, CoordinateGridMixin { + interpolate: IGetSet; + tension: IGetSet; + defined: IGetSet, LineChart>; + dashStyle: IGetSet, LineChart>; + renderArea: IGetSet; + dotRadius: IGetSet; + renderDataPoints: IGetSet; + } + + export interface DataCountWidgetHTML { + all: string; + some: string; + } + + export interface DataCountWidget extends BaseMixin { + html: IGetSet; + formatNumber: IGetSet, DataCountWidget>; + } + + export interface DataTableWidget extends BaseMixin { + size: IGetSet; + columns: IGetSet|string|Array|string>>, DataTableWidget>; + sortBy: IGetSet, DataTableWidget>; + order: IGetSet<(a: any, b: any) => number, DataTableWidget>; + } + + export interface DataGridWidget extends BaseMixin { + size: IGetSet; + html: IGetSet, DataTableWidget>; + htmlGroup: IGetSet, DataTableWidget>; + sortBy: IGetSet, DataTableWidget>; + order: IGetSet<(a: any, b: any) => number, DataTableWidget>; + } + + export interface BubbleChart extends BubbleMixin, CoordinateGridMixin { + elasticRadius: IGetSet; + } + + export interface CompositeChart extends CoordinateGridMixin { + useRightAxisGridLines: IGetSet; + childOptions: IGetSet; + rightYAxisLabel: IGetSet; + compose: IGetSet>, CompositeChart>; + children(): Array>; + shareColors: IGetSet; + shareTitle: IGetSet; + rightY: IGetSet, CompositeChart>; + rightYAxis: IGetSet; + } + + export interface SeriesChart extends CompositeChart { + chart: IGetSet<(c: any) => BaseMixin, SeriesChart>; + seriesAccessor: IGetSet, SeriesChart>; + seriesSort: IGetSet<(a: any, b: any) => number, SeriesChart>; + valueSort: IGetSet<(a: any, b: any) => number, SeriesChart>; + } + + export interface GeoChoroplethLayer { + name: string; + keyAccessor: Accessor; + data: any; + } + + export interface GeoChoroplethChart extends ColorMixin, BaseMixin { + overlayGeoJson(json: any, name: string, keyAccessor: Accessor): void; + projection: IGetSet; + geoJsons(): Array; + geoPath(): D3.Geo.Path; + removeGeoJson(name: string): void; + } + + export interface BubbleOverlayChart extends BubbleMixin, BaseMixin { + point(name: string, x: number, y: number): void; + } + + export interface RowChart extends CapMixin, MarginMixin, ColorMixin, BaseMixin { + x: IGetSet, RowChart>; + renderTitleLabel: IGetSet; + xAxis: IGetSet; + fixedBarHeight: IGetSet; + gap: IGetSet; + elasticX: IGetSet; + labelOffsetX: IGetSet; + labelOffsetY: IGetSet; + titleLabelOffsetX: IGetSet; + } + + export interface ScatterPlot extends CoordinateGridMixin { + existenceAccessor: IGetSet, ScatterPlot>; + symbol: IGetSet; + symbolSize: IGetSet; + highlightedSize: IGetSet; + hiddenSize: IGetSet; + } + + export interface NumberDisplayWidgetHTML { + one: string; + some: string; + none: string; + } + + export interface NumberDisplayWidget extends BaseMixin { + html: IGetSet; + value(): string; + formatNumber: IGetSet, NumberDisplayWidget>; + } + + export interface HeatMap extends ColorMixin, MarginMixin, BaseMixin { + colsLabel: IGetSet, HeatMap>; + rowsLabel: IGetSet, HeatMap>; + rows: IGetSet, HeatMap>; + cols: IGetSet, HeatMap>; + boxOnClick: IGetSet<(d: any) => void, HeatMap>; + xAxisOnClick: IGetSet<(d: any) => void, HeatMap>; + yAxisOnClick: IGetSet<(d: any) => void, HeatMap>; + } + + export interface BoxPlot extends CoordinateGridMixin { + boxPadding: IGetSet; + outerPadding: IGetSet; + boxWidth: IGetSet; + tickFormat: IGetSet, BoxPlot>; + } + + export interface ChartRegistry { + has(chart: BaseMixin): boolean; + register(chart: BaseMixin, group?: string): void; + deregister(chart: BaseMixin, group?: string): void; + clear(group?: string): void; + list(group?: string): Array>; + } + + export interface Base { + chartRegistry: ChartRegistry; + registerChart(chart: BaseMixin, group?: string): void; + deregisterChart(chart: BaseMixin, group?: string): void; + hasChart(chart: BaseMixin): boolean; + deregisterAllCharts(group?: string): void; + filterAll(group?: string): void; + refocusAll(group?: string): void; + renderAll(group?: string): void; + redrawAll(group?: string): void; + disableTransitions: boolean; + transition(selections: D3.Selection, duration: number, callback: (s: D3.Selection) => void): void; + + units: Units; + events: Events; + errors: Errors; + instanceOfChart(object: any): boolean; + logger: Logger; + override(object: any, fnName: string, newFn: Function): void; + printers: Printers; + pluck(n: string, f?: Accessor): Accessor; + round: Round; + utils: Utils; + + legend(): Legend; + + pieChart(parent: string, chartGroup?: string): PieChart; + barChart(parent: string, chartGroup?: string): BarChart; + lineChart(parent: string, chartGroup?: string): LineChart; + dataCount(parent: string, chartGroup?: string): DataCountWidget; + dataTable(parent: string, chartGroup?: string): DataTableWidget; + dataGrid(parent: string, chartGroup?: string): DataGridWidget; + bubbleChart(parent: string, chartGroup?: string): BubbleChart; + compositeChart(parent: string, chartGroup?: string): CompositeChart; + seriesChart(parent: string, chartGroup?: string): SeriesChart; + geoChoroplethChart(parent: string, chartGroup?: string): GeoChoroplethChart; + bubbleOverlayChart(parent: string, chartGroup?: string): BubbleOverlayChart; + rowChart(parent: string, chartGroup?: string): RowChart; + scatterPlot(parent: string, chartGroup?: string): ScatterPlot; + numberDisplay(parent: string, chartGroup?: string): NumberDisplayWidget; + heatMap(parent: string, chartGroup?: string): HeatMap; + boxPlot(parent: string, chartGroup?: string): BoxPlot; + } +} + +declare var dc: DC.Base; + +declare module 'dc' { + export = dc; +} From 516266a0ac7cc5f8b4e64ae9998121ff9306aad5 Mon Sep 17 00:00:00 2001 From: Matt Traynham Date: Mon, 23 Feb 2015 14:15:12 -0500 Subject: [PATCH 072/185] Updates to d3 --- d3/d3.d.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/d3/d3.d.ts b/d3/d3.d.ts index 03450a002..4935110e1 100644 --- a/d3/d3.d.ts +++ b/d3/d3.d.ts @@ -702,8 +702,9 @@ declare module D3 { * Parse a delimited string into objects using the header row. * * @param string delimited formatted string to parse + * @param accessor to modify properties of each row */ - parse(string: string): any[]; + parse(string: string, accessor?: (row: any) => any): any[]; /** * Parse a delimited string into tuples, ignoring the header row. * @@ -849,7 +850,7 @@ declare module D3 { sortKeys(comparator: (d1: any, d2: any) => number): Nest; sortValues(comparator: (d1: any, d2: any) => number): Nest; rollup(rollupFunction: (data: any, index: number) => any): Nest; - map(values: any[]): any; + map(values: any[], mapType?: any): any; entries(values: any[]): NestKeyValue[]; } From 6091089428735d01955d6fa74e45091535e07e48 Mon Sep 17 00:00:00 2001 From: Cain Cresswell-Miley Date: Tue, 24 Feb 2015 09:12:23 +1300 Subject: [PATCH 073/185] node-uuid: add parse and unparse methods, and tests --- node-uuid/{node-uuid.tests.ts => node-uuid-tests.ts} | 5 +++++ node-uuid/node-uuid.d.ts | 6 ++++++ 2 files changed, 11 insertions(+) rename node-uuid/{node-uuid.tests.ts => node-uuid-tests.ts} (85%) diff --git a/node-uuid/node-uuid.tests.ts b/node-uuid/node-uuid-tests.ts similarity index 85% rename from node-uuid/node-uuid.tests.ts rename to node-uuid/node-uuid-tests.ts index 49c8f165a..9ad3c1cfc 100644 --- a/node-uuid/node-uuid.tests.ts +++ b/node-uuid/node-uuid-tests.ts @@ -18,6 +18,11 @@ var padding: number[] = [0, 1, 2] var offset: number = 15 +var buf : number[] = [] + +uuid.parse(uid4, buf, offset) +uuid.unparse(buf, offset) + uuid.v1(options, padding, offset) uuid.v2(options, padding, offset) uuid.v3(options, padding, offset) diff --git a/node-uuid/node-uuid.d.ts b/node-uuid/node-uuid.d.ts index d4857cf31..d1e1e8c2e 100644 --- a/node-uuid/node-uuid.d.ts +++ b/node-uuid/node-uuid.d.ts @@ -44,6 +44,12 @@ interface UUID { v4(options?: UUIDOptions, buffer?: number[], offset?: number): string v4(options?: UUIDOptions, buffer?: Buffer, offset?: number): string + + parse(id: string, buffer?: number[], offset?: number): number[] + parse(id: string, buffer?: Buffer, offset?: number): Buffer + + unparse(buffer: number[], offset?: number): string + unparse(buffer: Buffer, offset?: number): string } declare module "node-uuid" { From 6b4139a0182e83dd8aa8b2528be0e612df8401ea Mon Sep 17 00:00:00 2001 From: Wim Looman Date: Tue, 24 Feb 2015 11:23:28 +1300 Subject: [PATCH 074/185] Add definitions for mess --- mess/mess-tests.ts | 7 +++++++ mess/mess.d.ts | 9 +++++++++ 2 files changed, 16 insertions(+) create mode 100644 mess/mess-tests.ts create mode 100644 mess/mess.d.ts diff --git a/mess/mess-tests.ts b/mess/mess-tests.ts new file mode 100644 index 000000000..240f435ae --- /dev/null +++ b/mess/mess-tests.ts @@ -0,0 +1,7 @@ +/// + +import mess = require('mess'); + +var numbers: number[] = [1, 2, 3]; +mess(numbers); +numbers = mess([2, 4, 6]); diff --git a/mess/mess.d.ts b/mess/mess.d.ts new file mode 100644 index 000000000..94f381a94 --- /dev/null +++ b/mess/mess.d.ts @@ -0,0 +1,9 @@ +// Type definitions for mess 0.1.2 +// Project: https://github.com/bobrik/node-mess +// Definitions by: Wim Looman +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module "mess" { + function shuffle(array: T[]): T[]; + export = shuffle; +} From 070980d5f2441eb34622204d1d20bec92b9817c3 Mon Sep 17 00:00:00 2001 From: Yuki KAN Date: Tue, 24 Feb 2015 08:26:47 +0900 Subject: [PATCH 075/185] Fix socket.io.d.ts for wrong type in Namespace.connected --- socket.io/socket.io.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/socket.io/socket.io.d.ts b/socket.io/socket.io.d.ts index 00d2f2688..bccff1c77 100644 --- a/socket.io/socket.io.d.ts +++ b/socket.io/socket.io.d.ts @@ -44,7 +44,7 @@ declare module SocketIO { interface Namespace extends NodeJS.EventEmitter { name: string; - connected: { [id: number]: Socket }; + connected: { [id: string]: Socket }; use(fn: Function): Namespace on(event: 'connection', listener: (socket: Socket) => void): any; From 4ec69330e8738de5746c6e20dfa8bed07b478eaa Mon Sep 17 00:00:00 2001 From: Yuki KAN Date: Tue, 24 Feb 2015 08:56:43 +0900 Subject: [PATCH 076/185] Fix socket.io.d.ts: argument of Socket.disconnect --- socket.io/socket.io.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/socket.io/socket.io.d.ts b/socket.io/socket.io.d.ts index bccff1c77..2571e239b 100644 --- a/socket.io/socket.io.d.ts +++ b/socket.io/socket.io.d.ts @@ -68,7 +68,7 @@ declare module SocketIO { broadcast: Socket; volatile: Socket; connected: boolean; - disconnect(close: boolean): Socket; + disconnect(close?: boolean): Socket; } interface Client { From 809181986264a273285972ec0a77219ac79d6d43 Mon Sep 17 00:00:00 2001 From: cabralRodrigo Date: Tue, 24 Feb 2015 02:15:44 -0300 Subject: [PATCH 077/185] Added definitions for is.js Ref.: https://github.com/borisyankov/DefinitelyTyped/issues/3713 --- is-js/is-js-tests.ts | 655 +++++++++++++++++++++ is-js/is-js.d.ts | 1323 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 1978 insertions(+) create mode 100644 is-js/is-js-tests.ts create mode 100644 is-js/is-js.d.ts diff --git a/is-js/is-js-tests.ts b/is-js/is-js-tests.ts new file mode 100644 index 000000000..44940bee1 --- /dev/null +++ b/is-js/is-js-tests.ts @@ -0,0 +1,655 @@ +/// + +//#region Type checks + +var getArguments = function () { + return arguments; +}; +var arguments = getArguments(); +is.arguments(arguments); +is.not.arguments({ foo: 'bar' }); +is.all.arguments(arguments, 'bar'); +is.any.arguments(['foo'], arguments); +is.all.arguments([arguments, 'foo', 'bar']); + +is.array(['foo', 'bar', 'baz']); +is.not.array({ foo: 'bar' }); +is.all.array(['foo'], 'bar'); +is.any.array(['foo'], 'bar'); +is.all.array([[1, 2], 'foo', 'bar']); + +is.boolean(true); +is.not.boolean({ foo: 'bar' }); +is.all.boolean(true, 'bar'); +is.any.boolean(true, 'bar'); +is.all.boolean([true, 'foo', 'bar']); + +is.date(new Date()); +is.not.date({ foo: 'bar' }); +is.all.date(new Date(), 'bar'); +is.any.date(new Date(), 'bar'); +is.all.date([new Date(), 'foo', 'bar']); + +is.error(new Error()); +is.not.error({ foo: 'bar' }); +is.all.error(new Error(), 'bar'); +is.any.error(new Error(), 'bar'); +is.all.error([new Error(), 'foo', 'bar']); + +is.function(toString); +is.not.function({ foo: 'bar' }); +is.all.function(toString, 'bar'); +is.any.function(toString, 'bar'); +is.all.function([toString, 'foo', 'bar']); + +is.nan(NaN); +is.not.nan(42); +is.all.nan(NaN, 1); +is.any.nan(NaN, 2); +is.all.nan([NaN, 'foo', 1]); + +is.null(null); +is.not.null(42); +is.all.null(null, 1); +is.any.null(null, 2); +is.all.null([null, 'foo', 1]); + +is.number(42); +is.not.number('42'); +is.all.number('foo', 1); +is.any.number({}, 2); +is.all.number([42, 'foo', 1]); + +is.object({ foo: 'bar' }); +is.object(toString); +is.not.object('foo'); +is.all.object({}, 1); +is.any.object({}, 2); +is.all.object([{}, new Object()]); + +is.json({ foo: 'bar' }); +is.json(toString); +is.not.json([]); +is.all.json({}, 1); +is.any.json({}, 2); +is.all.json([{}, { foo: 'bar' }]); + +is.regexp(/test/); +is.not.regexp(['foo']); +is.all.regexp(/test/, 1); +is.any.regexp(new RegExp('ab+c'), 2); +is.all.regexp([{}, /test/]); + +is.string('foo'); +is.not.string(['foo']); +is.all.string('foo', 1); +is.any.string('foo', 2); +is.all.string([{}, 'foo']); + +is.char('f'); +is.not.char(['foo']); +is.all.char('f', 1); +is.any.char('f', 2); +is.all.char(['f', 'o', 'o']); + +is.undefined(undefined); +is.not.undefined(null); +is.all.undefined(undefined, 1); +is.any.undefined(undefined, 2); +is.all.undefined([{}, undefined]); + +is.sameType(42, 7); +is.sameType(42, '7'); +is.not.sameType(42, 7); + +//#endregion + +//#region Presence checks + +is.empty({}); +is.empty([]); +is.empty(''); +is.not.empty(['foo']); +is.all.empty('', {}, ['foo']); +is.any.empty([], 42); +is.all.empty([{}, 'foo']); + +is.existy({}); +is.existy(null); +is.not.existy(undefined); +is.all.existy(null, ['foo']); +is.any.existy(undefined, 42); +is.all.existy([{}, 'foo']); + +is.truthy(true); +is.truthy(null); +is.not.truthy(false); +is.all.truthy(null, true); +is.any.truthy(undefined, true); +is.all.truthy([{}, true]); + +is.falsy(false); +is.falsy(null); +is.not.falsy(true); +is.all.falsy(null, false); +is.any.falsy(undefined, true); +is.all.falsy([false, true, undefined]); + +is.space(' '); +is.space('foo'); +is.not.space(true); +is.all.space(' ', 'foo'); +is.any.space(' ', true); +is.all.space([' ', 'foo', undefined]); + +//#endregion + +//#region RegExp checks + +is.url('http://www.test.com'); +is.url('foo'); +is.not.url(true); +is.all.url('http://www.test.com', 'foo'); +is.any.url('http://www.test.com', true); +is.all.url(['http://www.test.com', 'foo', undefined]); + +is.email('test@test.com'); +is.email('foo'); +is.not.email('foo'); +is.all.email('test@test.com', 'foo'); +is.any.email('test@test.com', 'foo'); +is.all.email(['test@test.com', 'foo', undefined]); + +is.creditCard(378282246310005); +is.creditCard(123); +is.not.creditCard(123); +is.all.creditCard(378282246310005, 123); +is.any.creditCard(378282246310005, 123); +is.all.creditCard([378282246310005, 123, undefined]); + +is.alphaNumeric('alphaNu3er1k'); +is.alphaNumeric('*?'); +is.not.alphaNumeric('*?'); +is.all.alphaNumeric('alphaNu3er1k', '*?'); +is.any.alphaNumeric('alphaNu3er1k', '*?'); +is.all.alphaNumeric(['alphaNu3er1k', '*?']); + +is.timeString('13:45:30'); +is.timeString('90:90:90'); +is.not.timeString('90:90:90'); +is.all.timeString('13:45:30', '90:90:90'); +is.any.timeString('13:45:30', '90:90:90'); +is.all.timeString(['13:45:30', '90:90:90']); + +is.dateString('11/11/2011'); +is.dateString('90/11/2011'); +is.not.dateString('90/11/2011'); +is.all.dateString('11/11/2011', '90/11/2011'); +is.any.dateString('11/11/2011', '90/11/2011'); +is.all.dateString(['11/11/2011', '90/11/2011']); + +is.usZipCode('02201-1020'); +is.usZipCode('123'); +is.not.usZipCode('123'); +is.all.usZipCode('02201-1020', '123'); +is.any.usZipCode('02201-1020', '123'); +is.all.usZipCode(['02201-1020', '123']); + +is.caPostalCode('L8V3Y1'); +is.caPostalCode('L8V 3Y1'); +is.caPostalCode('123'); +is.not.caPostalCode('123'); +is.all.caPostalCode('L8V3Y1', '123'); +is.any.caPostalCode('L8V3Y1', '123'); +is.all.caPostalCode(['L8V3Y1', '123']); + +is.ukPostCode('B184BJ'); +is.ukPostCode('123'); +is.not.ukPostCode('123'); +is.all.ukPostCode('B184BJ', '123'); +is.any.ukPostCode('B184BJ', '123'); +is.all.ukPostCode(['B184BJ', '123']); + +is.nanpPhone('609-555-0175'); +is.nanpPhone('123'); +is.not.nanpPhone('123'); +is.all.nanpPhone('609-555-0175', '123'); +is.any.nanpPhone('609-555-0175', '123'); +is.all.nanpPhone(['609-555-0175', '123']); + +is.eppPhone('+90.2322456789'); +is.eppPhone('123'); +is.not.eppPhone('123'); +is.all.eppPhone('+90.2322456789', '123'); +is.any.eppPhone('+90.2322456789', '123'); +is.all.eppPhone(['+90.2322456789', '123']); + +is.socialSecurityNumber('017-90-7890'); +is.socialSecurityNumber('123'); +is.not.socialSecurityNumber('123'); +is.all.socialSecurityNumber('017-90-7890', '123'); +is.any.socialSecurityNumber('017-90-7890', '123'); +is.all.socialSecurityNumber(['017-90-7890', '123']); + +is.affirmative('yes'); +is.affirmative('no'); +is.not.affirmative('no'); +is.all.affirmative('yes', 'no'); +is.any.affirmative('yes', 'no'); +is.all.affirmative(['yes', 'y', 'true', 't', 'ok', 'okay']); + +is.hexadecimal('f0f0f0'); +is.hexadecimal(2.5); +is.not.hexadecimal('string'); +is.all.hexadecimal('ff', 'f50'); +is.any.hexadecimal('ff5500', true); +is.all.hexadecimal(['fff', '333', 'f50']); + +is.hexColor('#333'); +is.hexColor('#3333'); +is.not.hexColor(0.5); +is.all.hexColor('fff', 'f50'); +is.any.hexColor('ff5500', 0.5); +is.all.hexColor(['fff', '333', 'f50']); + +is.ip('198.156.23.5'); +is.ip('1.2..5'); +is.not.ip('8:::::::7'); +is.all.ip('0:1::4:ff5:54:987:C', '123.123.123.123'); +is.any.ip('123.8.4.3', '0.0.0.0'); +is.all.ip(['123.123.23.12', 'A:B:C:D:E:F:0:0']); + +is.ipv4('198.12.3.142'); +is.ipv4('1.2..5'); +is.not.ipv4('8:::::::7'); +is.all.ipv4('198.12.3.142', '123.123.123.123'); +is.any.ipv4('255.255.255.255', '850..1.4'); +is.all.ipv4(['198.12.3.142', '1.2.3']); + +is.ipv6('2001:DB8:0:0:1::1'); +is.ipv6('985.12.3.4'); +is.not.ipv6('8:::::::7'); +is.all.ipv6('2001:DB8:0:0:1::1', '1:50:198:2::1:2:8'); +is.any.ipv6('255.255.255.255', '2001:DB8:0:0:1::1'); +is.all.ipv6(['2001:DB8:0:0:1::1', '1.2.3']); + +//#endregion + +//#region String checks + +is.include('Some text goes here', 'text'); +is.include('test', 'text'); +is.not.include('test', 'text'); + +is.upperCase('YEAP'); +is.upperCase('nope'); +is.not.upperCase('Nope'); +is.all.upperCase('YEAP', 'nope'); +is.any.upperCase('YEAP', 'nope'); +is.all.upperCase(['YEAP', 'ALL UPPERCASE']); + +is.lowerCase('yeap'); +is.lowerCase('NOPE'); +is.not.lowerCase('Nope'); +is.all.lowerCase('yeap', 'NOPE'); +is.any.lowerCase('yeap', 'NOPE'); +is.all.lowerCase(['yeap', 'all lowercase']); + +is.startWith('yeap', 'ye'); +is.startWith('nope', 'ye'); +is.not.startWith('nope not that', 'not'); + +is.endWith('yeap', 'ap'); +is.endWith('nope', 'no'); +is.not.endWith('nope not that', 'not'); +is.endWith('yeap that one', 'one'); + +is.capitalized('Yeap'); +is.capitalized('nope'); +is.not.capitalized('nope not capitalized'); +is.not.capitalized('nope Capitalized'); +is.all.capitalized('Yeap', 'All', 'Capitalized'); +is.any.capitalized('Yeap', 'some', 'Capitalized'); +is.all.capitalized(['Nope', 'not']); + +is.palindrome('testset'); +is.palindrome('nope'); +is.not.palindrome('nope not palindrome'); +is.not.palindrome('tt'); +is.all.palindrome('testset', 'tt'); +is.any.palindrome('Yeap', 'some', 'testset'); +is.all.palindrome(['Nope', 'testset']); + +//#endregion + +//#region Arithmetic checks + +is.equal(42, 40 + 2); +is.equal('yeap', 'yeap'); +is.equal(true, true); +is.not.equal('yeap', 'nope'); + +is.even(42); +is.not.even(41); +is.all.even(40, 42, 44); +is.any.even(39, 42, 43); +is.all.even([40, 42, 43]); + +is.odd(41); +is.not.odd(42); +is.all.odd(39, 41, 43); +is.any.odd(39, 42, 44); +is.all.odd([40, 42, 43]); + +is.positive(41); +is.not.positive(-42); +is.all.positive(39, 41, 43); +is.any.positive(-39, 42, -44); +is.all.positive([40, 42, -43]); + +is.negative(-41); +is.not.negative(42); +is.all.negative(-39, -41, -43); +is.any.negative(-39, 42, 44); +is.all.negative([40, 42, -43]); + +is.above(41, 30); +is.not.above(42, 50); + +is.under(30, 35); +is.not.under(42, 30); + +is.within(30, 20, 40); +is.not.within(40, 30, 35); + +is.decimal(41.5); +is.not.decimal(42); +is.all.decimal(39.5, 41.5, -43.5); +is.any.decimal(-39, 42.5, 44); +is.all.decimal([40, 42.5, -43]); + +is.integer(41); +is.not.integer(42.5); +is.all.integer(39, 41, -43); +is.any.integer(-39, 42.5, 44); +is.all.integer([40, 42.5, -43]); + +is.finite(41); +is.not.finite(42 / 0); +is.all.finite(39, 41, -43); +is.any.finite(-39, Infinity, 44); +is.all.finite([Infinity, -Infinity, 42.5]); + +is.infinite(Infinity); +is.not.infinite(42); +is.all.infinite(Infinity, -Infinity, -43 / 0); +is.any.infinite(-39, Infinity, 44); +is.all.infinite([Infinity, -Infinity, 42.5]); + +//#endregion + +//#region Object checks + +is.propertyCount({ this: 'is', 'sample': {} }, 2); +is.propertyCount({ this: 'is', 'sample': {} }, 3); +is.not.propertyCount({}, 2); + +is.propertyDefined({ yeap: 'yeap' }, 'yeap'); +is.propertyDefined({ yeap: 'yeap' }, 'nope'); +is.not.propertyDefined({}, 'nope'); + +is.windowObject(window); +is.windowObject({ nope: 'nope' }); +is.not.windowObject({}); + +is.all.windowObject(window, { nope: 'nope' }); +is.any.windowObject(window, { nope: 'nope' }); +is.all.windowObject([window, { nope: 'nope' }]); + +var obj = document.createElement('div'); +is.domNode(obj); +is.domNode({ nope: 'nope' }); +is.not.domNode({}); +is.all.domNode(obj, obj); +is.any.domNode(obj, { nope: 'nope' }); +is.all.domNode([obj, { nope: 'nope' }]); + +//#endregion + +//#region Array checks + +is.inArray(2, [1, 2, 3]); +is.inArray(4, [1, 2, 3]); +is.not.inArray(4, [1, 2, 3]); + +is.sorted([1, 2, 3]); +is.sorted([1, 2, 4, 3]); +is.not.sorted([5, 4, 3]); +is.all.sorted([1, 2], [3, 4]); +is.any.sorted([1, 2], [5, 4]); +is.all.sorted([[1, 2], [5, 4]]); + +//#endregion + +//#region Environment checks + +is.ie(); +is.ie(6); +is.not.ie(); + +is.chrome(); +is.not.chrome(); + +is.firefox(); +is.not.firefox(); + +is.opera(); +is.not.opera(); + +is.safari(); +is.not.safari(); + +is.ios(); +is.not.ios(); + +is.iphone(); +is.not.iphone(); + +is.ipad(); +is.not.ipad(); + +is.ipod(); +is.not.ipod(); + +is.android(); +is.not.android(); + +is.androidPhone(); +is.not.androidPhone(); + +is.androidTablet(); +is.not.androidTablet(); + +is.blackberry(); + +is.not.blackberry(); + +is.windowsPhone(); +is.not.windowsPhone(); + +is.windowsTablet(); +is.not.windowsTablet(); + +is.windows(); +is.not.windows(); + +is.mac(); +is.not.mac(); + +is.linux(); +is.not.linux(); + +is.desktop(); +is.not.desktop(); + +is.mobile(); +is.not.mobile(); + +is.tablet(); +is.not.tablet(); + +is.online(); +is.not.online(); + +is.offline(); +is.not.offline(); + +//#endregion + +//#region Time checks + +var today = new Date(); +var yesterday = new Date(new Date().setDate(new Date().getDate() - 1)); +var tomorrow = new Date(new Date().setDate(new Date().getDate() + 1)); +var monday = new Date('01/26/2015'); +var sunday = new Date('01/25/2015'); +var saturday = new Date('01/24/2015'); + +is.today(today); +is.today(yesterday) +is.not.today(yesterday); +is.all.today(today, today); +is.any.today(today, yesterday); +is.all.today([today, yesterday]); + +is.yesterday(today); +is.yesterday(yesterday); +is.not.yesterday(today); +is.all.yesterday(yesterday, today); +is.any.yesterday(today, yesterday); +is.all.yesterday([today, yesterday]); + +is.tomorrow(today); +is.tomorrow(tomorrow); +is.not.tomorrow(today); +is.all.tomorrow(tomorrow, today); +is.any.tomorrow(today, tomorrow); +is.all.tomorrow([today, tomorrow]); + +is.past(yesterday); +is.past(tomorrow); +is.not.past(tomorrow); +is.all.past(tomorrow, yesterday); +is.any.past(yesterday, tomorrow); +is.all.past([yesterday, tomorrow]); + +is.future(yesterday); +is.future(tomorrow); +is.not.future(yesterday); +is.all.future(tomorrow, yesterday); +is.any.future(yesterday, tomorrow); +is.all.future([yesterday, tomorrow]); + +var mondayObj = new Date('01/26/2015'); +var tuesdayObj = new Date('01/27/2015'); +is.day(mondayObj, 'monday'); +is.day(mondayObj, 'tuesday'); +is.not.day(mondayObj, 'tuesday'); + +var januaryObj = new Date('01/26/2015'); +var februaryObj = new Date('02/26/2015'); +is.month(januaryObj, 'january'); +is.month(februaryObj, 'january'); +is.not.month(februaryObj, 'january'); + +var year2015 = new Date('01/26/2015'); +var year2016 = new Date('01/26/2016'); +is.year(year2015, 2015); +is.year(year2016, 2015); +is.not.year(year2016, 2015); + +is.leapYear(2016); +is.leapYear(2015); +is.not.leapYear(2015); +is.all.leapYear(2015, 2016); +is.any.leapYear(2015, 2016); +is.all.leapYear([2016, 2080]); + +is.weekend(sunday); +is.weekend(monday); +is.not.weekend(monday); +is.all.weekend(sunday, saturday); +is.any.weekend(sunday, saturday, monday); +is.all.weekend([sunday, saturday, monday]); + +is.weekday(monday); +is.weekday(sunday); +is.not.weekday(sunday); +is.all.weekday(monday, saturday); +is.any.weekday(sunday, saturday, monday); +is.all.weekday([sunday, saturday, monday]); + +is.inDateRange(sunday, saturday, monday); +is.inDateRange(saturday, sunday, monday); +is.not.inDateRange(saturday, sunday, monday); + +var twoDaysAgo = new Date(new Date().setDate(new Date().getDate() - 2)); +var nineDaysAgo = new Date(new Date().setDate(new Date().getDate() - 9)); +is.inLastWeek(twoDaysAgo); +is.inLastWeek(nineDaysAgo); +is.not.inLastWeek(nineDaysAgo); + +var tenDaysAgo = new Date(new Date().setDate(new Date().getDate() - 10)); +var fortyDaysAgo = new Date(new Date().setDate(new Date().getDate() - 40)); +is.inLastMonth(tenDaysAgo); +is.inLastMonth(fortyDaysAgo); +is.not.inLastMonth(fortyDaysAgo); + +var twoMonthsAgo = new Date(new Date().setMonth(new Date().getMonth() - 2)); +var thirteenMonthsAgo = new Date(new Date().setMonth(new Date().getMonth() - 13)); +is.inLastYear(twoMonthsAgo); +is.inLastYear(thirteenMonthsAgo); +is.not.inLastYear(thirteenMonthsAgo); + +var twoDaysLater = new Date(new Date().setDate(new Date().getDate() + 2)); +var nineDaysLater = new Date(new Date().setDate(new Date().getDate() + 9)); +is.inNextWeek(twoDaysLater); +is.inNextWeek(nineDaysLater); +is.not.inNextWeek(nineDaysLater); + +var tenDaysLater = new Date(new Date().setDate(new Date().getDate() + 10)); +var fortyDaysLater = new Date(new Date().setDate(new Date().getDate() + 40)); +is.inNextMonth(tenDaysLater); +is.inNextMonth(fortyDaysLater); +is.not.inNextMonth(fortyDaysLater); + +var twoMonthsLater = new Date(new Date().setMonth(new Date().getMonth() + 2)); +var thirteenMonthsLater = new Date(new Date().setMonth(new Date().getMonth() + 13)); +is.inNextYear(twoMonthsLater); +is.inNextYear(thirteenMonthsLater); +is.not.inNextYear(thirteenMonthsLater); + +var firstQuarter = new Date('01/26/2015'); +var secondQuarter = new Date('05/26/2015'); +is.quarterOfYear(firstQuarter, 1); +is.quarterOfYear(secondQuarter, 1); +is.not.quarterOfYear(secondQuarter, 1); + +var january1 = new Date('01/01/2015'); +var june1 = new Date('06/01/2015'); +is.dayLightSavingTime(june1); +is.dayLightSavingTime(january1); +is.not.dayLightSavingTime(january1); + +//#endregion + +//#region Configuration methods + +is.url('https://www.duckduckgo.com'); +is.setRegexp(/quack/, 'url'); +is.url('quack'); + +var customName = is.setNamespace(); +customName.odd(3); + +//#endregion \ No newline at end of file diff --git a/is-js/is-js.d.ts b/is-js/is-js.d.ts new file mode 100644 index 000000000..aff47a7c5 --- /dev/null +++ b/is-js/is-js.d.ts @@ -0,0 +1,1323 @@ +// Type definitions for is.js +// Project: http://arasatasaygin.github.io/is.js/ +// Definitions by: Rodrigo Cabral +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +interface IsStatic { + + //#region Type checks + + /** + * Checks if the given value type is arguments. + */ + arguments(value: any): boolean; + + /** + * Checks if the given value type is array. + */ + array(value: any): boolean; + + /** + * Checks if the given value type is boolean. + */ + boolean(value: any): boolean; + + /** + * Checks if the given value type is date. + */ + date(value: any): boolean; + + /** + * Checks if the given value type is error. + */ + error(value: any): boolean; + + /** + * Checks if the given value type is function. + */ + function(value: any): boolean; + + /** + * Checks if the given value type is NaN. + */ + nan(value: any): boolean; + + /** + * Checks if the given value type is null. + */ + null(value: any): boolean; + + /** + * Checks if the given value type is number. + */ + number(value: any): boolean; + + /** + * Checks if the given value type is object. + */ + object(value: any): boolean; + + /** + * Checks if the given value type is pure json object. + */ + json(value: any): boolean; + + /** + * Checks if the given value type is RegExp. + */ + regexp(value: any): boolean; + + /** + * Checks if the given value type is string. + */ + string(value: any): boolean; + + /** + * Checks if the given value type is char. + */ + char(value: any): boolean; + + /** + * Checks if the given value type is undefined. + */ + undefined(value: any): boolean; + + /** + * Checks if the given value types are same type. + */ + sameType(value1: any, value2: any): boolean; + + //#endregion + + //#region Presence checks + + /** + * Checks if the given value is empty. + */ + empty(value: any): boolean; + + /** + * Checks if the given value is existy. (not null or undefined) + */ + existy(value: any): boolean; + + /** + * Checks if the given value is truthy. (existy and not false) + */ + truthy(value: any): boolean; + + /** + * Checks if the given value is falsy. + */ + falsy(value: any): boolean; + + /** + * Checks if the given value is space. + */ + space(value: any): boolean; + + //#endregion + + //#region RegExp checks + + /** + * Checks if the given value matches url regexp. + */ + url(value: any): boolean; + + /** + * Checks if the given value matches email regexp. + */ + email(value: any): boolean; + + /** + * Checks if the given value matches credit card regexp. + */ + creditCard(value: any): boolean; + + /** + * Checks if the given value matches alpha numeric regexp. + */ + alphaNumeric(value: any): boolean; + + /** + * Checks if the given value matches time string regexp. + */ + timeString(value: any): boolean; + + /** + * Checks if the given value matches date string regexp. + */ + dateString(value: any): boolean; + + /** + * Checks if the given value matches US zip code regexp. + */ + usZipCode(value: any): boolean; + + /** + * Checks if the given value matches Canada postal code regexp. + */ + caPostalCode(value: any): boolean; + + /** + * Checks if the given value matches UK post code regexp. + */ + ukPostCode(value: any): boolean; + + /** + * Checks if the given value matches North American numbering plan phone regexp. + */ + nanpPhone(value: any): boolean; + + /** + * Checks if the given value matches extensible provisioning protocol phone regexp. + */ + eppPhone(value: any): boolean; + + /** + * Checks if the given value matches social security number regexp. + */ + socialSecurityNumber(value: any): boolean; + + /** + * Checks if the given value matches affirmative regexp. + */ + affirmative(value: any): boolean; + + /** + * Checks if the given value matches hexadecimal regexp. + */ + hexadecimal(value: any): boolean; + + /** + * Checks if the given value matches hexcolor regexp. + */ + hexColor(value: any): boolean; + + /** + * Checks if the given value matches ip regexp. + */ + ip(value: any): boolean; + + /** + * Checks if the given value matches ipv4 regexp + */ + ipv4(value: any): boolean; + + /** + * Checks if the given value matches ipv6 regexp + */ + ipv6(value: any): boolean; + + //#endregion + + //#region String checks + + /** + * Checks if the given string contains a substring. + */ + include(value1: string, value2: string): boolean; + + /** + * Checks if the given string is UPPERCASE. + */ + upperCase(value: string): boolean; + + /** + * Checks if the given string is lowercase. + */ + lowerCase(value: string): boolean; + + /** + * Checks if the given string starts with substring. + */ + startWith(value1: string, value2: string): boolean; + + /** + * Checks if the given string ends with substring. + */ + endWith(value1: string, value2: string): boolean; + + /** + * Checks if the given string is capitalized. + */ + capitalized(value: string): boolean; + + /** + * Checks if the given string is palindrome. + */ + palindrome(value: string): boolean; + + //#endregion + + //#region Arithmetic checks + + /** + * Checks if the given values are equal. + */ + equal(value1: any, value2: any): boolean; + + /** + * Checks if the given value is even. + */ + even(value: number): boolean; + + /** + * Checks if the given value is odd. + */ + odd(value: number): boolean; + + /** + * Checks if the given value is positive. + */ + positive(value: number): boolean; + + /** + * Checks if the given value is negative. + */ + negative(value: number): boolean; + + /** + * Checks if the given value is above minimum value. + */ + above(value: number, min: number): boolean; + + /** + * Checks if the given value is under maximum value. + */ + under(value: number, max: number): boolean; + + /** + * Checks if the given value is within minimum and maximum values. + */ + within(value: number, min: number, max: number): boolean; + + /** + * Checks if the given value is decimal. + */ + decimal(value: number): boolean; + + /** + * Checks if the given value is integer. + */ + integer(value: number): boolean; + + /** + * Checks if the given value is finite. + */ + finite(value: number): boolean; + + /** + * Checks if the given value is infinite. + */ + infinite(value: number): boolean; + + //#endregion + + //#region Object checks + + /** + * Checks if objects' property count is equal to given count. + */ + propertyCount(value: any, count: number): boolean; + + /** + * Checks if the given property is defined on object. + */ + propertyDefined(value: any, property: string): boolean; + + /** + * Checks if the given object is window object. + */ + windowObject(value: any): boolean; + + /** + * Checks if the given object is a dom node. + */ + domNode(value: any): boolean; + + //#endregion + + //#region Array checks + + /** + * Checks if the given item is in array. + */ + inArray(value: T, array: T[]): boolean; + + /** + * Checks if the given array is sorted. + */ + sorted(value: any[]): boolean; + + //#endregion + + //#region Environment checks + + /** + * Checks if current browser is ie + * @parm value Optional version number of browser + */ + ie(value?: number): boolean; + + /** + * Checks if current browser is chrome. + */ + chrome(): boolean; + + /** + * Checks if current browser is firefox. + */ + firefox(): boolean; + + /** + * Checks if current browser is opera. + */ + opera(): boolean; + + /** + * Checks if current browser is safari. + */ + safari(): boolean; + + /** + * Checks if current device has ios. + */ + ios(): boolean; + + /** + * Checks if current device is iPhone. + */ + iphone(): boolean; + + /** + * Checks if current device is iPad. + */ + ipad(): boolean; + + /** + * Checks if current device is iPod. + */ + ipod(): boolean; + + /** + * Checks if current device has Android. + */ + android(): boolean; + + /** + * Checks if current device is Android phone. + */ + androidPhone(): boolean; + + /** + * Checks if current device is Android tablet. + */ + androidTablet(): boolean; + + /** + * Checks if current device is Blackberry. + */ + blackberry(): boolean; + + /** + * Checks if current device is Windows phone. + */ + windowsPhone(): boolean; + + /** + * Checks if current device is Windows tablet. + */ + windowsTablet(): boolean; + + /** + * Checks if current OS is Windows. + */ + windows(): boolean; + + /** + * Checks if current OS is Mac OS X. + */ + mac(): boolean; + + /** + * Checks if current OS is linux. + */ + linux(): boolean; + + /** + * Checks if current device is desktop. + */ + desktop(): boolean; + + /** + * Checks if current device is mobile. + */ + mobile(): boolean; + + /** + * Checks if current device is tablet. + */ + tablet(): boolean; + + /** + * Checks if current device is online. + */ + online(): boolean; + + /** + * Checks if current device is offline. + */ + offline(): boolean; + + //#endregion + + //#region Time checks + + /** + * Checks if the given date object indicate today. + */ + today(value: Date): boolean; + + /** + * Checks if the given date object indicate yesterday. + */ + yesterday(value: Date): boolean; + + /** + * Checks if the given date object indicate tomorrow. + */ + tomorrow(value: Date): boolean; + + /** + * Checks if the given date object indicate past. + */ + past(value: Date): boolean; + + /** + * Checks if the given date object indicate future. + */ + future(value: Date): boolean; + + /** + * Checks if the given date objects' day equal given dayString parameter. + */ + day(value: Date, dayString: string): boolean; + + /** + * Checks if the given date objects' month equal given monthString parameter. + */ + month(value: Date, monthString: string): boolean; + + /** + * Checks if the given date objects' year equal given yearNumber parameter. + */ + year(value: Date, yearNumber: number): boolean; + + /** + * Checks if the given year number is a leap year + */ + leapYear(value: number): boolean; + + /** + * Checks if the given date objects' day is weekend. + */ + weekend(value: Date): boolean; + + /** + * Checks if the given date objects' day is weekday. + */ + weekday(value: Date): boolean; + + /** + * Checks if date is within given range. + */ + inDateRange(value: Date, start: Date, end: Date): boolean; + + /** + * Checks if the given date is between now and 7 days ago. + */ + inLastWeek(value: Date): boolean; + + /** + * Checks if the given date is between now and a month ago. + */ + inLastMonth(value: Date): boolean; + + /** + * Checks if the given date is between now and a year ago. + */ + inLastYear(value: Date): boolean; + + /** + * Checks if the given date is between now and 7 days later. + */ + inNextWeek(value: Date): boolean; + + /** + * Checks if the given date is between now and a month later. + */ + inNextMonth(value: Date): boolean; + + /** + * Checks if the given date is between now and a year later. + */ + inNextYear(value: Date): boolean; + + /** + * Checks if the given date is in the parameter quarter. + */ + quarterOfYear(value: Date, quarter: number): boolean; + + /** + * Checks if the given date is in daylight saving time. + */ + dayLightSavingTime(value: Date): boolean; + + //#endregion + +} + +interface IsStaticApi { + + //#region Type checks + + /** + * Checks if the given value type is arguments. + */ + arguments(...value: any[]): boolean; + + /** + * Checks if the given value type is arguments. + */ + arguments(value: any[]): boolean; + + /** + * Checks if the given value type is array. + */ + array(...value: any[]): boolean; + + /** + * Checks if the given value type is array. + */ + array(value: any[]): boolean; + + /** + * Checks if the given value type is boolean. + */ + boolean(...value: any[]): boolean; + + /** + * Checks if the given value type is boolean. + */ + boolean(value: any[]): boolean; + + /** + * Checks if the given value type is date. + */ + date(...value: any[]): boolean; + + /** + * Checks if the given value type is date. + */ + date(value: any[]): boolean; + + /** + * Checks if the given value type is error. + */ + error(...value: any[]): boolean; + + /** + * Checks if the given value type is error. + */ + error(value: any[]): boolean; + + /** + * Checks if the given value type is function. + */ + function(...value: any[]): boolean; + + /** + * Checks if the given value type is function. + */ + function(value: any[]): boolean; + + /** + * Checks if the given value type is NaN. + */ + nan(...value: any[]): boolean; + + /** + * Checks if the given value type is NaN. + */ + nan(value: any[]): boolean; + + /** + * Checks if the given value type is null. + */ + null(...value: any[]): boolean; + + /** + * Checks if the given value type is null. + */ + null(value: any[]): boolean; + + /** + * Checks if the given value type is number. + */ + number(...value: any[]): boolean; + + /** + * Checks if the given value type is number. + */ + number(value: any[]): boolean; + + /** + * Checks if the given value type is object. + */ + object(...value: any[]): boolean; + + /** + * Checks if the given value type is object. + */ + object(value: any[]): boolean; + + /** + * Checks if the given value type is pure json object. + */ + json(...value: any[]): boolean; + + /** + * Checks if the given value type is pure json object. + */ + json(value: any[]): boolean; + + /** + * Checks if the given value type is RegExp. + */ + regexp(...value: any[]): boolean; + + /** + * Checks if the given value type is RegExp. + */ + regexp(value: any[]): boolean; + + /** + * Checks if the given value type is string. + */ + string(...value: any[]): boolean; + + /** + * Checks if the given value type is string. + */ + string(value: any[]): boolean; + + /** + * Checks if the given value type is char. + */ + char(...value: any[]): boolean; + + /** + * Checks if the given value type is char. + */ + char(value: any[]): boolean; + + /** + * Checks if the given value type is undefined. + */ + undefined(...value: any[]): boolean; + + /** + * Checks if the given value type is undefined. + */ + undefined(value: any[]): boolean; + + //#endregion + + //#region Presence checks + + /** + * Checks if the given value is empty. + */ + empty(...value: any[]): boolean; + + /** + * Checks if the given value is empty. + */ + empty(value: any[]): boolean; + + /** + * Checks if the given value is existy. (not null or undefined) + */ + existy(...value: any[]): boolean; + + /** + * Checks if the given value is existy. (not null or undefined) + */ + existy(value: any[]): boolean; + + /** + * Checks if the given value is truthy. (existy and not false) + */ + truthy(...value: any[]): boolean; + + /** + * Checks if the given value is truthy. (existy and not false) + */ + truthy(value: any[]): boolean; + + /** + * Checks if the given value is falsy. + */ + falsy(...value: any[]): boolean; + + /** + * Checks if the given value is falsy. + */ + falsy(value: any[]): boolean; + + /** + * Checks if the given value is space. + */ + space(...value: any[]): boolean; + + /** + * Checks if the given value is space. + */ + space(value: any[]): boolean; + + //#endregion + + //#region RegExp checks + + /** + * Checks if the given value matches url regexp. + */ + url(...value: any[]): boolean; + + /** + * Checks if the given value matches url regexp. + */ + url(value: any[]): boolean; + + /** + * Checks if the given value matches email regexp. + */ + email(...value: any[]): boolean; + + /** + * Checks if the given value matches email regexp. + */ + email(value: any[]): boolean; + + /** + * Checks if the given value matches credit card regexp. + */ + creditCard(...value: any[]): boolean; + + /** + * Checks if the given value matches credit card regexp. + */ + creditCard(value: any[]): boolean; + + /** + * Checks if the given value matches alpha numeric regexp. + */ + alphaNumeric(...value: any[]): boolean; + + /** + * Checks if the given value matches alpha numeric regexp. + */ + alphaNumeric(value: any[]): boolean; + + /** + * Checks if the given value matches time string regexp. + */ + timeString(...value: any[]): boolean; + + /** + * Checks if the given value matches time string regexp. + */ + timeString(value: any[]): boolean; + + /** + * Checks if the given value matches date string regexp. + */ + dateString(...value: any[]): boolean; + + /** + * Checks if the given value matches date string regexp. + */ + dateString(value: any[]): boolean; + + /** + * Checks if the given value matches US zip code regexp. + */ + usZipCode(...value: any[]): boolean; + + /** + * Checks if the given value matches US zip code regexp. + */ + usZipCode(value: any[]): boolean; + + /** + * Checks if the given value matches Canada postal code regexp. + */ + caPostalCode(...value: any[]): boolean; + + /** + * Checks if the given value matches Canada postal code regexp. + */ + caPostalCode(value: any[]): boolean; + + /** + * Checks if the given value matches UK post code regexp. + */ + ukPostCode(...value: any[]): boolean; + + /** + * Checks if the given value matches UK post code regexp. + */ + ukPostCode(value: any[]): boolean; + + /** + * Checks if the given value matches North American numbering plan phone regexp. + */ + nanpPhone(...value: any[]): boolean; + + /** + * Checks if the given value matches North American numbering plan phone regexp. + */ + nanpPhone(value: any[]): boolean; + + /** + * Checks if the given value matches extensible provisioning protocol phone regexp. + */ + eppPhone(...value: any[]): boolean; + + /** + * Checks if the given value matches extensible provisioning protocol phone regexp. + */ + eppPhone(value: any[]): boolean; + + /** + * Checks if the given value matches social security number regexp. + */ + socialSecurityNumber(...value: any[]): boolean; + + /** + * Checks if the given value matches social security number regexp. + */ + socialSecurityNumber(value: any[]): boolean; + + /** + * Checks if the given value matches affirmative regexp. + */ + affirmative(...value: any[]): boolean; + + /** + * Checks if the given value matches affirmative regexp. + */ + affirmative(value: any[]): boolean; + + /** + * Checks if the given value matches hexadecimal regexp. + */ + hexadecimal(...value: any[]): boolean; + + /** + * Checks if the given value matches hexadecimal regexp. + */ + hexadecimal(value: any[]): boolean; + + /** + * Checks if the given value matches hexcolor regexp. + */ + hexColor(...value: any[]): boolean; + + /** + * Checks if the given value matches hexcolor regexp. + */ + hexColor(value: any[]): boolean; + + /** + * Checks if the given value matches ip regexp. + */ + ip(...value: any[]): boolean; + + /** + * Checks if the given value matches ip regexp. + */ + ip(value: any[]): boolean; + + /** + * Checks if the given value matches ipv4 regexp. + */ + ipv4(...value: any[]): boolean; + + /** + * Checks if the given value matches ipv4 regexp. + */ + ipv4(value: any[]): boolean; + + /** + * Checks if the given value matches ipv6 regexp. + */ + ipv6(...value: any[]): boolean; + + /** + * Checks if the given value matches ipv6 regexp. + */ + ipv6(value: any[]): boolean; + + //#endregion + + //#region String checks + + /** + * Checks if the given string is UPPERCASE. + */ + upperCase(...value: string[]): boolean; + + /** + * Checks if the given string is UPPERCASE. + */ + upperCase(value: string[]): boolean; + + /** + * Checks if the given string is lowercase. + */ + lowerCase(...value: string[]): boolean; + + /** + * Checks if the given string is lowercase. + */ + lowerCase(value: string[]): boolean; + + /** + * Checks if the given string is capitalized. + */ + capitalized(...value: string[]): boolean; + + /** + * Checks if the given string is capitalized. + */ + capitalized(value: string[]): boolean; + + /** + * Checks if the given string is palindrome + */ + palindrome(...value: string[]): boolean; + + /** + * Checks if the given string is palindrome + */ + palindrome(value: string[]): boolean; + + //#endregion + + //#region Arithmetic checks + + /** + * Checks if the given value is even. + */ + even(...value: number[]): boolean; + + /** + * Checks if the given value is even. + */ + even(value: number[]): boolean; + + /** + * Checks if the given value is odd. + */ + odd(...value: number[]): boolean; + + /** + * Checks if the given value is odd. + */ + odd(value: number[]): boolean; + + /** + * Checks if the given value is positive. + */ + positive(...value: number[]): boolean; + + /** + * Checks if the given value is positive. + */ + positive(value: number[]): boolean; + + /** + * Checks if the given value is negative. + */ + negative(...value: number[]): boolean; + + /** + * Checks if the given value is negative. + */ + negative(value: number[]): boolean; + + /** + * Checks if the given value is decimal. + */ + decimal(...value: number[]): boolean; + + /** + * Checks if the given value is decimal. + */ + decimal(value: number[]): boolean; + + /** + * Checks if the given value is integer. + */ + integer(...value: number[]): boolean; + + /** + * Checks if the given value is integer. + */ + integer(value: number[]): boolean; + + /** + * Checks if the given value is finite. + */ + finite(...value: number[]): boolean; + + /** + * Checks if the given value is finite. + */ + finite(value: number[]): boolean; + + /** + * Checks if the given value is infinite. + */ + infinite(...value: number[]): boolean; + + /** + * Checks if the given value is infinite. + */ + infinite(value: number[]): boolean; + + //#endregion + + //#region Object checks + + /** + * Checks if the given object is window object. + */ + windowObject(...value: any[]): boolean; + + /** + * Checks if the given object is window object. + */ + windowObject(value: any[]): boolean; + + /** + * Checks if the given object is a dom node. + */ + domNode(...value: any[]): boolean; + + /** + * Checks if the given object is a dom node. + */ + domNode(value: any[]): boolean; + + //#endregion + + //#region Array checks + + /** + * Checks if the given array is sorted. + */ + sorted(...value: number[][]): boolean; + + /** + * Checks if the given array is sorted. + */ + sorted(value: number[][]): boolean; + + //#endregion + + //#region Time checks + + /** + * Checks if the given date object indicate today. + */ + today(...value: Date[]): boolean; + + /** + * Checks if the given date object indicate today. + */ + today(value: Date[]): boolean; + + /** + * Checks if the given date object indicate yesterday. + */ + yesterday(...value: Date[]): boolean; + + /** + * Checks if the given date object indicate yesterday. + */ + yesterday(value: Date[]): boolean; + + /** + * Checks if the given date object indicate tomorrow. + */ + tomorrow(...value: Date[]): boolean; + + /** + * Checks if the given date object indicate tomorrow. + */ + tomorrow(value: Date[]): boolean; + + /** + * Checks if the given date object indicate past. + */ + past(...value: Date[]): boolean; + + /** + * Checks if the given date object indicate past. + */ + past(value: Date[]): boolean; + + /** + * Checks if the given date object indicate future. + */ + future(...value: Date[]): boolean; + + /** + * Checks if the given date object indicate future. + */ + future(value: Date[]): boolean; + + /** + * Checks if the given year number is a leap year + */ + leapYear(...value: number[]): boolean; + + /** + * Checks if the given year number is a leap year + */ + leapYear(value: number[]): boolean; + + /** + * Checks if the given date objects' day is weekend. + */ + weekend(...value: Date[]): boolean; + + /** + * Checks if the given date objects' day is weekend. + */ + weekend(value: Date[]): boolean; + + /** + * Checks if the given date objects' day is weekday. + */ + weekday(...value: Date[]): boolean; + + /** + * Checks if the given date objects' day is weekday. + */ + weekday(value: Date[]): boolean; + + //#endregion +} + +interface Is extends IsStatic { + + not: IsStatic; + any: IsStaticApi; + all: IsStaticApi; + + /** + * Override RegExps if you think they suck. + */ + setRegexp(value: RegExp, regexp: 'url'): boolean; + + /** + * Override RegExps if you think they suck. + */ + setRegexp(value: RegExp, regexp: 'email'): boolean; + + /** + * Override RegExps if you think they suck. + */ + setRegexp(value: RegExp, regexp: 'creditCard'): boolean; + + /** + * Override RegExps if you think they suck. + */ + setRegexp(value: RegExp, regexp: 'alphaNumeric'): boolean; + + /** + * Override RegExps if you think they suck. + */ + setRegexp(value: RegExp, regexp: 'timeString'): boolean; + + /** + * Override RegExps if you think they suck. + */ + setRegexp(value: RegExp, regexp: 'dateString'): boolean; + + /** + * Override RegExps if you think they suck. + */ + setRegexp(value: RegExp, regexp: 'usZipCode'): boolean; + + /** + * Override RegExps if you think they suck. + */ + setRegexp(value: RegExp, regexp: 'caPostalCode'): boolean; + + /** + * Override RegExps if you think they suck. + */ + setRegexp(value: RegExp, regexp: 'nanpPhone'): boolean; + + /** + * Override RegExps if you think they suck. + */ + setRegexp(value: RegExp, regexp: 'eppPhone'): boolean; + + /** + * Override RegExps if you think they suck. + */ + setRegexp(value: RegExp, regexp: 'affirmative'): boolean; + + /** + * Override RegExps if you think they suck. + */ + setRegexp(value: RegExp, regexp: 'hexadecimal'): boolean; + + /** + * Override RegExps if you think they suck. + */ + setRegexp(value: RegExp, regexp: 'hexColor'): boolean; + + /** + * Override RegExps if you think they suck. + */ + setRegexp(value: RegExp, regexp: 'ip'): boolean; + + /** + * Override RegExps if you think they suck. + */ + setRegexp(value: RegExp, regexp: 'ipv6'): boolean; + + /** + * Override RegExps if you think they suck. + */ + setRegexp(value: RegExp, regexp: string): boolean; + + /** + * Change namespace of library to prevent name collisions. + */ + setNamespace(): Is; +} + +declare var is: Is; + +declare module 'is' { + export = is; +} \ No newline at end of file From 2fb1302479033161817fb901a778323d7bd4b743 Mon Sep 17 00:00:00 2001 From: laszlojakab Date: Tue, 24 Feb 2015 09:24:16 +0100 Subject: [PATCH 078/185] toJSON() added --- moment/moment.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/moment/moment.d.ts b/moment/moment.d.ts index 6bd041c5c..841ecd09a 100644 --- a/moment/moment.d.ts +++ b/moment/moment.d.ts @@ -227,6 +227,7 @@ declare module moment { toDate(): Date; toISOString(): string; + toJSON(): string; unix(): number; isLeapYear(): boolean; From 8b558e1f0a6a34feb3ed5c2913b324e8d1c19026 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Morch=C3=B3n=20Poveda?= Date: Tue, 24 Feb 2015 09:58:08 +0100 Subject: [PATCH 079/185] Update knockout.d.ts As of: ``` javascript self['$rawData'] = dataItemOrObservable; ``` at https://github.com/knockout/knockout/blob/master/src/binding/bindingAttributeSyntax.js --- knockout/knockout.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/knockout/knockout.d.ts b/knockout/knockout.d.ts index 80969ef0b..3d7eace2c 100644 --- a/knockout/knockout.d.ts +++ b/knockout/knockout.d.ts @@ -118,6 +118,7 @@ interface KnockoutBindingContext { $parents: any[]; $root: any; $data: any; + $rawData: any | KnockoutObservable; $index?: KnockoutObservable; $parentContext?: KnockoutBindingContext; From 99dce32c09c42da277662a2c1f09a787639fb89d Mon Sep 17 00:00:00 2001 From: Skitch Date: Tue, 24 Feb 2015 10:53:05 -0500 Subject: [PATCH 080/185] Added optional index parameter to DSV's parse row accessor --- d3/d3.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/d3/d3.d.ts b/d3/d3.d.ts index 4935110e1..6cc372f7f 100644 --- a/d3/d3.d.ts +++ b/d3/d3.d.ts @@ -704,7 +704,7 @@ declare module D3 { * @param string delimited formatted string to parse * @param accessor to modify properties of each row */ - parse(string: string, accessor?: (row: any) => any): any[]; + parse(string: string, accessor?: (row: any, index?: number) => any): any[]; /** * Parse a delimited string into tuples, ignoring the header row. * From 3ca66ac6fbc3f01a425386b393baf31a2d2e4553 Mon Sep 17 00:00:00 2001 From: Igor Fesenko Date: Tue, 24 Feb 2015 18:05:29 +0200 Subject: [PATCH 081/185] toastr: Added progressBar --- toastr/toastr-tests.ts | 3 ++- toastr/toastr.d.ts | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/toastr/toastr-tests.ts b/toastr/toastr-tests.ts index 9a5ae6a19..adacb1934 100644 --- a/toastr/toastr-tests.ts +++ b/toastr/toastr-tests.ts @@ -48,7 +48,8 @@ function test_fromdemo() { debug: $('#debugInfo').prop('checked'), tapToDismiss: $('#tapToDismiss').prop('checked'), positionClass: $('#positionGroup input:radio:checked').val() || 'toast-top-right', - preventDuplicates: true + preventDuplicates: true, + progressBar: true } if ($fadeIn.val().length) { toastr.options.showDuration = +$fadeIn.val() diff --git a/toastr/toastr.d.ts b/toastr/toastr.d.ts index 8745a6157..2fcdc3840 100644 --- a/toastr/toastr.d.ts +++ b/toastr/toastr.d.ts @@ -119,6 +119,11 @@ interface ToastrOptions { */ preventDuplicates?: boolean; + /** + * Visually indicates how long before a toast expires. + */ + progressBar?: boolean; + /** * Function to execute on toast click */ From be9cde5cf9ad4e981d017a50e8edcc36778b5f60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Morch=C3=B3n=20Poveda?= Date: Tue, 24 Feb 2015 17:09:42 +0100 Subject: [PATCH 082/185] Base classes to inherit from them (step 1 of X) Add a base class --- yeoman-generator/yeoman-generator.d.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/yeoman-generator/yeoman-generator.d.ts b/yeoman-generator/yeoman-generator.d.ts index aed7a8f03..fa2dec44b 100644 --- a/yeoman-generator/yeoman-generator.d.ts +++ b/yeoman-generator/yeoman-generator.d.ts @@ -20,6 +20,22 @@ declare module yo { sourceRoot(rootPath: string): string; } + export class YeomanGeneratorBase implements IYeomanGenerator { + argument(name: string, config: IArgumentConfig): void; + composeWith(namespace: string, options: any, settings?: IComposeSetting): IYeomanGenerator; + defaultFor(name: string): void; + destinationRoot(rootPath: string): string; + determineAppname(): void; + getCollisionFilter(): (output: any) => void; + hookFor(name: string, config: IHookConfig): void; + option(name: string, config: IYeomanGeneratorOption): void; + rootGeneratorName(): string; + run(args?: any): void; + run(args: any, callback?: Function): void; + runHooks(callback?: Function): void; + sourceRoot(rootPath: string): string; + } + export interface IArgumentConfig { desc: string; required: boolean; From 0acdbea7fda268fafae18a061070c7544b0596b9 Mon Sep 17 00:00:00 2001 From: vvakame Date: Wed, 25 Feb 2015 01:19:03 +0900 Subject: [PATCH 083/185] update CONTRIBUTORS.md --- CONTRIBUTORS.md | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 59f0f70e5..c870d1977 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -25,7 +25,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](angular-translate/angular-translate.d.ts) [Angular Translate (pascalprecht.translate module)](https://github.com/PascalPrecht/angular-translate) by [Michel Salib](https://github.com/michelsalib) * [:link:](angular-ui-bootstrap/angular-ui-bootstrap.d.ts) [Angular UI Bootstrap](https://github.com/angular-ui/bootstrap) by [Brian Surowiec](https://github.com/xt0rted) * [:link:](angular-bootstrap-lightbox/angular-bootstrap-lightbox.d.ts) [angular-bootstrap-lightbox](https://github.com/compact/angular-bootstrap-lightbox) by [Roland Zwaga](https://github.com/rolandzwaga) -* [:link:](angular-hotkeys/angular-hotkeys.d.ts) [angular-hotkeys](https://github.com/chieffancypants/angular-hotkeys) by [Jason Zhao](https://github.com/jlz27) +* [:link:](angular-hotkeys/angular-hotkeys.d.ts) [angular-hotkeys](https://github.com/chieffancypants/angular-hotkeys) by [Jason Zhao](https://github.com/jlz27), [Stefan Steinhart](https://github.com/reppners) * [:link:](angular-http-auth/angular-http-auth.d.ts) [angular-http-auth](https://github.com/witoldsz/angular-http-auth) by [vvakame](https://github.com/vvakame) * [:link:](angular-local-storage/angular-local-storage.d.ts) [angular-local-storage](https://github.com/grevory/angular-local-storage) by [Ken Fukuyama](https://github.com/kenfdev) * [:link:](angular-notify/angular-notify.d.ts) [angular-notify](https://github.com/cgross/angular-notify) by [Suwato](https://github.com/Suwato/DefinitelyTyped) @@ -41,6 +41,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](cordova/cordova.d.ts) [Apache Cordova](http://cordova.apache.org) by [Microsoft Open Technologies Inc.](http://msopentech.com) * [:link:](appframework/appframework.d.ts) [AppFramework](http://app-framework-software.intel.com) by [kyo_ago](https://github.com/kyo-ago) * [:link:](arbiter/Arbiter.d.ts) [Arbiter.js](http://arbiterjs.com) by [Arash Shakery](https://github.com/arash16) +* [:link:](archy/archy.d.ts) [archy](https://github.com/substack/node-archy) by [vvakame](https://github.com/vvakame) * [:link:](asciify/asciify.d.ts) [asciify](https://www.npmjs.org/package/asciify) by [Alan Norbauer](http://alan.norbauer.com) * [:link:](aspnet-identity-pw/aspnet-identity-pw.d.ts) [aspnet-identity-pw](https://github.com/Syncbak-Git/aspnet-identity-pw) by [jt000](https://github.com/jt000) * [:link:](assert/assert.d.ts) [assert and power-assert](https://github.com/Jxck/assert) by [vvakame](https://github.com/vvakame) @@ -136,7 +137,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](dat-gui/dat-gui.d.ts) [dat.GUI](https://github.com/dataarts/dat.gui) by [Satoru Kimura](https://github.com/gyohk) * [:link:](date.format.js/date.format.d.ts) [Date Format](http://blog.stevenlevithan.com/archives/date-time-format) by [Rob Stutton](https://github.com/balrob) * [:link:](datejs/datejs.d.ts) [DateJS](http://www.datejs.com) by [David Khristepher Santos](http://github.com/rupertavery) -* [:link:](dcjs/dc.d.ts) [DCJS](https://github.com/dc-js) by [hans windhoff](https://github.com/hansrwindhoff) +* [:link:](dcjs/dc.d.ts) [DCJS](https://github.com/dc-js/dc.js) by [hans windhoff](https://github.com/hansrwindhoff), [matt traynham](https://github.com/mtraynham) * [:link:](debug/debug.d.ts) [debug](https://github.com/visionmedia/debug) by [Seon-Wook Park](https://github.com/swook) * [:link:](deep-diff/deep-diff.d.ts) [deep-diff](https://github.com/flitbit/diff) by [ZauberNerd](https://github.com/ZauberNerd) * [:link:](deep-freeze/deep-freeze.d.ts) [deep-freeze](https://github.com/substack/deep-freeze) by [Bart van der Schoor](https://github.com/Bartvds) @@ -237,8 +238,8 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](google.analytics/ga.d.ts) [Google Analytics (Classic and Universal)](https://developers.google.com/analytics/devguides/collection/gajs) by [Ronnie Haakon Hegelund](http://ronniehegelund.blogspot.dk), [Pat Kujawa](http://patkujawa.com) * [:link:](gapi/gapi.d.ts) [Google API Client](https://code.google.com/p/google-api-javascript-client) by [Frank M](https://github.com/sgtfrankieboy) * [:link:](google.feeds/google.feed.api.d.ts) [Google Feed Apis](https://developers.google.com/feed) by [RodneyJT](https://github.com/RodneyJT) -* [:link:](google.geolocation/google.geolocation.d.ts) [Google Geolocation](https://code.google.com/p/geo-location-javascript) by [Vincent Bortone](https://github.com/vbortone) * [:link:](googlemaps/google.maps.d.ts) [Google Geolocation](https://developers.google.com/maps) by [Folia A/S](http://www.folia.dk) +* [:link:](google.geolocation/google.geolocation.d.ts) [Google Geolocation](https://code.google.com/p/geo-location-javascript) by [Vincent Bortone](https://github.com/vbortone) * [:link:](gapi.pagespeedonline/gapi.pagespeedonline.d.ts) [Google Page Speed Online Api](https://developers.google.com/speed/pagespeed) by [Frank M](https://github.com/sgtfrankieboy) * [:link:](recaptcha/recaptcha.d.ts) [Google Recaptcha](https://www.google.com/recaptcha) by [Brent Jenkins](https://github.com/brentj73) * [:link:](gapi.translate/gapi.translate.d.ts) [Google Translate API](https://developers.google.com/translate) by [Frank M](https://github.com/sgtfrankieboy) @@ -324,6 +325,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](jquery.dataTables/jquery.dataTables.d.ts) [JQuery DataTables](http://www.datatables.net) by [Armin Sander](https://github.com/pragmatrix) * [:link:](jquery.fileupload/jquery.fileupload.d.ts) [jQuery File Upload Plugin](https://github.com/blueimp/jQuery-File-Upload) by [Rob Alarcon](https://github.com/rob-alarcon) * [:link:](jquery.joyride/jquery.joyride.d.ts) [jQuery JoyRide Plugin](https://github.com/zurb/joyride) by [Vincent Bortone](https://github.com/vbortone) +* [:link:](jqgrid/jqgrid.d.ts) [jQuery jqgrid Plugin](https://github.com/tonytomov/jqGrid) by [Lokesh Peta](https://github.com/lokeshpeta) * [:link:](jquerymobile/jquerymobile.d.ts) [jQuery Mobile](http://jquerymobile.com) by [Boris Yankov](https://github.com/borisyankov) * [:link:](jquery.notifyBar/jquery.notifyBar.d.ts) [jQuery Notify Bar](http://www.whoop.ee/posts/2013-04-05-the-resurrection-of-jquery-notify-bar) by [Shunsuke Ohtani](https://github.com/zaneli) * [:link:](jquery.base64/jquery.base64.d.ts) [jQuery Plugin - base64 codec](https://github.com/yatt/jquery.base64) by [Shinya Mochizuki](https://github.com/enrapt-mochizuki) @@ -390,6 +392,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](jshamcrest/jshamcrest.d.ts) [JsHamcrest](https://github.com/danielfm/jshamcrest) by [David Harkness](https://github.com/dharkness) * [:link:](hashset/hashset.d.ts) [jshashset](http://www.timdown.co.uk/jshashtable/jshashset.html) by [Sergey Gerasimov](https://github.com/gerich-home) * [:link:](hashtable/hashtable.d.ts) [jshashtable](http://www.timdown.co.uk/jshashtable) by [Sergey Gerasimov](https://github.com/gerich-home) +* [:link:](jsnox/jsnox.d.ts) [JSnoX](https://github.com/af/jsnox) by [Steve Baker](https://github.com/stkb) * [:link:](json-pointer/json-pointer.d.ts) [json-pointer 1.0 l](https://www.npmjs.org/package/json-pointer) by [Bart van der Schoor](https://github.com/Bartvds) * [:link:](jsoneditoronline/jsoneditoronline.d.ts) [JSONEditorOnline](https://github.com/josdejong/jsoneditoronline) by [Vincent Bortone](https://github.com/vbortone) * [:link:](JSONStream/JSONStream.d.ts) [JSONStream](http://github.com/dominictarr/JSONStream) by [Bart van der Schoor](https://github.com/Bartvds) @@ -423,6 +426,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](knockout.rx/knockout.rx.d.ts) [knockout.rx](https://github.com/Igorbek/knockout.rx) by [Igor Oleinikov](https://github.com/Igorbek) * [:link:](knockstrap/knockstrap.d.ts) [Knockstrap](http://faulknercs.github.io/Knockstrap) by [Adam PluciÅ„ski](https://github.com/adaskothebeast) * [:link:](knockout.kogrid/ko-grid.d.ts) [ko-grid](http://knockout-contrib.github.io/KoGrid) by [huer12](https://github.com/huer12) +* [:link:](ko.plus/ko.plus.d.ts) [ko.plus](https://github.com/stevegreatrex/ko.plus) by [Howard Richards](https://github.com/conficient) * [:link:](kolite/kolite.d.ts) [KoLite](https://github.com/CodeSeven/kolite) by [Boris Yankov](https://github.com/borisyankov) * [:link:](kuromoji/kuromoji.d.ts) [kuromoji.js](https://github.com/takuyaa/kuromoji.js) by [MIZUSHIMA Junki](https://github.com/mzsm) * [:link:](ladda/ladda.d.ts) [Ladda](https://github.com/hakimel/Ladda) by [Danil Flores](https://github.com/dflor003), [Michael Lee](https://github.com/leemicw) @@ -444,7 +448,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](log4javascript/log4javascript.d.ts) [log4javascript](http://log4javascript.org) by [Markus Wagner](https://github.com/Ritzlgrmft) * [:link:](log4js/log4js.d.ts) [log4js](https://github.com/nomiddlename/log4js-node) by [Kentaro Okuno](http://github.com/armorik83) * [:link:](logg/logg.d.ts) [logg](https://github.com/dpup/node-logg) by [Bret Little](https://github.com/blittle) -* [:link:](logrotate-stream/logrotate-stream.d.ts) [logrotate-stream](https://github.com/dstokes/logrotate-stream) by [rogierschouten](https://github.com/rogierschouten) +* [:link:](logrotate-stream/logrotate-stream.d.ts) [logrotate-stream](https://github.com/dstokes/logrotate-stream) by [Rogier Schouten](https://github.com/rogierschouten) * [:link:](long/long.d.ts) [Long.js](https://github.com/dcodeIO/Long.js) by [Toshihide Hara](https://github.com/kerug) * [:link:](lru-cache/lru-cache.d.ts) [lru-cache](https://github.com/isaacs/node-lru-cache) by [Bart van der Schoor](https://github.com/Bartvds) * [:link:](lscache/lscache.d.ts) [lscache](https://github.com/pamelafox/lscache) by [Chris Martinez](https://github.com/Chris-Martinezz) @@ -454,9 +458,11 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](mapsjs/mapsjs.d.ts) [Mapsjs](https://github.com/mapsjs) by [Matthew James Davis](https://github.com/davismj) * [:link:](marionette/marionette.d.ts) [Marionette](https://github.com/marionettejs) by [Zeeshan Hamid](https://github.com/zhamid), [Natan Vivo](https://github.com/nvivo), [Sven Tschui](https://github.com/sventschui) * [:link:](marked/marked.d.ts) [Marked](https://github.com/chjj/marked) by [William Orr](https://github.com/worr) +* [:link:](maskedinput/maskedinput.d.ts) [Masked Input plugin for jQuery](http://digitalbush.com/projects/masked-input-plugin) by [Lokesh Peta](https://github.com/lokeshpeta) * [:link:](mathjax/mathjax.d.ts) [MathJax](https://github.com/mathjax/MathJax) by [Roland Zwaga](https://github.com/rolandzwaga) * [:link:](mCustomScrollbar/mCustomScrollbar.d.ts) [mCustomScrollbar](https://github.com/malihu/malihu-custom-scrollbar-plugin) by [Sarah Williams](https://github.com/flurg) * [:link:](memory-cache/memory-cache.d.ts) [memory-cache](http://github.com/ptarjan/node-cache) by [Jeff Goddard](https://github.com/jedigo) +* [:link:](mess/mess.d.ts) [mess](https://github.com/bobrik/node-mess) by [Wim Looman](https://github.com/Nemo157) * [:link:](messenger/messenger.d.ts) [Messenger.js](https://github.com/HubSpot/messenger) by [Derek Cicerone](https://github.com/derekcicerone) * [:link:](meteor/meteor.d.ts) [Meteor](http://www.meteor.com) by [Dave Allen](https://github.com/fullflavedave) * [:link:](method-override/method-override.d.ts) [method-override](https://github.com/expressjs/method-override) by [Santi Albo](https://github.com/santialbo) @@ -538,8 +544,8 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](nodeunit/nodeunit.d.ts) [nodeunit](https://github.com/caolan/nodeunit) by [Jeff Goddard](https://github.com/jedigo) * [:link:](nomnom/nomnom.d.ts) [nomnom](https://github.com/harthur/nomnom) by [Paul Vick](https://github.com/panopticoncentral) * [:link:](nopt/nopt.d.ts) [nopt](https://github.com/npm/nopt) by [jbondc](https://github.com/jbondc) -* [:link:](notifyjs/notifyjs.d.ts) [notify.js](https://github.com/alexgibson/notify.js) by [soundTricker](https://github.com/soundTricker) * [:link:](notify/notify.d.ts) [Notify.js](https://github.com/jpillora/notifyjs) by [Xiaohan Zhang](https://github.com/hellochar) +* [:link:](notifyjs/notifyjs.d.ts) [notify.js](https://github.com/alexgibson/notify.js) by [soundTricker](https://github.com/soundTricker) * [:link:](noVNC/noVNC.d.ts) [noVNC](https://github.com/kanaka/noVNC) by [Ken Smith](https://github.com/smithkl42) * [:link:](npm/npm.d.ts) [npm](https://github.com/npm/npm) by [Maxime LUCE](https://github.com/SomaticIT) * [:link:](nprogress/nprogress.d.ts) [NProgress](https://github.com/rstacruz/nprogress) by [Judah Gabriel Himango](http://debuggerdotbreak.wordpress.com) @@ -772,13 +778,14 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](websocket/websocket.d.ts) [websocket](https://github.com/Worlize/WebSocket-Node) by [Paul Loyd](https://github.com/loyd) * [:link:](when/when.d.ts) [When](https://github.com/cujojs/when) by [Derek Cicerone](https://github.com/derekcicerone), [Wim Looman](https://github.com/Nemo157) * [:link:](which/which.d.ts) [which](https://github.com/isaacs/node-which) by [vvakame](https://github.com/vvakame) -* [:link:](windows-service/windows-service.d.ts) [windows-service](https://bitbucket.org/stephenwvickers/node-windows-service) by [rogierschouten](https://github.com/rogierschouten) +* [:link:](windows-service/windows-service.d.ts) [windows-service](https://bitbucket.org/stephenwvickers/node-windows-service) by [Rogier Schouten](https://github.com/rogierschouten) * [:link:](winjs/winjs.d.ts) [WinJS](http://try.buildwinjs.com) by [TypeScript samples](https://www.typescriptlang.org), [Adam Hewitt](https://github.com/adamhewitt627), [Craig Treasure](https://github.com/craigktreasure), [Jeff Fisher](https://github.com/xirzec) * [:link:](winrt/winrt.d.ts) [WinRT](http://msdn.microsoft.com/en-us/library/windows/apps/br211377.aspx) by [TypeScript samples](https://www.typescriptlang.org) * [:link:](winston/winston.d.ts) [winston](https://github.com/flatiron/winston) by [bonnici](https://github.com/bonnici), [Peter Harris](https://github.com/codeanimal) * [:link:](wolfy87-eventemitter/wolfy87-eventemitter.d.ts) [wolfy87-eventemitter](https://github.com/Wolfy87/EventEmitter) by [ryiwamoto](https://github.com/ryiwamoto) * [:link:](wrench/wrench.d.ts) [wrench](https://github.com/ryanmcgrath/wrench-js) by [Carlos Ballesteros Velasco](https://github.com/soywiz) * [:link:](ws/ws.d.ts) [ws](https://github.com/einaros/ws) by [Paul Loyd](https://github.com/loyd) +* [:link:](x-editable/x-editable.d.ts) [X-Editable](http://vitalets.github.io/x-editable/index.html) by [Chris Kirby](https://github.com/sirkirby) * [:link:](x2js/xml2json.d.ts) [x2js](https://code.google.com/p/x2js) by [Horiuchi_H](https://github.com/horiuchi) * [:link:](jsfl/xJSFL.d.ts) [xJSFL](http://www.xjsfl.com) by [soywiz](https://github.com/soywiz) * [:link:](xpath/xpath.d.ts) [xpath](https://github.com/goto100/xpath) by [Andrew Bradley](https://github.com/cspotcode) From 0a2199ac29b73d1d9324d133a2bc47161dd33908 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Morch=C3=B3n=20Poveda?= Date: Tue, 24 Feb 2015 17:21:04 +0100 Subject: [PATCH 084/185] Interfaces & classes Interfaces with "new" now are Interfaces without "new" and clases with constructor. --- yeoman-generator/yeoman-generator.d.ts | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/yeoman-generator/yeoman-generator.d.ts b/yeoman-generator/yeoman-generator.d.ts index fa2dec44b..dda2d7caa 100644 --- a/yeoman-generator/yeoman-generator.d.ts +++ b/yeoman-generator/yeoman-generator.d.ts @@ -76,15 +76,19 @@ declare module yo { end: () => void; } - export interface IBase { - new(args: string, options: any): IYeomanGenerator; - new(args: string[], options: any): IYeomanGenerator; - extend(protoProps: IQueueProps, staticProps?: any): IYeomanGenerator; + export interface INamedBase extends IYeomanGenerator { } - export interface INamedBase { - new(args: string, options: any): IYeomanGenerator; - new(args: string[], options: any): IYeomanGenerator; + export interface IBase extends INamedBase { + extend(protoProps: IQueueProps, staticProps?: any): IYeomanGenerator; + } + + export class Namedbase extends YeomanGeneratorBase implements INamedBase { + constructor(args: string | string[], options: any); + } + + export class Base extends Namedbase implements IBase { + extend(protoProps: IQueueProps, staticProps?: any): IYeomanGenerator; } export interface IAssert { From b000c516422c47c9657271b637b119ac035d8558 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Morch=C3=B3n=20Poveda?= Date: Tue, 24 Feb 2015 17:26:25 +0100 Subject: [PATCH 085/185] Updated module "generators" with classes Change the un-inheritable interfaces Base: IBase and NamedBase: INamedBase by the new clases Base and NamedBase. Now you can do like this: ``` typescript class WflGenerator extends yo.generators.Base { } ``` --- yeoman-generator/yeoman-generator.d.ts | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/yeoman-generator/yeoman-generator.d.ts b/yeoman-generator/yeoman-generator.d.ts index dda2d7caa..e5f9f62e3 100644 --- a/yeoman-generator/yeoman-generator.d.ts +++ b/yeoman-generator/yeoman-generator.d.ts @@ -83,14 +83,6 @@ declare module yo { extend(protoProps: IQueueProps, staticProps?: any): IYeomanGenerator; } - export class Namedbase extends YeomanGeneratorBase implements INamedBase { - constructor(args: string | string[], options: any); - } - - export class Base extends Namedbase implements IBase { - extend(protoProps: IQueueProps, staticProps?: any): IYeomanGenerator; - } - export interface IAssert { file(path: string): void; file(paths: string[]): void; @@ -150,10 +142,16 @@ declare module yo { var file: any; var assert: IAssert; var test: ITestHelper; - var generators: { - Base: IBase; - NamedBase: INamedBase; - }; + module generators { + + export class Namedbase extends YeomanGeneratorBase implements INamedBase { + constructor(args: string | string[], options: any); + } + + export class Base extends Namedbase implements IBase { + extend(protoProps: IQueueProps, staticProps?: any): IYeomanGenerator; + } + } } declare module "yeoman-generator" { From b216006e6f1803f0d3cd76b52abc0a24fa00cb61 Mon Sep 17 00:00:00 2001 From: Rodrigo Cabral Date: Tue, 24 Feb 2015 13:33:06 -0300 Subject: [PATCH 086/185] Renamed folder and files for match the npm package --- is-js/is-js-tests.ts => is_js/is_js-tests.ts | 2 +- is-js/is-js.d.ts => is_js/is_js.d.ts | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename is-js/is-js-tests.ts => is_js/is_js-tests.ts (99%) rename is-js/is-js.d.ts => is_js/is_js.d.ts (100%) diff --git a/is-js/is-js-tests.ts b/is_js/is_js-tests.ts similarity index 99% rename from is-js/is-js-tests.ts rename to is_js/is_js-tests.ts index 44940bee1..d90728e85 100644 --- a/is-js/is-js-tests.ts +++ b/is_js/is_js-tests.ts @@ -1,4 +1,4 @@ -/// +/// //#region Type checks diff --git a/is-js/is-js.d.ts b/is_js/is_js.d.ts similarity index 100% rename from is-js/is-js.d.ts rename to is_js/is_js.d.ts From 293abd9b04aeca521a2c6bbb376da017ca89eb51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Morch=C3=B3n=20Poveda?= Date: Tue, 24 Feb 2015 17:40:25 +0100 Subject: [PATCH 087/185] Fixes Namedbase -> NamedBase static Base.extend --- yeoman-generator/yeoman-generator.d.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/yeoman-generator/yeoman-generator.d.ts b/yeoman-generator/yeoman-generator.d.ts index e5f9f62e3..bc11f2e30 100644 --- a/yeoman-generator/yeoman-generator.d.ts +++ b/yeoman-generator/yeoman-generator.d.ts @@ -80,7 +80,6 @@ declare module yo { } export interface IBase extends INamedBase { - extend(protoProps: IQueueProps, staticProps?: any): IYeomanGenerator; } export interface IAssert { @@ -144,12 +143,12 @@ declare module yo { var test: ITestHelper; module generators { - export class Namedbase extends YeomanGeneratorBase implements INamedBase { + export class NamedBase extends YeomanGeneratorBase implements INamedBase { constructor(args: string | string[], options: any); } - export class Base extends Namedbase implements IBase { - extend(protoProps: IQueueProps, staticProps?: any): IYeomanGenerator; + export class Base extends NamedBase implements IBase { + static extend(protoProps: IQueueProps, staticProps?: any): IYeomanGenerator; } } } From 022d3ea8436a98264daf329ccdaf09384333b454 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Morch=C3=B3n=20Poveda?= Date: Tue, 24 Feb 2015 17:57:02 +0100 Subject: [PATCH 088/185] Extend NodeJS.EventEmitter As seen here: https://github.com/yeoman/generator/blob/master/lib/base.js ``` JavaScript var Base = module.exports = function Base(args, options) { events.EventEmitter.call(this); ``` --- yeoman-generator/yeoman-generator.d.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/yeoman-generator/yeoman-generator.d.ts b/yeoman-generator/yeoman-generator.d.ts index bc11f2e30..f6d0dd981 100644 --- a/yeoman-generator/yeoman-generator.d.ts +++ b/yeoman-generator/yeoman-generator.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/yeoman/generator // Definitions by: Kentaro Okuno // Definitions: https://github.com/borisyankov/DefinitelyTyped +/// declare module yo { export interface IYeomanGenerator { @@ -20,7 +21,7 @@ declare module yo { sourceRoot(rootPath: string): string; } - export class YeomanGeneratorBase implements IYeomanGenerator { + export class YeomanGeneratorBase implements IYeomanGenerator, NodeJS.EventEmitter { argument(name: string, config: IArgumentConfig): void; composeWith(namespace: string, options: any, settings?: IComposeSetting): IYeomanGenerator; defaultFor(name: string): void; @@ -34,6 +35,14 @@ declare module yo { run(args: any, callback?: Function): void; runHooks(callback?: Function): void; sourceRoot(rootPath: string): string; + addListener(event: string, listener: Function): NodeJS.EventEmitter; + on(event: string, listener: Function): NodeJS.EventEmitter; + once(event: string, listener: Function): NodeJS.EventEmitter; + removeListener(event: string, listener: Function): NodeJS.EventEmitter; + removeAllListeners(event?: string): NodeJS.EventEmitter; + setMaxListeners(n: number): void; + listeners(event: string): Function[]; + emit(event: string, ...args: any[]): boolean; } export interface IArgumentConfig { From d4138db108928fa63de369d38c2d30f9ae7e09e6 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 24 Feb 2015 18:43:05 +0100 Subject: [PATCH 089/185] added zip.js def files --- .gitignore | 3 ++ zip.js/zip.js-tests.ts | 43 ++++++++++++++++++++ zip.js/zip.js.d.ts | 92 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 138 insertions(+) create mode 100644 zip.js/zip.js-tests.ts create mode 100644 zip.js/zip.js.d.ts diff --git a/.gitignore b/.gitignore index bbbef0357..71251cf8a 100644 --- a/.gitignore +++ b/.gitignore @@ -32,6 +32,9 @@ _infrastructure/tests/build #rx.js !rx.js +#zip.js +!zip.js + node_modules .sublimets diff --git a/zip.js/zip.js-tests.ts b/zip.js/zip.js-tests.ts new file mode 100644 index 000000000..bacaf1cd6 --- /dev/null +++ b/zip.js/zip.js-tests.ts @@ -0,0 +1,43 @@ +// create the blob object storing the data to compress +var blob = new Blob([ "Lorem ipsum dolor sit amet, consectetuer adipiscing elit..." ], { + type : "text/plain" +}); +// creates a zip storing the file "lorem.txt" with blob as data +// the zip will be stored into a Blob object (zippedBlob) +zipBlob("lorem.txt", blob, function(zippedBlob) { + // unzip the first file from zipped data stored in zippedBlob + unzipBlob(zippedBlob, function(unzippedBlob) { + // logs the uncompressed Blob + console.log(unzippedBlob); + }); +}); + +function zipBlob(filename, blob, callback) { + // use a zip.BlobWriter object to write zipped data into a Blob object + zip.createWriter(new zip.BlobWriter("application/zip"), function(zipWriter) { + // use a BlobReader object to read the data stored into blob variable + zipWriter.add(filename, new zip.BlobReader(blob), function() { + // close the writer and calls callback function + zipWriter.close(callback); + }); + }, onerror); +} + +function unzipBlob(blob, callback) { + // use a zip.BlobReader object to read zipped data stored into blob variable + zip.createReader(new zip.BlobReader(blob), function(zipReader) { + // get entries from the zip file + zipReader.getEntries(function(entries) { + // get data from the first file + entries[0].getData(new zip.BlobWriter("text/plain"), function(data) { + // close the reader and calls callback function with uncompressed data as parameter + zipReader.close(); + callback(data); + }); + }); + }, onerror); +} + +function onerror(message) { + console.error(message); +} \ No newline at end of file diff --git a/zip.js/zip.js.d.ts b/zip.js/zip.js.d.ts new file mode 100644 index 000000000..d134b4a68 --- /dev/null +++ b/zip.js/zip.js.d.ts @@ -0,0 +1,92 @@ +// Type definitions for zip.js 2.x +// Project: https://github.com/gildas-lormeau/zip.js +// Definitions by: Louis Grignon +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module zip { + export var useWebWorkers: boolean; + export var workerScriptsPath: string; + export var workerScripts: { + deflater?: string[]; + inflater?: string[]; + }; + + export class Reader { + public size: number; + public init(callback: () => void, onerror: (error) => void): void; + public readUint8Array(index: number, length: number, callback: (result: Uint8Array) => void, onerror?: (error) => void): void; + } + + export class TextReader extends Reader { + constructor(text: string); + } + + export class BlobReader extends Reader { + constructor(blob: Blob); + } + + export class Data64URIReader extends Reader { + constructor(dataURI: string); + } + + export class HttpReader extends Reader { + constructor(url: string); + } + + export function createReader(reader: zip.Reader, callback: (zipReader: ZipReader) => void, onerror?: (error) => void): void; + + export class ZipReader { + getEntries(callback: (entries: zip.Entry[]) => void); + close(callback: () => void): void; + } + + export interface Entry { + filename: string; + directory: boolean; + compressedSize: number; + uncompressedSize: number; + lastModDate: Date; + lastModDateRaw: number; + comment: string; + crc32: number; + + getData(writer: zip.Writer, onend: (result: any) => void, onprogress?: (progress: number, total: number) => void, checkCrc32?: boolean): void; + } + + export class Writer { + public init(callback: () => void, onerror?: (error) => void): void; + public writeUint8Array(array: Uint8Array, callback: () => void, onerror?: (error) => void): void; + public getData(callback: (data) => void, onerror?: (error) => void); + } + + export class TextWriter extends Writer { + constructor(encoding: string); + } + + export class BlobWriter extends Writer { + constructor(contentType: string); + } + + export class FileWriter extends Writer { + constructor(fileEntry: FileEntry); + } + + export class Data64URIWriter extends Writer { + constructor(mimeString?: string); + } + + export function createWriter(writer: zip.Writer, callback: (zipWriter: zip.ZipWriter) => void, onerror?: (error) => void, dontDeflate?: boolean): void; + + export interface WriteOptions { + directory?: boolean; + level?: number; + comment?: string; + lastModDate?: Date; + version?: number; + } + + export class ZipWriter { + public add(name: string, reader: zip.Reader, onend: () => void, onprogress?: (progress: number, total: number) => void, options?: WriteOptions): void; + public close(callback: (result: any) => void): void; + } +} From b47ae8052e2957fa61c1a45f355ccaecbb32f712 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 24 Feb 2015 18:56:03 +0100 Subject: [PATCH 090/185] fixed implied any --- zip.js/zip.js-tests.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/zip.js/zip.js-tests.ts b/zip.js/zip.js-tests.ts index bacaf1cd6..fa085ca38 100644 --- a/zip.js/zip.js-tests.ts +++ b/zip.js/zip.js-tests.ts @@ -1,18 +1,18 @@ // create the blob object storing the data to compress -var blob = new Blob([ "Lorem ipsum dolor sit amet, consectetuer adipiscing elit..." ], { +var blob: Blob = new Blob([ "Lorem ipsum dolor sit amet, consectetuer adipiscing elit..." ], { type : "text/plain" }); // creates a zip storing the file "lorem.txt" with blob as data // the zip will be stored into a Blob object (zippedBlob) -zipBlob("lorem.txt", blob, function(zippedBlob) { +zipBlob("lorem.txt", blob, function(zippedBlob: Blob) { // unzip the first file from zipped data stored in zippedBlob - unzipBlob(zippedBlob, function(unzippedBlob) { + unzipBlob(zippedBlob, function(unzippedBlob: Blob) { // logs the uncompressed Blob console.log(unzippedBlob); }); }); -function zipBlob(filename, blob, callback) { +function zipBlob(filename: string, blob: Blob, callback: (blob: Blob) => void) { // use a zip.BlobWriter object to write zipped data into a Blob object zip.createWriter(new zip.BlobWriter("application/zip"), function(zipWriter) { // use a BlobReader object to read the data stored into blob variable @@ -20,24 +20,24 @@ function zipBlob(filename, blob, callback) { // close the writer and calls callback function zipWriter.close(callback); }); - }, onerror); + }, theErrorHandler); } -function unzipBlob(blob, callback) { +function unzipBlob(blob: Blob, callback: (unzippedBlob: Blob) => void) { // use a zip.BlobReader object to read zipped data stored into blob variable zip.createReader(new zip.BlobReader(blob), function(zipReader) { // get entries from the zip file - zipReader.getEntries(function(entries) { + zipReader.getEntries(function(entries: zip.Entry[]) { // get data from the first file - entries[0].getData(new zip.BlobWriter("text/plain"), function(data) { + entries[0].getData(new zip.BlobWriter("text/plain"), function(data: Blob) { // close the reader and calls callback function with uncompressed data as parameter zipReader.close(); callback(data); }); }); - }, onerror); + }, theErrorHandler); } -function onerror(message) { +function theErrorHandler(message) { console.error(message); } \ No newline at end of file From c6f2524d663b3605576b9981b18bf1ab996ac999 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 24 Feb 2015 19:05:41 +0100 Subject: [PATCH 091/185] explicit any and add missing returns added FileEntry --- zip.js/zip.js.d.ts | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/zip.js/zip.js.d.ts b/zip.js/zip.js.d.ts index d134b4a68..3c026cd7a 100644 --- a/zip.js/zip.js.d.ts +++ b/zip.js/zip.js.d.ts @@ -3,6 +3,8 @@ // Definitions by: Louis Grignon // Definitions: https://github.com/borisyankov/DefinitelyTyped +interface FileEntry {} + declare module zip { export var useWebWorkers: boolean; export var workerScriptsPath: string; @@ -13,8 +15,8 @@ declare module zip { export class Reader { public size: number; - public init(callback: () => void, onerror: (error) => void): void; - public readUint8Array(index: number, length: number, callback: (result: Uint8Array) => void, onerror?: (error) => void): void; + public init(callback: () => void, onerror: (error: any) => void): void; + public readUint8Array(index: number, length: number, callback: (result: Uint8Array) => void, onerror?: (error: any) => void): void; } export class TextReader extends Reader { @@ -33,11 +35,11 @@ declare module zip { constructor(url: string); } - export function createReader(reader: zip.Reader, callback: (zipReader: ZipReader) => void, onerror?: (error) => void): void; + export function createReader(reader: zip.Reader, callback: (zipReader: ZipReader) => void, onerror?: (error: any) => void): void; export class ZipReader { - getEntries(callback: (entries: zip.Entry[]) => void); - close(callback: () => void): void; + getEntries(callback: (entries: zip.Entry[]) => void): void; + close(callback?: () => void): void; } export interface Entry { @@ -54,9 +56,9 @@ declare module zip { } export class Writer { - public init(callback: () => void, onerror?: (error) => void): void; - public writeUint8Array(array: Uint8Array, callback: () => void, onerror?: (error) => void): void; - public getData(callback: (data) => void, onerror?: (error) => void); + public init(callback: () => void, onerror?: (error: any) => void): void; + public writeUint8Array(array: Uint8Array, callback: () => void, onerror?: (error: any) => void): void; + public getData(callback: (data) => void, onerror?: (error: any) => void) : void; } export class TextWriter extends Writer { @@ -75,7 +77,7 @@ declare module zip { constructor(mimeString?: string); } - export function createWriter(writer: zip.Writer, callback: (zipWriter: zip.ZipWriter) => void, onerror?: (error) => void, dontDeflate?: boolean): void; + export function createWriter(writer: zip.Writer, callback: (zipWriter: zip.ZipWriter) => void, onerror?: (error: any) => void, dontDeflate?: boolean): void; export interface WriteOptions { directory?: boolean; From aebd7dec12bbe71ba544d2673fb6ed1868c4cecd Mon Sep 17 00:00:00 2001 From: Yuki KAN Date: Wed, 25 Feb 2015 07:57:03 +0900 Subject: [PATCH 092/185] Fix many incorrect types of socket.io.d.ts. references: https://github.com/Automattic/socket.io --- socket.io/socket.io.d.ts | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/socket.io/socket.io.d.ts b/socket.io/socket.io.d.ts index 2571e239b..3a37d819a 100644 --- a/socket.io/socket.io.d.ts +++ b/socket.io/socket.io.d.ts @@ -37,19 +37,19 @@ declare module SocketIO { emit(name: string, ...args: any[]): Socket; use(fn: Function): Namespace; - on(event: 'connection', listener: (socket: Socket) => void): any; - on(event: 'connect', listener: (socket: Socket) => void): any; - on(event: string, listener: Function): any; + on(event: 'connection', listener: (socket: Socket) => void): Namespace; + on(event: 'connect', listener: (socket: Socket) => void): Namespace; + on(event: string, listener: Function): Namespace; } interface Namespace extends NodeJS.EventEmitter { name: string; connected: { [id: string]: Socket }; - use(fn: Function): Namespace + use(fn: Function): Namespace; - on(event: 'connection', listener: (socket: Socket) => void): any; - on(event: 'connect', listener: (socket: Socket) => void): any; - on(event: string, listener: Function): any; + on(event: 'connection', listener: (socket: Socket) => void): Namespace; + on(event: 'connect', listener: (socket: Socket) => void): Namespace; + on(event: string, listener: Function): Namespace; } interface Socket { @@ -63,8 +63,13 @@ declare module SocketIO { leave(name: string, fn?: Function): Socket; to(room: string): Socket; in(room: string): Socket; + send(): Socket; + write(): Socket; - on(event: string, listener: Function): any; + on(event: string, listener: Function): Socket; + once(event: string, listener: Function): Socket; + removeListener(event: string, listener: Function): Socket; + removeAllListeners(event: string): Socket; broadcast: Socket; volatile: Socket; connected: boolean; From d1e97f22f325dba2f90523e50260f6ca0d09be3d Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 25 Feb 2015 00:28:03 +0100 Subject: [PATCH 093/185] last any type + reference --- zip.js/zip.js-tests.ts | 4 +++- zip.js/zip.js.d.ts | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/zip.js/zip.js-tests.ts b/zip.js/zip.js-tests.ts index fa085ca38..b00654996 100644 --- a/zip.js/zip.js-tests.ts +++ b/zip.js/zip.js-tests.ts @@ -1,3 +1,5 @@ +/// + // create the blob object storing the data to compress var blob: Blob = new Blob([ "Lorem ipsum dolor sit amet, consectetuer adipiscing elit..." ], { type : "text/plain" @@ -38,6 +40,6 @@ function unzipBlob(blob: Blob, callback: (unzippedBlob: Blob) => void) { }, theErrorHandler); } -function theErrorHandler(message) { +function theErrorHandler(message: any) { console.error(message); } \ No newline at end of file diff --git a/zip.js/zip.js.d.ts b/zip.js/zip.js.d.ts index 3c026cd7a..fa976dca9 100644 --- a/zip.js/zip.js.d.ts +++ b/zip.js/zip.js.d.ts @@ -58,7 +58,7 @@ declare module zip { export class Writer { public init(callback: () => void, onerror?: (error: any) => void): void; public writeUint8Array(array: Uint8Array, callback: () => void, onerror?: (error: any) => void): void; - public getData(callback: (data) => void, onerror?: (error: any) => void) : void; + public getData(callback: (data: any) => void, onerror?: (error: any) => void) : void; } export class TextWriter extends Writer { From c846c315b1159610e9cde500230c10bacd4cfd58 Mon Sep 17 00:00:00 2001 From: Chris Bowdon Date: Wed, 25 Feb 2015 08:13:09 +0800 Subject: [PATCH 094/185] Add defs for Chance.js --- chance/chance-tests.ts | 36 +++++++ chance/chance.d.ts | 213 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 249 insertions(+) create mode 100644 chance/chance-tests.ts create mode 100644 chance/chance.d.ts diff --git a/chance/chance-tests.ts b/chance/chance-tests.ts new file mode 100644 index 000000000..5a2aa9a9c --- /dev/null +++ b/chance/chance-tests.ts @@ -0,0 +1,36 @@ +/// + +// Instantiation +var globalInstance: Chance.Chance = chance; +var createYourOwn = new Chance(Math.random); + +// Basic usage +var randBool: boolean = chance.bool(); + +var birthday: Date = chance.birthday(); +var birthdayStr: Date|string = chance.birthday({ string: true }); + +var strArr: string[] = chance.n(chance.string, 42); + +var uniqInts: number[] = chance.unique(chance.integer, 99); + +var currencyPair = chance.currency_pair(); +var firstCurrency = currencyPair[0]; +var secondCurrency = currencyPair[1]; + +// Mixins can be used with on-the-fly type declaration +declare module Chance { + interface Chance { + time(): string; + } +} + +chance.mixin({ + time: function () { + var h = chance.hour({ twentyfour: true }), + m = chance.minute(); + return `${h}:${m}`; + } +}); + +var timeString: string = chance.time(); diff --git a/chance/chance.d.ts b/chance/chance.d.ts new file mode 100644 index 000000000..2af960efe --- /dev/null +++ b/chance/chance.d.ts @@ -0,0 +1,213 @@ +// Type definitions for Chance 0.7.3 +// Project: http://chancejs.com +// Definitions by: Chris Bowdon +// Definitions: https://github.com/borisyankov/DefinitelyTyped +declare module Chance { + + interface ChanceStatic { + Chance(): Chance; + new(): Chance; + new(seed: number): Chance; + new(generator: () => any): Chance; + } + + interface Chance { + + // Basics + bool(opts?: Options): boolean; + character(opts?: Options): string; + floating(opts?: Options): number; + integer(opts?: Options): number; + natural(opts?: Options): number; + string(opts?: Options): string; + + // Text + paragraph(opts?: Options): string; + sentence(opts?: Options): string; + syllable(opts?: Options): string; + word(opts?: Options): string; + + // Person + age(opts?: Options): number; + birthday(): Date; + birthday(opts?: Options): Date|string; + cpf(): string; + first(opts?: Options): string; + last(opts?: Options): string; + name(opts?: Options): string; + name_prefix(opts?: Options): string; + name_suffix(opts?: Options): string; + prefix(opts?: Options): string; + ssn(opts?: Options): string; + suffix(opts?: Options): string; + + // Mobile + android_id(): string; + apple_token(): string; + bb_pin(): string; + wp7_anid(): string; + wp8_anid2(): string; + + // Web + color(opts?: Options): string; + domain(opts?: Options): string; + email(opts?: Options): string; + fbid(): string; + google_analytics(): string; + hashtag(): string; + ip(): string; + ipv6(): string; + klout(): string; + tld(): string; + twitter(): string; + url(opts?: Options): string; + + // Location + address(opts?: Options): string; + altitude(opts?: Options): number; + areacode(): string; + city(): string; + coordinates(opts?: Options): string; + country(opts?: Options): string; + depth(opts?: Options): number; + geohash(opts?: Options): string; + latitude(opts?: Options): number; + longitude(opts?: Options): number; + phone(opts?: Options): string; + postal(): string; + province(opts?: Options): string; + state(opts?: Options): string; + street(opts?: Options): string; + zip(opts?: Options): string; + + // Time + ampm(): string; + date(): Date; + date(opts: DateOptions): Date|string; + hammertime(): number; + hour(opts?: Options): number; + millisecond(): number; + minute(): number; + month(): string; + month(opts: Options): Month; + second(): number; + timestamp(): number; + year(opts?: Options): string; + + // Finance + cc(opts?: Options): string; + cc_type(): string; + cc_type(opts: Options): string|CreditCardType; + currency(): Currency; + currency_pair(): [ Currency, Currency ]; + dollar(opts?: Options): string; + exp(): string; + exp(opts: Options): string|CreditCardExpiration; + exp_month(opts?: Options): string; + exp_year(opts?: Options): string; + + // Helpers + capitalize(str: string): string; + mixin(desc: MixinDescriptor): any; + pad(num: number, width: number, padChar?: string): string; + pick(arr: T[]): T; + pick(arr: T[], count: number): T[]; + set: Setter; + shuffle(arr: T[]): T[]; + + // Miscellaneous + d4(): number; + d6(): number; + d8(): number; + d10(): number; + d12(): number; + d20(): number; + d30(): number; + d100(): number; + guid(): string; + hash(opts?: Options): string; + n(generator: () => T, count: number, opts?: Options): T[]; + normal(opts?: Options): string; + radio(opts?: Options): string; + rpg(dice: string): number[]; + rpg(dice: string, opts?: Options): number[]|number; + tv(opts?: Options): string; + unique(generator: () => T, count: number, opts?: Options): T[]; + weighted(values: T[], weights: number[]): T; + + // "Hidden" + cc_types(): CreditCardType[]; + mersenne_twister(seed?: number): any; // API return type not defined in docs + months(): Month[]; + name_prefixes(): Name[]; + provinces(): Name[]; + states(): Name[]; + street_suffix(): Name; + street_suffixes(): Name[]; + } + + // A more rigorous approach might be to produce + // the correct options interfaces for each method + interface Options { [id: string]: any; } + + interface DateOptions { + string?: boolean; + american?: boolean; + year?: number; + month?: number; + day?: number; + } + + interface Month { + name: string; + short_name: string; + numeric: string; + } + + interface CreditCardType { + name: string; + short_name: string; + prefix: string; + length: number; + } + + interface Currency { + code: string; + name: string; + } + + interface CreditCardExpiration { + month: string; + year: string; + } + + interface MixinDescriptor { [id: string]: () => any; } + + interface Setter { + (key: 'firstNames', values: string[]): any; + (key: 'lastNames', values: string[]): any; + (key: 'provinces', values: string[]): any; + (key: 'us_states_and_dc', values: string[]): any; + (key: 'territories', values: string[]): any; + (key: 'armed_forces', values: string[]): any; + (key: 'street_suffixes', values: string[]): any; + (key: 'months', values: string[]): any; + (key: 'cc_types', values: string[]): any; + (key: 'currency_types', values: string[]): any; + (key: string, values: T[]): any; + } + + interface Name { + name: string; + abbreviation: string; + } +} + +// window.chance +declare var chance: Chance.Chance; +declare var Chance: Chance.ChanceStatic; + +// import Chance = require('chance'); +declare module 'chance' { + export = Chance; +} From 24991f93983dcd7b9004001583b74978114e3afd Mon Sep 17 00:00:00 2001 From: Yuki KAN Date: Wed, 25 Feb 2015 10:05:33 +0900 Subject: [PATCH 095/185] Fix socket.io.d.ts: argument of send(), write() oops --- socket.io/socket.io.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/socket.io/socket.io.d.ts b/socket.io/socket.io.d.ts index 3a37d819a..677d4fcc2 100644 --- a/socket.io/socket.io.d.ts +++ b/socket.io/socket.io.d.ts @@ -63,8 +63,8 @@ declare module SocketIO { leave(name: string, fn?: Function): Socket; to(room: string): Socket; in(room: string): Socket; - send(): Socket; - write(): Socket; + send(...args: any[]): Socket; + write(...args: any[]): Socket; on(event: string, listener: Function): Socket; once(event: string, listener: Function): Socket; From 70779548d5352f88f1a96b4512ca5e8d37aba71b Mon Sep 17 00:00:00 2001 From: Vincent Siao Date: Tue, 24 Feb 2015 17:18:58 -0800 Subject: [PATCH 096/185] Remove Context generics from React 0.13 defs --- react/future/react-0.13.0-tests.ts | 18 +-- react/future/react-0.13.0.d.ts | 66 +++++----- react/future/react-addons-0.13.0-tests.ts | 18 +-- react/future/react-addons-0.13.0.d.ts | 128 +++++++++---------- react/future/react-addons-global-0.13.0.d.ts | 62 ++++----- react/future/react-global-0.13.0.d.ts | 66 +++++----- 6 files changed, 179 insertions(+), 179 deletions(-) diff --git a/react/future/react-0.13.0-tests.ts b/react/future/react-0.13.0-tests.ts index dd0052ee3..b32356119 100644 --- a/react/future/react-0.13.0-tests.ts +++ b/react/future/react-0.13.0-tests.ts @@ -23,7 +23,7 @@ interface ChildContext { someOtherValue: string; } -interface MyComponent extends React.Component { +interface MyComponent extends React.Component { reset(): void; } @@ -42,8 +42,8 @@ var INPUT_REF: string = "input"; // Top-Level API // -------------------------------------------------------------------------- -var ClassicComponent: React.ClassicComponentClass = - React.createClass({ +var ClassicComponent: React.ClassicComponentClass = + React.createClass({ getDefaultProps: () => { return { hello: undefined, @@ -70,7 +70,7 @@ var ClassicComponent: React.ClassicComponentClass = } }); -class ModernComponent extends React.Component +class ModernComponent extends React.Component implements React.ChildContextProvider { constructor(props: Props, context: Context) { @@ -145,9 +145,9 @@ var domElement: React.ReactHTMLElement = React.createElement("div"); // React.render -var component: React.Component = +var component: React.Component = React.render(element, container); -var classicComponent: React.ClassicComponent = +var classicComponent: React.ClassicComponent = React.render(classicElement, container); var domComponent: React.DOMComponent = React.render(domElement, container); @@ -234,7 +234,7 @@ React.DOM.input(htmlAttr); // React.PropTypes // -------------------------------------------------------------------------- -var PropTypesSpecification: React.ComponentSpec = { +var PropTypesSpecification: React.ComponentSpec = { propTypes: { optionalArray: React.PropTypes.array, optionalBool: React.PropTypes.bool, @@ -275,7 +275,7 @@ var PropTypesSpecification: React.ComponentSpec = { // ContextTypes // -------------------------------------------------------------------------- -var ContextTypesSpecification: React.ComponentSpec = { +var ContextTypesSpecification: React.ComponentSpec = { contextTypes: { optionalArray: React.PropTypes.array, optionalBool: React.PropTypes.bool, @@ -329,7 +329,7 @@ var onlyChild = React.Children.only([null, [[["Hallo"], true]], false]); interface TimerState { secondsElapsed: number; } -class Timer extends React.Component<{}, TimerState, {}> { +class Timer extends React.Component<{}, TimerState> { static state = { secondsElapsed: 0 } diff --git a/react/future/react-0.13.0.d.ts b/react/future/react-0.13.0.d.ts index 842623bc8..fd4b27e98 100644 --- a/react/future/react-0.13.0.d.ts +++ b/react/future/react-0.13.0.d.ts @@ -16,10 +16,10 @@ declare module "react" { } interface ReactElement

- extends ReactElementBase, P> {} + extends ReactElementBase, P> {} interface ReactClassicElement

- extends ReactElementBase | string, P> {} + extends ReactElementBase | string, P> {} interface ReactDOMElement

// subtype of ReactClassicElement extends ReactElementBase {} @@ -62,26 +62,26 @@ declare module "react" { // Top Level API // ---------------------------------------------------------------------- - function createClass( - spec: ComponentSpec): ClassicComponentClass; + function createClass( + spec: ComponentSpec): ClassicComponentClass; function createFactory

( type: string): DOMFactory

; function createFactory

( - type: ClassicComponentClass | string): ClassicFactory

; + type: ClassicComponentClass | string): ClassicFactory

; function createFactory

( - type: ComponentClass): Factory

; + type: ComponentClass): Factory

; function createElement

( type: string, props?: P, ...children: ReactNode[]): ReactDOMElement

; function createElement

( - type: ClassicComponentClass | string, + type: ClassicComponentClass | string, props?: P, ...children: ReactNode[]): ReactClassicElement

; function createElement

( - type: ComponentClass, + type: ComponentClass, props?: P, ...children: ReactNode[]): ReactElement

; @@ -92,11 +92,11 @@ declare module "react" { function render( element: ReactClassicElement

, container: Element, - callback?: () => any): ClassicComponent; + callback?: () => any): ClassicComponent; function render( element: ReactElement

, container: Element, - callback?: () => any): Component; + callback?: () => any): Component; function unmountComponentAtNode(container: Element): boolean; function renderToString(element: ReactElementBase): string; @@ -105,9 +105,9 @@ declare module "react" { function initializeTouchEvents(shouldUseTouch: boolean): void; function findDOMNode( - componentOrElement: Component | Element): TElement; + componentOrElement: Component | Element): TElement; function findDOMNode( - componentOrElement: Component | Element): Element; + componentOrElement: Component | Element): Element; var DOM: ReactDOM; var PropTypes: ReactPropTypes; @@ -118,19 +118,19 @@ declare module "react" { // ---------------------------------------------------------------------- // Base component for plain JS classes - class Component implements ComponentLifecycle { - constructor(props: P, context: C); + class Component implements ComponentLifecycle { + constructor(props: P, context: any); setState(state: S, callback?: () => any): void; forceUpdate(): void; props: P; state: S; - context: C; + context: any; refs: { - [key: string]: Component + [key: string]: Component }; } - interface ClassicComponent extends Component { + interface ClassicComponent extends Component { replaceState(nextState: S, callback?: () => any): void; getDOMNode(): TElement; getDOMNode(): Element; @@ -140,7 +140,7 @@ declare module "react" { replaceProps(nextProps: P, callback?: () => any): void; } - interface DOMComponent

extends ClassicComponent { + interface DOMComponent

extends ClassicComponent { tagName: string; } @@ -155,19 +155,19 @@ declare module "react" { // Class Interfaces // ---------------------------------------------------------------------- - interface ComponentClassBase { + interface ComponentClassBase

{ propTypes?: ValidationMap

; - contextTypes?: ValidationMap; - childContextTypes?: ValidationMap<{}>; + contextTypes?: ValidationMap; + childContextTypes?: ValidationMap; } - interface ComponentClass extends ComponentClassBase { - new(props?: P, context?: C): Component; + interface ComponentClass extends ComponentClassBase

{ + new(props?: P, context?: any): Component; defaultProps?: P; } - interface ClassicComponentClass extends ComponentClassBase { - new(props?: P, context?: C): ClassicComponent; + interface ClassicComponentClass extends ComponentClassBase

{ + new(props?: P, context?: any): ClassicComponent; getDefaultProps?(): P; displayName?: string; } @@ -176,18 +176,18 @@ declare module "react" { // Component Specs and Lifecycle // ---------------------------------------------------------------------- - interface ComponentLifecycle { + interface ComponentLifecycle { componentWillMount?(): void; componentDidMount?(): void; - componentWillReceiveProps?(nextProps: P, nextContext: C): void; - shouldComponentUpdate?(nextProps: P, nextState: S, nextContext: C): boolean; - componentWillUpdate?(nextProps: P, nextState: S, nextContext: C): void; - componentDidUpdate?(prevProps: P, prevState: S, prevContext: C): void; + componentWillReceiveProps?(nextProps: P, nextContext: any): void; + shouldComponentUpdate?(nextProps: P, nextState: S, nextContext: any): boolean; + componentWillUpdate?(nextProps: P, nextState: S, nextContext: any): void; + componentDidUpdate?(prevProps: P, prevState: S, prevContext: any): void; componentWillUnmount?(): void; } - interface Mixin extends ComponentLifecycle { - mixins?: Mixin; + interface Mixin extends ComponentLifecycle { + mixins?: Mixin; statics?: { [key: string]: any; }; @@ -201,7 +201,7 @@ declare module "react" { getDefaultProps?(): P; } - interface ComponentSpec extends Mixin { + interface ComponentSpec extends Mixin { render(): ReactElementBase; } diff --git a/react/future/react-addons-0.13.0-tests.ts b/react/future/react-addons-0.13.0-tests.ts index a1be24add..d76097cd6 100644 --- a/react/future/react-addons-0.13.0-tests.ts +++ b/react/future/react-addons-0.13.0-tests.ts @@ -21,7 +21,7 @@ interface ChildContext { someOtherValue: string; } -interface MyComponent extends React.Component { +interface MyComponent extends React.Component { reset(): void; } @@ -40,8 +40,8 @@ var INPUT_REF: string = "input"; // Top-Level API // -------------------------------------------------------------------------- -var ClassicComponent: React.ClassicComponentClass = - React.createClass({ +var ClassicComponent: React.ClassicComponentClass = + React.createClass({ getDefaultProps: () => { return { hello: undefined, @@ -68,7 +68,7 @@ var ClassicComponent: React.ClassicComponentClass = } }); -class ModernComponent extends React.Component +class ModernComponent extends React.Component implements React.ChildContextProvider { constructor(props: Props, context: Context) { @@ -143,9 +143,9 @@ var domElement: React.ReactHTMLElement = React.createElement("div"); // React.render -var component: React.Component = +var component: React.Component = React.render(element, container); -var classicComponent: React.ClassicComponent = +var classicComponent: React.ClassicComponent = React.render(classicElement, container); var domComponent: React.DOMComponent = React.render(domElement, container); @@ -232,7 +232,7 @@ React.DOM.input(htmlAttr); // React.PropTypes // -------------------------------------------------------------------------- -var PropTypesSpecification: React.ComponentSpec = { +var PropTypesSpecification: React.ComponentSpec = { propTypes: { optionalArray: React.PropTypes.array, optionalBool: React.PropTypes.bool, @@ -273,7 +273,7 @@ var PropTypesSpecification: React.ComponentSpec = { // ContextTypes // -------------------------------------------------------------------------- -var ContextTypesSpecification: React.ComponentSpec = { +var ContextTypesSpecification: React.ComponentSpec = { contextTypes: { optionalArray: React.PropTypes.array, optionalBool: React.PropTypes.bool, @@ -327,7 +327,7 @@ var onlyChild = React.Children.only([null, [[["Hallo"], true]], false]); interface TimerState { secondsElapsed: number; } -class Timer extends React.Component<{}, TimerState, {}> { +class Timer extends React.Component<{}, TimerState> { static state = { secondsElapsed: 0 } diff --git a/react/future/react-addons-0.13.0.d.ts b/react/future/react-addons-0.13.0.d.ts index dd06aa1e9..bb4af1d1e 100644 --- a/react/future/react-addons-0.13.0.d.ts +++ b/react/future/react-addons-0.13.0.d.ts @@ -16,10 +16,10 @@ declare module "react/addons" { } interface ReactElement

- extends ReactElementBase, P> {} + extends ReactElementBase, P> {} interface ReactClassicElement

- extends ReactElementBase | string, P> {} + extends ReactElementBase | string, P> {} interface ReactDOMElement

// subtype of ReactClassicElement extends ReactElementBase {} @@ -62,26 +62,26 @@ declare module "react/addons" { // Top Level API // ---------------------------------------------------------------------- - function createClass( - spec: ComponentSpec): ClassicComponentClass; + function createClass( + spec: ComponentSpec): ClassicComponentClass; function createFactory

( type: string): DOMFactory

; function createFactory

( - type: ClassicComponentClass | string): ClassicFactory

; + type: ClassicComponentClass | string): ClassicFactory

; function createFactory

( - type: ComponentClass): Factory

; + type: ComponentClass): Factory

; function createElement

( type: string, props?: P, ...children: ReactNode[]): ReactDOMElement

; function createElement

( - type: ClassicComponentClass | string, + type: ClassicComponentClass | string, props?: P, ...children: ReactNode[]): ReactClassicElement

; function createElement

( - type: ComponentClass, + type: ComponentClass, props?: P, ...children: ReactNode[]): ReactElement

; @@ -92,11 +92,11 @@ declare module "react/addons" { function render( element: ReactClassicElement

, container: Element, - callback?: () => any): ClassicComponent; + callback?: () => any): ClassicComponent; function render( element: ReactElement

, container: Element, - callback?: () => any): Component; + callback?: () => any): Component; function unmountComponentAtNode(container: Element): boolean; function renderToString(element: ReactElementBase): string; @@ -105,9 +105,9 @@ declare module "react/addons" { function initializeTouchEvents(shouldUseTouch: boolean): void; function findDOMNode( - componentOrElement: Component | Element): TElement; + componentOrElement: Component | Element): TElement; function findDOMNode( - componentOrElement: Component | Element): Element; + componentOrElement: Component | Element): Element; var DOM: ReactDOM; var PropTypes: ReactPropTypes; @@ -118,19 +118,19 @@ declare module "react/addons" { // ---------------------------------------------------------------------- // Base component for plain JS classes - class Component implements ComponentLifecycle { - constructor(props: P, context: C); + class Component implements ComponentLifecycle { + constructor(props: P, context: any); setState(state: S, callback?: () => any): void; forceUpdate(): void; props: P; state: S; - context: C; + context: any; refs: { - [key: string]: Component + [key: string]: Component }; } - interface ClassicComponent extends Component { + interface ClassicComponent extends Component { replaceState(nextState: S, callback?: () => any): void; getDOMNode(): TElement; getDOMNode(): Element; @@ -140,7 +140,7 @@ declare module "react/addons" { replaceProps(nextProps: P, callback?: () => any): void; } - interface DOMComponent

extends ClassicComponent { + interface DOMComponent

extends ClassicComponent { tagName: string; } @@ -155,19 +155,19 @@ declare module "react/addons" { // Class Interfaces // ---------------------------------------------------------------------- - interface ComponentClassBase { + interface ComponentClassBase

{ propTypes?: ValidationMap

; - contextTypes?: ValidationMap; - childContextTypes?: ValidationMap<{}>; + contextTypes?: ValidationMap; + childContextTypes?: ValidationMap; } - interface ComponentClass extends ComponentClassBase { - new(props?: P, context?: C): Component; + interface ComponentClass extends ComponentClassBase

{ + new(props?: P, context?: any): Component; defaultProps?: P; } - interface ClassicComponentClass extends ComponentClassBase { - new(props?: P, context?: C): ClassicComponent; + interface ClassicComponentClass extends ComponentClassBase

{ + new(props?: P, context?: any): ClassicComponent; getDefaultProps?(): P; displayName?: string; } @@ -176,18 +176,18 @@ declare module "react/addons" { // Component Specs and Lifecycle // ---------------------------------------------------------------------- - interface ComponentLifecycle { + interface ComponentLifecycle { componentWillMount?(): void; componentDidMount?(): void; - componentWillReceiveProps?(nextProps: P, nextContext: C): void; - shouldComponentUpdate?(nextProps: P, nextState: S, nextContext: C): boolean; - componentWillUpdate?(nextProps: P, nextState: S, nextContext: C): void; - componentDidUpdate?(prevProps: P, prevState: S, prevContext: C): void; + componentWillReceiveProps?(nextProps: P, nextContext: any): void; + shouldComponentUpdate?(nextProps: P, nextState: S, nextContext: any): boolean; + componentWillUpdate?(nextProps: P, nextState: S, nextContext: any): void; + componentDidUpdate?(prevProps: P, prevState: S, prevContext: any): void; componentWillUnmount?(): void; } - interface Mixin extends ComponentLifecycle { - mixins?: Mixin; + interface Mixin extends ComponentLifecycle { + mixins?: Mixin; statics?: { [key: string]: any; }; @@ -201,7 +201,7 @@ declare module "react/addons" { getDefaultProps?(): P; } - interface ComponentSpec extends Mixin { + interface ComponentSpec extends Mixin { render(): ReactElementBase; } @@ -748,7 +748,7 @@ declare module "react/addons" { // React.addons (Transitions) // ---------------------------------------------------------------------- - type ReactType = ComponentClass | string; + type ReactType = ComponentClass | string; interface TransitionGroupProps { component?: ReactType; @@ -763,9 +763,9 @@ declare module "react/addons" { } type CSSTransitionGroup = - ComponentClass; + ComponentClass; type TransitionGroup = - ComponentClass; + ComponentClass; // // React.addons (Mixins) @@ -776,11 +776,11 @@ declare module "react/addons" { requestChange(newValue: T): void; } - interface LinkedStateMixin extends Mixin { + interface LinkedStateMixin extends Mixin { linkState(key: string): ReactLink; } - interface PureRenderMixin extends Mixin { + interface PureRenderMixin extends Mixin { } // @@ -846,50 +846,50 @@ declare module "react/addons" { interface ReactTestUtils { Simulate: Simulate; - renderIntoDocument

(element: ReactElement

): Component; - renderIntoDocument>(element: ReactElement): C; + renderIntoDocument

(element: ReactElement

): Component; + renderIntoDocument>(element: ReactElement): C; mockComponent(mocked: MockedComponentClass, mockTagName?: string): ReactTestUtils; isElementOfType(element: ReactElement, type: ReactType): boolean; - isTextComponent(instance: Component): boolean; - isDOMComponent(instance: Component): boolean; - isCompositeComponent(instance: Component): boolean; + isTextComponent(instance: Component): boolean; + isDOMComponent(instance: Component): boolean; + isCompositeComponent(instance: Component): boolean; isCompositeComponentWithType( - instance: Component, - type: ComponentClass): boolean; + instance: Component, + type: ComponentClass): boolean; findAllInRenderedTree( - tree: Component, - fn: (i: Component) => boolean): Component; + tree: Component, + fn: (i: Component) => boolean): Component; scryRenderedDOMComponentsWithClass( - tree: Component, + tree: Component, className: string): DOMComponent[]; findRenderedDOMComponentWithClass( - tree: Component, + tree: Component, className: string): DOMComponent; scryRenderedDOMComponentsWithTag( - tree: Component, + tree: Component, tagName: string): DOMComponent[]; findRenderedDOMComponentWithTag( - tree: Component, + tree: Component, tagName: string): DOMComponent; - scryRenderedComponentsWithType( - tree: Component, - type: ComponentClass): Component[]; - scryRenderedComponentsWithType>( - tree: Component, - type: ComponentClass): C[]; + scryRenderedComponentsWithType( + tree: Component, + type: ComponentClass): Component[]; + scryRenderedComponentsWithType>( + tree: Component, + type: ComponentClass): C[]; - findRenderedComponentWithType( - tree: Component, - type: ComponentClass): Component; - findRenderedComponentWithType>( - tree: Component, - type: ComponentClass): C; + findRenderedComponentWithType( + tree: Component, + type: ComponentClass): Component; + findRenderedComponentWithType>( + tree: Component, + type: ComponentClass): C; } interface SyntheticEventData { @@ -928,7 +928,7 @@ declare module "react/addons" { interface EventSimulator { (element: Element, eventData?: SyntheticEventData): void; - (descriptor: Component, eventData?: SyntheticEventData): void; + (component: Component, eventData?: SyntheticEventData): void; } interface Simulate { diff --git a/react/future/react-addons-global-0.13.0.d.ts b/react/future/react-addons-global-0.13.0.d.ts index 733ba54a5..d11a4ae03 100644 --- a/react/future/react-addons-global-0.13.0.d.ts +++ b/react/future/react-addons-global-0.13.0.d.ts @@ -37,7 +37,7 @@ declare module React { // React.addons (Transitions) // ---------------------------------------------------------------------- - type ReactType = ComponentClass | string; + type ReactType = ComponentClass | string; interface TransitionGroupProps { component?: ReactType; @@ -52,9 +52,9 @@ declare module React { } type CSSTransitionGroup = - ComponentClass; + ComponentClass; type TransitionGroup = - ComponentClass; + ComponentClass; // // React.addons (Mixins) @@ -65,11 +65,11 @@ declare module React { requestChange(newValue: T): void; } - interface LinkedStateMixin extends Mixin { + interface LinkedStateMixin extends Mixin { linkState(key: string): ReactLink; } - interface PureRenderMixin extends Mixin { + interface PureRenderMixin extends Mixin { } // @@ -135,50 +135,50 @@ declare module React { interface ReactTestUtils { Simulate: Simulate; - renderIntoDocument

(element: ReactElement

): Component; - renderIntoDocument>(element: ReactElement): C; + renderIntoDocument

(element: ReactElement

): Component; + renderIntoDocument>(element: ReactElement): C; mockComponent(mocked: MockedComponentClass, mockTagName?: string): ReactTestUtils; isElementOfType(element: ReactElement, type: ReactType): boolean; - isTextComponent(instance: Component): boolean; - isDOMComponent(instance: Component): boolean; - isCompositeComponent(instance: Component): boolean; + isTextComponent(instance: Component): boolean; + isDOMComponent(instance: Component): boolean; + isCompositeComponent(instance: Component): boolean; isCompositeComponentWithType( - instance: Component, - type: ComponentClass): boolean; + instance: Component, + type: ComponentClass): boolean; findAllInRenderedTree( - tree: Component, - fn: (i: Component) => boolean): Component; + tree: Component, + fn: (i: Component) => boolean): Component; scryRenderedDOMComponentsWithClass( - tree: Component, + tree: Component, className: string): DOMComponent[]; findRenderedDOMComponentWithClass( - tree: Component, + tree: Component, className: string): DOMComponent; scryRenderedDOMComponentsWithTag( - tree: Component, + tree: Component, tagName: string): DOMComponent[]; findRenderedDOMComponentWithTag( - tree: Component, + tree: Component, tagName: string): DOMComponent; - scryRenderedComponentsWithType( - tree: Component, - type: ComponentClass): Component[]; - scryRenderedComponentsWithType>( - tree: Component, - type: ComponentClass): C[]; + scryRenderedComponentsWithType( + tree: Component, + type: ComponentClass): Component[]; + scryRenderedComponentsWithType>( + tree: Component, + type: ComponentClass): C[]; - findRenderedComponentWithType( - tree: Component, - type: ComponentClass): Component; - findRenderedComponentWithType>( - tree: Component, - type: ComponentClass): C; + findRenderedComponentWithType( + tree: Component, + type: ComponentClass): Component; + findRenderedComponentWithType>( + tree: Component, + type: ComponentClass): C; } interface SyntheticEventData { @@ -217,7 +217,7 @@ declare module React { interface EventSimulator { (element: Element, eventData?: SyntheticEventData): void; - (descriptor: Component, eventData?: SyntheticEventData): void; + (component: Component, eventData?: SyntheticEventData): void; } interface Simulate { diff --git a/react/future/react-global-0.13.0.d.ts b/react/future/react-global-0.13.0.d.ts index 996d09d3a..60675aec9 100644 --- a/react/future/react-global-0.13.0.d.ts +++ b/react/future/react-global-0.13.0.d.ts @@ -16,10 +16,10 @@ declare module React { } interface ReactElement

- extends ReactElementBase, P> {} + extends ReactElementBase, P> {} interface ReactClassicElement

- extends ReactElementBase | string, P> {} + extends ReactElementBase | string, P> {} interface ReactDOMElement

// subtype of ReactClassicElement extends ReactElementBase {} @@ -62,26 +62,26 @@ declare module React { // Top Level API // ---------------------------------------------------------------------- - function createClass( - spec: ComponentSpec): ClassicComponentClass; + function createClass( + spec: ComponentSpec): ClassicComponentClass; function createFactory

( type: string): DOMFactory

; function createFactory

( - type: ClassicComponentClass | string): ClassicFactory

; + type: ClassicComponentClass | string): ClassicFactory

; function createFactory

( - type: ComponentClass): Factory

; + type: ComponentClass): Factory

; function createElement

( type: string, props?: P, ...children: ReactNode[]): ReactDOMElement

; function createElement

( - type: ClassicComponentClass | string, + type: ClassicComponentClass | string, props?: P, ...children: ReactNode[]): ReactClassicElement

; function createElement

( - type: ComponentClass, + type: ComponentClass, props?: P, ...children: ReactNode[]): ReactElement

; @@ -92,11 +92,11 @@ declare module React { function render( element: ReactClassicElement

, container: Element, - callback?: () => any): ClassicComponent; + callback?: () => any): ClassicComponent; function render( element: ReactElement

, container: Element, - callback?: () => any): Component; + callback?: () => any): Component; function unmountComponentAtNode(container: Element): boolean; function renderToString(element: ReactElementBase): string; @@ -105,9 +105,9 @@ declare module React { function initializeTouchEvents(shouldUseTouch: boolean): void; function findDOMNode( - componentOrElement: Component | Element): TElement; + componentOrElement: Component | Element): TElement; function findDOMNode( - componentOrElement: Component | Element): Element; + componentOrElement: Component | Element): Element; var DOM: ReactDOM; var PropTypes: ReactPropTypes; @@ -118,19 +118,19 @@ declare module React { // ---------------------------------------------------------------------- // Base component for plain JS classes - class Component implements ComponentLifecycle { - constructor(props: P, context: C); + class Component implements ComponentLifecycle { + constructor(props: P, context: any); setState(state: S, callback?: () => any): void; forceUpdate(): void; props: P; state: S; - context: C; + context: any; refs: { - [key: string]: Component + [key: string]: Component }; } - interface ClassicComponent extends Component { + interface ClassicComponent extends Component { replaceState(nextState: S, callback?: () => any): void; getDOMNode(): TElement; getDOMNode(): Element; @@ -140,7 +140,7 @@ declare module React { replaceProps(nextProps: P, callback?: () => any): void; } - interface DOMComponent

extends ClassicComponent { + interface DOMComponent

extends ClassicComponent { tagName: string; } @@ -155,19 +155,19 @@ declare module React { // Class Interfaces // ---------------------------------------------------------------------- - interface ComponentClassBase { + interface ComponentClassBase

{ propTypes?: ValidationMap

; - contextTypes?: ValidationMap; - childContextTypes?: ValidationMap<{}>; + contextTypes?: ValidationMap; + childContextTypes?: ValidationMap; } - interface ComponentClass extends ComponentClassBase { - new(props?: P, context?: C): Component; + interface ComponentClass extends ComponentClassBase

{ + new(props?: P, context?: any): Component; defaultProps?: P; } - interface ClassicComponentClass extends ComponentClassBase { - new(props?: P, context?: C): ClassicComponent; + interface ClassicComponentClass extends ComponentClassBase

{ + new(props?: P, context?: any): ClassicComponent; getDefaultProps?(): P; displayName?: string; } @@ -176,18 +176,18 @@ declare module React { // Component Specs and Lifecycle // ---------------------------------------------------------------------- - interface ComponentLifecycle { + interface ComponentLifecycle { componentWillMount?(): void; componentDidMount?(): void; - componentWillReceiveProps?(nextProps: P, nextContext: C): void; - shouldComponentUpdate?(nextProps: P, nextState: S, nextContext: C): boolean; - componentWillUpdate?(nextProps: P, nextState: S, nextContext: C): void; - componentDidUpdate?(prevProps: P, prevState: S, prevContext: C): void; + componentWillReceiveProps?(nextProps: P, nextContext: any): void; + shouldComponentUpdate?(nextProps: P, nextState: S, nextContext: any): boolean; + componentWillUpdate?(nextProps: P, nextState: S, nextContext: any): void; + componentDidUpdate?(prevProps: P, prevState: S, prevContext: any): void; componentWillUnmount?(): void; } - interface Mixin extends ComponentLifecycle { - mixins?: Mixin; + interface Mixin extends ComponentLifecycle { + mixins?: Mixin; statics?: { [key: string]: any; }; @@ -201,7 +201,7 @@ declare module React { getDefaultProps?(): P; } - interface ComponentSpec extends Mixin { + interface ComponentSpec extends Mixin { render(): ReactElementBase; } From d4460ea9416b21c08bdc894dc81f2142250e1de1 Mon Sep 17 00:00:00 2001 From: David Gardiner Date: Thu, 15 Jan 2015 12:02:30 +1030 Subject: [PATCH 097/185] Missing methods and optional arguments --- ember/ember.d.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ember/ember.d.ts b/ember/ember.d.ts index b6cdde9d6..a599782f9 100644 --- a/ember/ember.d.ts +++ b/ember/ember.d.ts @@ -88,16 +88,17 @@ interface Array { every(callback: Function, target?: any): boolean; everyBy(key: string, value?: string): boolean; everyProperty(key: string, value?: any): boolean; - filter(callback: Function, target: any): any[]; + filter(callback: Function, target?: any): any[]; filterBy(key: string, value?: string): any[]; - find(callback: Function, target: any): any; + find(callback: Function, target?: any): any; findBy(key: string, value?: string): any; forEach(callback: Function, target?: any): any; getEach(key: string): any[]; - indexOf(object: any, startAt: number): number; + indexOf(object: any, startAt?: number): number; insertAt(idx: number, object: any): any[]; invoke(methodName: string, ...args: any[]): any[]; - lastIndexOf(object: any, startAt: number): number; + lastIndexOf(object: any, startAt?: number): number; + map(callback: Function, target?: any): any[]; mapBy(key: string): any[]; nextObject(index: number, previousObject: any, context: any): any; objectAt(idx: number): any; @@ -154,6 +155,9 @@ interface Array { toggleProperty(keyName: string): any; copy(deep: boolean): any[]; frozenCopy(): any[]; + // 1.3 + isAny(key: string, value?: string): boolean; + isEvery(key: string, value?: string): boolean; } interface ApplicationCreateArguments { From ad18fda593e59d74a80f2ffc36a8501fb9f83547 Mon Sep 17 00:00:00 2001 From: David Gardiner Date: Wed, 21 Jan 2015 10:44:13 +1030 Subject: [PATCH 098/185] jsdocs for find() Optional arguments for find() and Handlebars.helper() --- ember/ember.d.ts | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/ember/ember.d.ts b/ember/ember.d.ts index a599782f9..3f926ae12 100644 --- a/ember/ember.d.ts +++ b/ember/ember.d.ts @@ -90,6 +90,29 @@ interface Array { everyProperty(key: string, value?: any): boolean; filter(callback: Function, target?: any): any[]; filterBy(key: string, value?: string): any[]; + + /** + Returns the first item in the array for which the callback returns true. + This method works similar to the `filter()` method defined in JavaScript 1.6 + except that it will stop working on the array once a match is found. + The callback method you provide should have the following signature (all + parameters are optional): + ```javascript + function(item, index, enumerable); + ``` + - `item` is the current item in the iteration. + - `index` is the current index in the iteration. + - `enumerable` is the enumerable object itself. + It should return the `true` to include the item in the results, `false` + otherwise. + Note that in addition to a callback, you can also pass an optional target + object that will be set as `this` on the context. This is a good way + to give your iterator function access to the current object. + @function find + @arg callback The callback to execute + @arg {Object} [target] The target object to use + @return {Object} Found item or `undefined`. +*/ find(callback: Function, target?: any): any; findBy(key: string, value?: string): any; forEach(callback: Function, target?: any): any; @@ -403,7 +426,7 @@ declare module Ember { everyProperty(key: string, value?: string): boolean; filter(callback: Function, target: any): any[]; filterBy(key: string, value?: string): any[]; - find(callback: Function, target: any): any; + find(callback: Function, target?: any): any; findBy(key: string, value?: string): any; forEach(callback: Function, target?: any): any; getEach(key: string): any[]; @@ -1005,8 +1028,8 @@ declare module Ember { module Handlebars { function compile(string: string): Function; function get(root: any, path: string, options?: {}): any; - function helper(name: string, func: Function, dependentKeys: string): void; - function helper(name: string, view: View, dependentKeys: string): void; + function helper(name: string, func: Function, dependentKeys?: string): void; + function helper(name: string, view: View, dependentKeys?: string): void; class helpers { action(actionName: string, context: any, options?: {}): void; bindAttr(options?: {}): string; From 93928c19d6b9cb13c357b6a458f1b81bd81caa05 Mon Sep 17 00:00:00 2001 From: David Gardiner Date: Wed, 21 Jan 2015 11:50:50 +1030 Subject: [PATCH 099/185] Change any[] to Enumerable --- ember/ember.d.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/ember/ember.d.ts b/ember/ember.d.ts index 3f926ae12..682f796d6 100644 --- a/ember/ember.d.ts +++ b/ember/ember.d.ts @@ -522,7 +522,7 @@ declare module Ember { static isClass: boolean; static isMethod: boolean; addArrayObserver(target: any, opts?: EnumerableConfigurationOptions): any[]; - addEnumerableObserver(target: any, opts: EnumerableConfigurationOptions): any[]; + addEnumerableObserver(target: any, opts: EnumerableConfigurationOptions): Enumerable; any(callback: Function, target?: any): boolean; anyBy(key: string, value?: string): boolean; arrayContentDidChange(startIdx: number, removeAmt: number, addAmt: number): any[]; @@ -539,10 +539,10 @@ declare module Ember { enumerableContentDidChange(removing: Enumerable, adding: number): any; enumerableContentDidChange(removing: number, adding: Enumerable): any; enumerableContentDidChange(removing: Enumerable, adding: Enumerable): any; - enumerableContentWillChange(removing: number, adding: number): any[]; - enumerableContentWillChange(removing: Enumerable, adding: number): any[]; - enumerableContentWillChange(removing: number, adding: Enumerable): any[]; - enumerableContentWillChange(removing: Enumerable, adding: Enumerable): any[]; + enumerableContentWillChange(removing: number, adding: number): Enumerable; + enumerableContentWillChange(removing: Enumerable, adding: number): Enumerable; + enumerableContentWillChange(removing: number, adding: Enumerable): Enumerable; + enumerableContentWillChange(removing: Enumerable, adding: Enumerable): Enumerable; every(callback: Function, target?: any): boolean; everyBy(key: string, value?: string): boolean; everyProperty(key: string, value?: string): boolean; @@ -570,7 +570,7 @@ declare module Ember { rejectBy(key: string, value?: string): any[]; removeArrayObserver(target: any, opts: EnumerableConfigurationOptions): any[]; removeAt(start: number, len: number): any; - removeEnumerableObserver(target: any, opts: EnumerableConfigurationOptions): any[]; + removeEnumerableObserver(target: any, opts: EnumerableConfigurationOptions): Enumerable; replace(idx: number, amt: number, objects: any[]): any; replaceContent(idx: number, amt: number, objects: any[]): void; reverseObjects(): any[]; @@ -580,10 +580,10 @@ declare module Ember { slice(beginIndex?: number, endIndex?: number): any[]; some(callback: Function, target?: any): boolean; toArray(): any[]; - uniq(): any[]; + uniq(): Enumerable; unshiftObject(object: any): any; unshiftObjects(objects: any[]): any[]; - without(value: any): any[]; + without(value: any): Enumerable; '[]': any[]; '@each': EachProxy; Boolean: boolean; @@ -592,9 +592,9 @@ declare module Ember { lastObject: any; length: number; addObject(object: any): any; - addObjects(objects: Enumerable): any[]; + addObjects(objects: Enumerable): MutableEnumberable; removeObject(object: any): any; - removeObjects(objects: Enumerable): any[]; + removeObjects(objects: Enumerable): MutableEnumberable; } var BOOTED: boolean; /** From 6f6dd3c30939f00493f621467784f7b439254aea Mon Sep 17 00:00:00 2001 From: David Gardiner Date: Wed, 21 Jan 2015 12:02:18 +1030 Subject: [PATCH 100/185] Update EmberStates.Transition --- ember/ember.d.ts | 201 +++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 168 insertions(+), 33 deletions(-) diff --git a/ember/ember.d.ts b/ember/ember.d.ts index 682f796d6..2fd4ec555 100644 --- a/ember/ember.d.ts +++ b/ember/ember.d.ts @@ -11,15 +11,147 @@ declare var Handlebars: HandlebarsStatic; declare module EmberStates { interface Transition { - abort(): void; - addInitialStates(): void; - matchContextsToStates(contexts: any[]): void; - normalize(manager: Ember.StateManager, contexts: any[]): void; - removeUnchangedContexts(manager: Ember.StateManager): void; - retry(): void; - sendEvents(eventName: string, sendRecursiveArguments: boolean, isUnhandledPass: boolean): void; - sendRecursively(event: string, currentState: Ember.State, isUnhandledPass: boolean): void; targetName: string; + urlMethod: string; + intent: any; + params: {}; + pivotHandler: any; + resolveIndex: number; + handlerInfos: any; + resolvedModels: {}; + isActive: boolean; + state: any; + queryParams: {}; + queryParamsOnly: boolean; + + isTransition: boolean; + + /** + The Transition's internal promise. Calling `.then` on this property + is that same as calling `.then` on the Transition object itself, but + this property is exposed for when you want to pass around a + Transition's promise, but not the Transition object itself, since + Transition object can be externally `abort`ed, while the promise + cannot. + */ + promise: Ember.RSVP.Promise; + + /** + Custom state can be stored on a Transition's `data` object. + This can be useful for decorating a Transition within an earlier + hook and shared with a later hook. Properties set on `data` will + be copied to new transitions generated by calling `retry` on this + transition. + */ + data: any; + + /** + A standard promise hook that resolves if the transition + succeeds and rejects if it fails/redirects/aborts. + + Forwards to the internal `promise` property which you can + use in situations where you want to pass around a thennable, + but not the Transition itself. + + @arg {Function} onFulfilled + @arg {Function} onRejected + @arg {String} label optional string for labeling the promise. Useful for tooling. + @return {Promise} + */ + then(onFulfilled: Function, onRejected: Function, label?: string): Ember.RSVP.Promise; + + /** + Forwards to the internal `promise` property which you can + use in situations where you want to pass around a thennable, + but not the Transition itself. + + @method catch + @arg {Function} onRejection + @arg {String} label optional string for labeling the promise. + Useful for tooling. + @return {Promise} + */ + catch(onRejection: Function, label?: string): Ember.RSVP.Promise; + + /** + Forwards to the internal `promise` property which you can + use in situations where you want to pass around a thennable, + but not the Transition itself. + + @method finally + @arg {Function} callback + @arg {String} label optional string for labeling the promise. + Useful for tooling. + @return {Promise} + */ + finally(callback: Function, label?: string): Ember.RSVP.Promise; + + /** + Aborts the Transition. Note you can also implicitly abort a transition + by initiating another transition while a previous one is underway. + */ + abort(): EmberStates.Transition; + normalize(manager: Ember.StateManager, contexts: any[]): void; + + /** + Retries a previously-aborted transition (making sure to abort the + transition if it's still active). Returns a new transition that + represents the new attempt to transition. + */ + retry(): EmberStates.Transition; + + /** + Sets the URL-changing method to be employed at the end of a + successful transition. By default, a new Transition will just + use `updateURL`, but passing 'replace' to this method will + cause the URL to update using 'replaceWith' instead. Omitting + a parameter will disable the URL change, allowing for transitions + that don't update the URL at completion (this is also used for + handleURL, since the URL has already changed before the + transition took place). + + @arg {String} method the type of URL-changing method to use + at the end of a transition. Accepted values are 'replace', + falsy values, or any other non-falsy value (which is + interpreted as an updateURL transition). + + @return {Transition} this transition + */ + method(method: string): EmberStates.Transition; + + /** + Fires an event on the current list of resolved/resolving + handlers within this transition. Useful for firing events + on route hierarchies that haven't fully been entered yet. + + Note: This method is also aliased as `send` + + @arg {Boolean} [ignoreFailure=false] a boolean specifying whether unhandled events throw an error + @arg {String} name the name of the event to fire + */ + trigger(ignoreFailure:boolean, eventName: string); + /** + Fires an event on the current list of resolved/resolving + handlers within this transition. Useful for firing events + on route hierarchies that haven't fully been entered yet. + + Note: This method is also aliased as `send` + + @arg {String} name the name of the event to fire + */ + trigger(eventName: string); + + /** + Transitions are aborted and their promises rejected + when redirects occur; this method returns a promise + that will follow any redirects that occur and fulfill + with the value fulfilled by any redirecting transitions + that occur. + + @return {Promise} a promise that fulfills with the same + value that the final redirecting transition fulfills with + */ + followRedirects(): Ember.RSVP.Promise; } } @@ -1334,7 +1466,7 @@ declare module Ember { constructor(arr: any[]); static activate(): void; addArrayObserver(target: any, opts?: EnumerableConfigurationOptions): any[]; - addEnumerableObserver(target: any, opts: EnumerableConfigurationOptions): any[]; + addEnumerableObserver(target: any, opts: EnumerableConfigurationOptions): Enumerable; any(callback: Function, target?: any): boolean; anyBy(key: string, value?: string): boolean; arrayContentDidChange(startIdx: number, removeAmt: number, addAmt: number): any[]; @@ -1351,10 +1483,10 @@ declare module Ember { enumerableContentDidChange(removing: Enumerable, adding: number): any; enumerableContentDidChange(removing: number, adding: Enumerable): any; enumerableContentDidChange(removing: Enumerable, adding: Enumerable): any; - enumerableContentWillChange(removing: number, adding: number): any[]; - enumerableContentWillChange(removing: Enumerable, adding: number): any[]; - enumerableContentWillChange(removing: number, adding: Enumerable): any[]; - enumerableContentWillChange(removing: Enumerable, adding: Enumerable): any[]; + enumerableContentWillChange(removing: number, adding: number): Enumerable; + enumerableContentWillChange(removing: Enumerable, adding: number): Enumerable; + enumerableContentWillChange(removing: number, adding: Enumerable): Enumerable; + enumerableContentWillChange(removing: Enumerable, adding: Enumerable): Enumerable; every(callback: Function, target?: any): boolean; everyBy(key: string, value?: string): boolean; everyProperty(key: string, value?: any): boolean; @@ -1381,7 +1513,7 @@ declare module Ember { rejectBy(key: string, value?: string): any[]; removeArrayObserver(target: any, opts: EnumerableConfigurationOptions): any[]; removeAt(start: number, len: number): any; - removeEnumerableObserver(target: any, opts: EnumerableConfigurationOptions): any[]; + removeEnumerableObserver(target: any, opts: EnumerableConfigurationOptions): Enumerable; replace(idx: number, amt: number, objects: any[]): any; reverseObjects(): any[]; setEach(key: string, value?: any): any; @@ -1390,10 +1522,10 @@ declare module Ember { slice(beginIndex?: number, endIndex?: number): any[]; some(callback: Function, target?: any): boolean; toArray(): any[]; - uniq(): any[]; + uniq(): Enumerable; unshiftObject(object: any): any; unshiftObjects(objects: any[]): any[]; - without(value: any): any[]; + without(value: any): Enumerable; '[]': any[]; '@each': EachProxy; Boolean: boolean; @@ -1402,30 +1534,30 @@ declare module Ember { lastObject: any; length: number; addObject(object: any): any; - addObjects(objects: Enumerable): any[]; + addObjects(objects: Enumerable): MutableEnumberable; removeObject(object: any): any; - removeObjects(objects: Enumerable): any[]; + removeObjects(objects: Enumerable): MutableEnumberable; addObserver: ModifyObserver; - beginPropertyChanges(): any[]; + beginPropertyChanges(): Observable; cacheFor(keyName: string): any; decrementProperty(keyName: string, decrement?: number): number; - endPropertyChanges(): any[]; + endPropertyChanges(): Observable; get(keyName: string): any; getProperties(...args: string[]): {}; getProperties(keys: string[]): {}; getWithDefault(keyName: string, defaultValue: any): any; hasObserverFor(key: string): boolean; incrementProperty(keyName: string, increment?: number): number; - notifyPropertyChange(keyName: string): any[]; - propertyDidChange(keyName: string): any[]; - propertyWillChange(keyName: string): any[]; - removeObserver(key: string, target: any, method: string): Observable; - removeObserver(key: string, target: any, method: Function): Observable; - set(keyName: string, value: any): any[]; - setProperties(hash: {}): any[]; + notifyPropertyChange(keyName: string): Observable; + propertyDidChange(keyName: string): Observable; + propertyWillChange(keyName: string): Observable; + removeObserver(key: string, target: any, method: string): void; + removeObserver(key: string, target: any, method: Function): void; + set(keyName: string, value: any): Observable; + setProperties(hash: {}): Observable; toggleProperty(keyName: string): any; - copy(deep: boolean): any[]; - frozenCopy(): any[]; + copy(deep: boolean): Copyable; + frozenCopy(): Copyable; } class NoneLocation extends Object { static detect(obj: any): boolean; @@ -1549,11 +1681,14 @@ declare module Ember { notifyPropertyChange(keyName: string): Observable; propertyDidChange(keyName: string): Observable; propertyWillChange(keyName: string): Observable; - removeObserver(key: string, target: {}, method: string): Observable; - removeObserver(key: string, target: {}, method: Function): Observable; + removeObserver(key: string, target: {}, method: string): void; + removeObserver(key: string, target: {}, method: Function): void; set(keyName: string, value: any): Observable; setProperties(hash: {}): Observable; - toggleProperty(keyName: string): any; + /** + Set the value of a boolean property to the opposite of its current value. + */ + toggleProperty(keyName: string): boolean; } class OrderedSet { add(obj: any): void; @@ -1623,7 +1758,7 @@ declare module Ember { serialize(model: {}, params: string[]): string; setupController(controller: Controller, model: {}): void; // ReSharper disable once InconsistentNaming - transitionTo(name: string, ...object: any[]): void; + transitionTo(name: string, ...object: any[]): EmberStates.Transition; actions: ActionsHash; } class Router extends Object { From c5e9ada526e016b8a1a1f7c0a88815966b223aa2 Mon Sep 17 00:00:00 2001 From: David Gardiner Date: Wed, 25 Feb 2015 14:56:10 +1030 Subject: [PATCH 101/185] Arrays are more flexible extend can take mixin parameter Add external ambient module --- ember/ember.d.ts | 248 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 245 insertions(+), 3 deletions(-) diff --git a/ember/ember.d.ts b/ember/ember.d.ts index 2fd4ec555..2ba1a1aab 100644 --- a/ember/ember.d.ts +++ b/ember/ember.d.ts @@ -14,14 +14,14 @@ declare module EmberStates { targetName: string; urlMethod: string; intent: any; - params: {}; + params: any; pivotHandler: any; resolveIndex: number; handlerInfos: any; - resolvedModels: {}; + resolvedModels: any; isActive: boolean; state: any; - queryParams: {}; + queryParams: any; queryParamsOnly: boolean; isTransition: boolean; @@ -1581,6 +1581,7 @@ declare module Ember { Creates a subclass of the Object class. **/ static extend(arguments?: CoreObjectArguments): T; + static extend(mixins? : Mixin, arguments?: CoreObjectArguments): T; /** Creates an instance of the class. @param arguments A hash containing values with which to initialize the newly instantiated object. @@ -2612,3 +2613,244 @@ declare module Em { var watchedEvents: typeof Ember.watchedEvents; var wrap: typeof Ember.wrap; } + +/** + * External ambient module - to allow "import Ember = require('Ember');" to work correctly + */ + +declare module "Ember" { + + var $: typeof Ember.$; + var A: typeof Ember.A; + class ActionHandlerMixin extends Ember.ActionHandlerMixin { } + class Application extends Ember.Application { } + class Array extends Ember.Array { } + class ArrayController extends Ember.ArrayController { } + var ArrayPolyfills: typeof Ember.ArrayPolyfills; + class ArrayProxy extends Ember.ArrayProxy { } + var BOOTED: typeof Ember.BOOTED; + class Binding extends Ember.Binding { } + class Button extends Ember.Button { } + class Checkbox extends Ember.Checkbox { } + class CollectionView extends Ember.CollectionView { } + class Comparable extends Ember.Comparable { } + class Component extends Ember.Component { } + class ComputedProperty extends Ember.ComputedProperty { } + class Container extends Ember.Container { } + class ContainerView extends Ember.ContainerView { } + class Controller extends Ember.Controller { } + class ControllerMixin extends Ember.ControllerMixin { } + class Copyable extends Ember.Copyable { } + class CoreObject extends Ember.CoreObject { } + class CoreView extends Ember.CoreView { } + class DAG extends Ember.DAG { } + var DEFAULT_GETTER_FUNCTION: typeof Ember.DEFAULT_GETTER_FUNCTION; + class DefaultResolver extends Ember.DefaultResolver { } + class Deffered extends Ember.Deferred { } + class DeferredMixin extends Ember.DeferredMixin { } + class Descriptor extends Ember.Descriptor { } + var EMPTY_META: typeof Ember.EMPTY_META; + var ENV: typeof Ember.ENV; + var EXTEND_PROTOTYPES: typeof Ember.EXTEND_PROTOTYPES; + class EachProxy extends Ember.EachProxy { } + class Enumerable extends Ember.Enumerable { } + var EnumerableUtils: typeof Ember.EnumerableUtils; + var Error: typeof Ember.Error; + class EventDispatcher extends Ember.EventDispatcher { } + class Evented extends Ember.Evented { } + var FROZEN_ERROR: typeof Ember.FROZEN_ERROR; + class Freezable extends Ember.Freezable { } + var GUID_KEY: typeof Ember.GUID_KEY; + module Handlebars { + var compile: typeof Ember.Handlebars.compile; + var get: typeof Ember.Handlebars.get; + var helper: typeof Ember.Handlebars.helper; + class helpers extends Ember.Handlebars.helpers { } + var precompile: typeof Ember.Handlebars.precompile; + var registerBoundHelper: typeof Ember.Handlebars.registerBoundHelper; + class Compiler extends Ember.Handlebars.Compiler { } + class JavaScriptCompiler extends Ember.Handlebars.JavaScriptCompiler { } + var registerHelper: typeof Ember.Handlebars.registerHelper; + var registerPartial: typeof Ember.Handlebars.registerPartial; + var K: typeof Ember.Handlebars.K; + var createFrame: typeof Ember.Handlebars.createFrame; + var Exception: typeof Ember.Handlebars.Exception; + class SafeString extends Ember.Handlebars.SafeString { } + var parse: typeof Ember.Handlebars.parse; + var print: typeof Ember.Handlebars.print; + var logger: typeof Ember.Handlebars.logger; + var log: typeof Ember.Handlebars.log; + } + class HashLocation extends Ember.HashLocation { } + class HistoryLocation extends Ember.HistoryLocation { } + var IS_BINDING: typeof Ember.IS_BINDING; + class Instrumentation extends Ember.Instrumentation { } + var K: typeof Ember.K; + var LOG_BINDINGS: typeof Ember.LOG_BINDINGS; + var LOG_STACKTRACE_ON_DEPRECATION: typeof Ember.LOG_STACKTRACE_ON_DEPRECATION; + var LOG_VERSION: typeof Ember.LOG_VERSION; + class LinkView extends Ember.LinkView { } + class Location extends Ember.Location { } + var Logger: typeof Ember.Logger; + var MANDATORY_SETTER_FUNCTION: typeof Ember.MANDATORY_SETTER_FUNCTION; + var META_KEY: typeof Ember.META_KEY; + class Map extends Ember.Map { } + class MapWithDefault extends Ember.MapWithDefault { } + class Mixin extends Ember.Mixin { } + class MutableArray extends Ember.MutableArray { } + class MutableEnumerable extends Ember.MutableEnumberable { } + var NAME_KEY: typeof Ember.NAME_KEY; + class Namespace extends Ember.Namespace { } + class NativeArray extends Ember.NativeArray { } + class NoneLocation extends Ember.NoneLocation { } + var ORDER_DEFINITION: typeof Ember.ORDER_DEFINITION; + class Object extends Ember.Object { } + class ObjectController extends Ember.ObjectController { } + class ObjectProxy extends Ember.ObjectProxy { } + class Observable extends Ember.Observable { } + class OrderedSet extends Ember.OrderedSet { } + module RSVP { + class Promise extends Ember.RSVP.Promise { } + } + class RenderBuffer extends Ember.RenderBuffer { } + class Route extends Ember.Route { } + class Router extends Ember.Router { } + class RouterDSL extends Ember.RouterDSL { } + var SHIM_ES5: typeof Ember.SHIM_ES5; + var STRINGS: typeof Ember.STRINGS; + class Select extends Ember.Select { } + class SelectOption extends Ember.SelectOption { } + class Set extends Ember.Set { } + class SortableMixin extends Ember.SortableMixin { } + class State extends Ember.State { } + class StateManager extends Ember.StateManager { } + module String { + var camelize: typeof Ember.String.camelize; + var capitalize: typeof Ember.String.capitalize; + var classify: typeof Ember.String.classify; + var dasherize: typeof Ember.String.dasherize; + var decamelize: typeof Ember.String.decamelize; + var fmt: typeof Ember.String.fmt; + var htmlSafe: typeof Ember.String.htmlSafe; + var loc: typeof Ember.String.loc; + var underscore: typeof Ember.String.underscore; + var w: typeof Ember.String.w; + } + var TEMPLATES: typeof Ember.TEMPLATES; + class TargetActionSupport extends Ember.TargetActionSupport { } + class Test extends Ember.Test { } + class TextArea extends Ember.TextArea { } + class TextField extends Ember.TextField { } + class TextSupport extends Ember.TextSupport { } + var VERSION: typeof Ember.VERSION; + class View extends Ember.View { } + class ViewTargetActionSupport extends Ember.ViewTargetActionSupport { } + var ViewUtils: typeof Ember.ViewUtils; + var addBeforeObserver: typeof Ember.addBeforeObserver; + var addListener: typeof Ember.addListener; + var addObserver: typeof Ember.addObserver; + var alias: typeof Ember.alias; + var aliasMethod: typeof Ember.aliasMethod; + var anyUnprocessedMixins: typeof Ember.anyUnprocessedMixins; + var assert: typeof Ember.assert; + var beforeObserver: typeof Ember.beforeObserver; + var beforeObserversFor: typeof Ember.beforeObserversFor; + var beginPropertyChanges: typeof Ember.beginPropertyChanges; + var bind: typeof Ember.bind; + var cacheFor: typeof Ember.cacheFor; + var canInvoke: typeof Ember.canInvoke; + var changeProperties: typeof Ember.changeProperties; + var compare: typeof Ember.compare; + var computed: typeof Ember.computed; + var config: typeof Ember.config; + var controllerFor: typeof Ember.controllerFor; + var copy: typeof Ember.copy; + var create: typeof Ember.create; + var debug: typeof Ember.debug; + var defineProperty: typeof defineProperty; + var deprecate: typeof deprecate; + var deprecateFunc: typeof deprecateFunc; + var destroy: typeof Ember.destroy; + var empty: typeof deprecateFunc; + var endPropertyChanges: typeof Ember.endPropertyChanges; + var exports: typeof Ember.exports; + var finishChains: typeof Ember.finishChains; + var flushPendingChains: typeof Ember.flushPendingChains; + var generateController: typeof Ember.generateController; + var generateGuid: typeof Ember.generateGuid; + var get: typeof Ember.get; + var getMeta: typeof Ember.getMeta; + var getPath: typeof Ember.getPath; + var getWithDefault: typeof Ember.getWithDefault; + var guidFor: typeof Ember.guidFor; + var handleErrors: typeof Ember.handleErrors; + var hasListeners: typeof Ember.hasListeners; + var hasOwnProperty: typeof Ember.hasOwnProperty; + var immediateObserver: typeof immediateObserver; + var imports: typeof Ember.imports; + var inspect: typeof Ember.inspect; + var instrument: typeof Ember.instrument; + var isArray: typeof Ember.isArray; + var isEmpty: typeof Ember.isEmpty; + var isEqual: typeof Ember.isEqual; + var isGlobalPath: typeof Ember.isGlobalPath; + var isNamespace: typeof Ember.isNamespace; + var isNone: typeof Ember.isNone; + var isPrototypeOf: typeof Ember.isPrototypeOf; + var isWatching: typeof Ember.isWatching; + var keys: typeof Ember.keys; + var listenersDiff: typeof Ember.listenersDiff; + var listenersFor: typeof Ember.listenersFor; + var listenersUnion: typeof Ember.listenersUnion; + var lookup: typeof Ember.lookup; + var makeArray: typeof Ember.makeArray; + var merge: typeof Ember.merge; + var meta: typeof Ember.meta; + var metaPath: typeof Ember.metaPath; + var mixin: typeof Ember.mixin; + var none: typeof Ember.none; + var normalizeTuple: typeof Ember.normalizeTuple; + var observer: typeof Ember.observer; + var observersFor: typeof Ember.observersFor; + var onLoad: typeof Ember.onLoad; + var oneWay: typeof Ember.oneWay; + var onError: typeof Ember.onError; + var overrideChains: typeof Ember.overrideChains; + var platform: typeof Ember.platform; + var propertyDidChange: typeof Ember.propertyDidChange; + var propertyIsEnumerable: typeof Ember.propertyIsEnumerable; + var propertyWillChange: typeof Ember.propertyWillChange; + var removeBeforeObserver: typeof Ember.removeBeforeObserver; + var removeChainWatcher: typeof Ember.removeChainWatcher; + var removeListener: typeof Ember.removeListener; + var removeObserver: typeof Ember.removeObserver; + var required: typeof Ember.required; + var rewatch: typeof Ember.rewatch; + var run: typeof Ember.run; + var runLoadHooks: typeof Ember.runLoadHooks; + var sendEvent: typeof Ember.sendEvent; + var set: typeof Ember.set; + var setMeta: typeof Ember.setMeta; + var setPath: typeof Ember.setPath; + var setProperties: typeof Ember.setProperties; + var subscribe: typeof Ember.subscribe; + var toLocaleString: typeof Ember.toLocaleString; + var toString: typeof Ember.toString; + var tryCatchFinally: typeof Ember.tryCatchFinally; + var tryFinally: typeof Ember.tryFinally; + var tryInvoke: typeof Ember.tryInvoke; + var trySet: typeof Ember.trySet; + var trySetPath: typeof Ember.trySetPath; + var typeOf: typeof Ember.typeOf; + var unwatch: typeof Ember.unwatch; + var unwatchKey: typeof Ember.unwatchKey; + var unwatchPath: typeof Ember.unwatchPath; + var uuid: typeof Ember.uuid; + var valueOf: typeof Ember.valueOf; + var warn: typeof Ember.warn; + var watch: typeof Ember.watch; + var watchKey: typeof Ember.watchKey; + var watchPath: typeof Ember.watchPath; + var watchedEvents: typeof Ember.watchedEvents; + var wrap: typeof Ember.wrap; +} From c2cfd165ef7a36d1347485d8680426762eaaedba Mon Sep 17 00:00:00 2001 From: David Gardiner Date: Wed, 25 Feb 2015 15:52:38 +1030 Subject: [PATCH 102/185] Fix errors from compiling with with --noImplicitAny Set Error as type 'any' because we can't currently refer to the global Error type --- ember/ember-tests.ts | 16 ++++++++-------- ember/ember.d.ts | 43 ++++++++++++++++++++++--------------------- 2 files changed, 30 insertions(+), 29 deletions(-) diff --git a/ember/ember-tests.ts b/ember/ember-tests.ts index 39e960e00..ef9b7e6d1 100644 --- a/ember/ember-tests.ts +++ b/ember/ember-tests.ts @@ -2,9 +2,9 @@ /// -var App; +var App : any; -App = Em.Application.create(); +App = Em.Application.create(); App.president = Em.Object.create({ name: 'Barack Obama' @@ -27,7 +27,7 @@ declare class MyPerson extends Em.Object { } var Person1 = Em.Object.extend({ - say: (thing) => { + say: (thing: string) => { alert(thing); } }); @@ -119,7 +119,7 @@ App.AlertView = Em.View.extend({ App.ListingView = Em.View.extend({ templateName: 'listing', - edit: (event) => { + edit: (event: any) => { event.view.set('isEditing', true); } }); @@ -133,7 +133,7 @@ App.userController = Em.Object.create({ }) }); -Handlebars.registerHelper('highlight', function(property, options) { +Handlebars.registerHelper('highlight', function(property: string, options: any) { var value = Em.Handlebars.get(this, property, options); return new Handlebars.SafeString('' + value + ''); }); @@ -195,7 +195,7 @@ people2.everyProperty('isHappy', true); people2.someProperty('isHappy', true); // Examples taken from http://emberjs.com/api/classes/Ember.RSVP.Promise.html -var promise = new Ember.RSVP.Promise(function(resolve, reject) { +var promise = new Ember.RSVP.Promise(function(resolve: Function, reject: Function) { // on success resolve('ok!'); @@ -203,8 +203,8 @@ var promise = new Ember.RSVP.Promise(function(resolve, reject) { reject('no-k!'); }); -promise.then(function(value) { +promise.then(function(value: any) { // on fulfillment -}, function(reason) { +}, function(reason: any) { // on rejection }); diff --git a/ember/ember.d.ts b/ember/ember.d.ts index 2ba1a1aab..b444cec1d 100644 --- a/ember/ember.d.ts +++ b/ember/ember.d.ts @@ -129,7 +129,7 @@ declare module EmberStates { @arg {Boolean} [ignoreFailure=false] a boolean specifying whether unhandled events throw an error @arg {String} name the name of the event to fire */ - trigger(ignoreFailure:boolean, eventName: string); + trigger(ignoreFailure:boolean, eventName: string): void; /** Fires an event on the current list of resolved/resolving handlers within this transition. Useful for firing events @@ -139,7 +139,7 @@ declare module EmberStates { @arg {String} name the name of the event to fire */ - trigger(eventName: string); + trigger(eventName: string): void; /** Transitions are aborted and their promises rejected @@ -193,7 +193,7 @@ interface String { } interface Array { - constructor(arr: any[]); + constructor(arr: any[]): void; activate(): void; addArrayObserver(target: any, opts?: EnumerableConfigurationOptions): any[]; addEnumerableObserver(target: any, opts: EnumerableConfigurationOptions): any[]; @@ -267,7 +267,7 @@ interface Array { removeArrayObserver(target: any, opts: EnumerableConfigurationOptions): any[]; removeAt(start: number, len: number): any; removeEnumerableObserver(target: any, opts: EnumerableConfigurationOptions): any[]; - replace(idx: number, amt: number, objects: any[]); + replace(idx: number, amt: number, objects: any[]): void; reverseObjects(): any[]; setEach(key: string, value?: any): any; setObjects(objects: any[]): any[]; @@ -334,7 +334,7 @@ interface ApplicationInitializerArguments { } interface ApplicationInitializerFunction { - (container: Ember.Container, application: Ember.Application); + (container: Ember.Container, application: Ember.Application): void; } interface CoreObjectArguments { @@ -361,11 +361,11 @@ interface ItemIndexEnumerableCallbackTarget { } interface ItemIndexEnumerableCallback { - (item: any, index: number, enumerable: Ember.Enumerable); + (item: any, index: number, enumerable: Ember.Enumerable): void; } interface ReduceCallback { - (previousValue: any, item: any, index: number, enumerable: Ember.Enumerable); + (previousValue: any, item: any, index: number, enumerable: Ember.Enumerable): void; } interface TransitionsHash { @@ -392,10 +392,10 @@ interface RenderOptions { } interface ModifyObserver { - (obj: any, path: string, target: any, method?: Function); - (obj: any, path: string, target: any, method?: string); - (obj: any, path: string, func: Function, method?: Function); - (obj: any, path: string, func: Function, method?: string); + (obj: any, path: string, target: any, method?: Function): void; + (obj: any, path: string, target: any, method?: string): void; + (obj: any, path: string, func: Function, method?: Function): void; + (obj: any, path: string, func: Function, method?: string): void; } declare module Ember { @@ -1117,8 +1117,9 @@ declare module Ember { /** A subclass of the JavaScript Error object for use in Ember. **/ + // Restore this to 'typeof Error' when https://github.com/Microsoft/TypeScript/issues/983 is resolved // ReSharper disable once DuplicatingLocalDeclaration - var Error: typeof Error; + var Error: any; // typeof Error; /** Handles delegating browser events to their corresponding Ember.Views. For example, when you click on a view, Ember.EventDispatcher ensures that that view's mouseDown method gets called. @@ -2526,9 +2527,9 @@ declare module Em { var copy: typeof Ember.copy; var create: typeof Ember.create; var debug: typeof Ember.debug; - var defineProperty: typeof defineProperty; - var deprecate: typeof deprecate; - var deprecateFunc: typeof deprecateFunc; + var defineProperty: typeof Ember.defineProperty; + var deprecate: typeof Ember.deprecate; + var deprecateFunc: typeof Ember.deprecateFunc; var destroy: typeof Ember.destroy; var empty: typeof deprecateFunc; var endPropertyChanges: typeof Ember.endPropertyChanges; @@ -2545,7 +2546,7 @@ declare module Em { var handleErrors: typeof Ember.handleErrors; var hasListeners: typeof Ember.hasListeners; var hasOwnProperty: typeof Ember.hasOwnProperty; - var immediateObserver: typeof immediateObserver; + var immediateObserver: typeof Ember.immediateObserver; var imports: typeof Ember.imports; var inspect: typeof Ember.inspect; var instrument: typeof Ember.instrument; @@ -2767,11 +2768,11 @@ declare module "Ember" { var copy: typeof Ember.copy; var create: typeof Ember.create; var debug: typeof Ember.debug; - var defineProperty: typeof defineProperty; - var deprecate: typeof deprecate; - var deprecateFunc: typeof deprecateFunc; + var defineProperty: typeof Ember.defineProperty; + var deprecate: typeof Ember.deprecate; + var deprecateFunc: typeof Ember.deprecateFunc; var destroy: typeof Ember.destroy; - var empty: typeof deprecateFunc; + var empty: typeof Ember.deprecateFunc; var endPropertyChanges: typeof Ember.endPropertyChanges; var exports: typeof Ember.exports; var finishChains: typeof Ember.finishChains; @@ -2786,7 +2787,7 @@ declare module "Ember" { var handleErrors: typeof Ember.handleErrors; var hasListeners: typeof Ember.hasListeners; var hasOwnProperty: typeof Ember.hasOwnProperty; - var immediateObserver: typeof immediateObserver; + var immediateObserver: typeof Ember.immediateObserver; var imports: typeof Ember.imports; var inspect: typeof Ember.inspect; var instrument: typeof Ember.instrument; From 19a680e67d7b5dc4c69fa690f8fe62ec1df7cc61 Mon Sep 17 00:00:00 2001 From: David Gardiner Date: Wed, 25 Feb 2015 16:02:56 +1030 Subject: [PATCH 103/185] any or {} --- ember/ember.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ember/ember.d.ts b/ember/ember.d.ts index b444cec1d..22cbb8ab5 100644 --- a/ember/ember.d.ts +++ b/ember/ember.d.ts @@ -14,14 +14,14 @@ declare module EmberStates { targetName: string; urlMethod: string; intent: any; - params: any; + params: {}|any; pivotHandler: any; resolveIndex: number; handlerInfos: any; - resolvedModels: any; + resolvedModels: {}|any; isActive: boolean; state: any; - queryParams: any; + queryParams: {}|any; queryParamsOnly: boolean; isTransition: boolean; From a3aa65cfd9e05f4589c9eafa9e45348ec98d4f0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Morch=C3=B3n=20Poveda?= Date: Wed, 25 Feb 2015 13:48:14 +0100 Subject: [PATCH 104/185] Update knockout-tests.ts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added a different versión of init, which returns an object instead of void. --- knockout/tests/knockout-tests.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/knockout/tests/knockout-tests.ts b/knockout/tests/knockout-tests.ts index 78d464f07..7b0c8174e 100644 --- a/knockout/tests/knockout-tests.ts +++ b/knockout/tests/knockout-tests.ts @@ -163,6 +163,7 @@ function test_bindings() { ko.bindingHandlers.yourBindingName = { init: function (element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) { + return { "controlsDescendantBindings": true }; }, update: function (element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) { } @@ -655,4 +656,4 @@ function testUnwrapUnion() { var possibleObs: KnockoutObservable | number; var num = ko.unwrap(possibleObs); -} \ No newline at end of file +} From 88a708f71a7dda8563c908fa300eb07a0e1dea2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Morch=C3=B3n=20Poveda?= Date: Wed, 25 Feb 2015 13:57:32 +0100 Subject: [PATCH 105/185] Update knockout.d.ts Added KnockoutBindingHandler.init alternative return type. --- knockout/knockout.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/knockout/knockout.d.ts b/knockout/knockout.d.ts index 28d7b94cc..d439ca3dd 100644 --- a/knockout/knockout.d.ts +++ b/knockout/knockout.d.ts @@ -133,8 +133,8 @@ interface KnockoutAllBindingsAccessor { } interface KnockoutBindingHandler { - init? (element: any, valueAccessor: () => any, allBindingsAccessor: KnockoutAllBindingsAccessor, viewModel: any, bindingContext: KnockoutBindingContext): void; - update? (element: any, valueAccessor: () => any, allBindingsAccessor: KnockoutAllBindingsAccessor, viewModel: any, bindingContext: KnockoutBindingContext): void; + init?: (element: any, valueAccessor: () => any, allBindingsAccessor: KnockoutAllBindingsAccessor, viewModel: any, bindingContext: KnockoutBindingContext): void | { controlsDescendantBindings: boolean; };; + update?: (element: any, valueAccessor: () => any, allBindingsAccessor: KnockoutAllBindingsAccessor, viewModel: any, bindingContext: KnockoutBindingContext): void; options?: any; preprocess?: (value: string, name: string, addBindingCallback?: (name: string, value: string) => void) => string; } From 65e48513ded529acf29e5e712d5d3762048fdd6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Morch=C3=B3n=20Poveda?= Date: Wed, 25 Feb 2015 14:09:05 +0100 Subject: [PATCH 106/185] Update knockout.d.ts Delete extra comma... --- knockout/knockout.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/knockout/knockout.d.ts b/knockout/knockout.d.ts index d439ca3dd..e275f950e 100644 --- a/knockout/knockout.d.ts +++ b/knockout/knockout.d.ts @@ -133,7 +133,7 @@ interface KnockoutAllBindingsAccessor { } interface KnockoutBindingHandler { - init?: (element: any, valueAccessor: () => any, allBindingsAccessor: KnockoutAllBindingsAccessor, viewModel: any, bindingContext: KnockoutBindingContext): void | { controlsDescendantBindings: boolean; };; + init?: (element: any, valueAccessor: () => any, allBindingsAccessor: KnockoutAllBindingsAccessor, viewModel: any, bindingContext: KnockoutBindingContext): void | { controlsDescendantBindings: boolean; }; update?: (element: any, valueAccessor: () => any, allBindingsAccessor: KnockoutAllBindingsAccessor, viewModel: any, bindingContext: KnockoutBindingContext): void; options?: any; preprocess?: (value: string, name: string, addBindingCallback?: (name: string, value: string) => void) => string; From cd2cc1719427f0521147eecca354370f465fcb8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Morch=C3=B3n=20Poveda?= Date: Wed, 25 Feb 2015 14:10:52 +0100 Subject: [PATCH 107/185] Update knockout.d.ts Fixed init & update signature. --- knockout/knockout.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/knockout/knockout.d.ts b/knockout/knockout.d.ts index e275f950e..5aa7c61cb 100644 --- a/knockout/knockout.d.ts +++ b/knockout/knockout.d.ts @@ -133,8 +133,8 @@ interface KnockoutAllBindingsAccessor { } interface KnockoutBindingHandler { - init?: (element: any, valueAccessor: () => any, allBindingsAccessor: KnockoutAllBindingsAccessor, viewModel: any, bindingContext: KnockoutBindingContext): void | { controlsDescendantBindings: boolean; }; - update?: (element: any, valueAccessor: () => any, allBindingsAccessor: KnockoutAllBindingsAccessor, viewModel: any, bindingContext: KnockoutBindingContext): void; + init?: (element: any, valueAccessor: () => any, allBindingsAccessor: KnockoutAllBindingsAccessor, viewModel: any, bindingContext: KnockoutBindingContext) => void | { controlsDescendantBindings: boolean; }; + update?: (element: any, valueAccessor: () => any, allBindingsAccessor: KnockoutAllBindingsAccessor, viewModel: any, bindingContext: KnockoutBindingContext) => void; options?: any; preprocess?: (value: string, name: string, addBindingCallback?: (name: string, value: string) => void) => string; } From 7f9ae75f8c8b2d0ae92103c36ef835c488271ac8 Mon Sep 17 00:00:00 2001 From: Chris Colbert Date: Wed, 25 Feb 2015 11:51:47 -0500 Subject: [PATCH 108/185] update signature of Promise.all and Promise.race --- es6-promise/es6-promise.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/es6-promise/es6-promise.d.ts b/es6-promise/es6-promise.d.ts index 271838807..4a793e540 100644 --- a/es6-promise/es6-promise.d.ts +++ b/es6-promise/es6-promise.d.ts @@ -54,12 +54,12 @@ declare module Promise { * the array passed to all can be a mixture of promise-like objects and other objects. * The fulfillment value is an array (in order) of fulfillment values. The rejection value is the first rejection value. */ - function all(promises: Promise[]): Promise; + function all(promises: (R | Thenable)[]): Promise; /** * Make a Promise that fulfills when any item fulfills, and rejects if any item rejects. */ - function race(promises: Promise[]): Promise; + function race(promises: (R | Thenable)[]): Promise; } declare module 'es6-promise' { From 561b5a075e0237db3631c0588890e72506c9d36d Mon Sep 17 00:00:00 2001 From: jayoungers Date: Wed, 25 Feb 2015 13:54:14 -0600 Subject: [PATCH 109/185] ICacheObject.put and IAnimateService.addClass Return Types Updating ICacheObject.put return type to the type of object passed in (opposed to just void): https://docs.angularjs.org/api/ng/type/$cacheFactory.Cache Updating IAnimateService.addClass to return the type IPromise (opposed to just void): https://docs.angularjs.org/api/ngAnimate/service/$animate --- angularjs/angular.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts index d764bec6b..2f88253f0 100755 --- a/angularjs/angular.d.ts +++ b/angularjs/angular.d.ts @@ -1024,7 +1024,7 @@ declare module ng { // Not garanteed to have, since it's a non-mandatory option //capacity: number; }; - put(key: string, value?: any): void; + put(key: string, value?: T): T; get(key: string): any; remove(key: string): void; removeAll(): void; @@ -1501,7 +1501,7 @@ declare module ng { // see http://docs.angularjs.org/api/ng.$animate /////////////////////////////////////////////////////////////////////// interface IAnimateService { - addClass(element: JQuery, className: string, done?: Function): void; + addClass(element: JQuery, className: string, done?: Function): IPromise; enter(element: JQuery, parent: JQuery, after: JQuery, done?: Function): void; leave(element: JQuery, done?: Function): void; move(element: JQuery, parent: JQuery, after: JQuery, done?: Function): void; From 4fb28c2c4aef8c4a3b6558cc11b6961b37fb13fd Mon Sep 17 00:00:00 2001 From: reppners Date: Wed, 25 Feb 2015 22:45:40 +0100 Subject: [PATCH 110/185] + initial commit --- js-data-angular/js-data-angular.d.ts | 19 ++ js-data/js-data.d.ts | 394 +++++++++++++++++++++++++++ 2 files changed, 413 insertions(+) create mode 100644 js-data-angular/js-data-angular.d.ts create mode 100644 js-data/js-data.d.ts diff --git a/js-data-angular/js-data-angular.d.ts b/js-data-angular/js-data-angular.d.ts new file mode 100644 index 000000000..a7c035722 --- /dev/null +++ b/js-data-angular/js-data-angular.d.ts @@ -0,0 +1,19 @@ +// Type definitions for JSDataAngular v2.1.0 +// Project: https://github.com/js-data/js-data-angular +// Definitions by: Stefan Steinhart +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// +/// + +declare module JSData { + + class ngDS extends DS { + + // sync methods + bindAll(scope:ng.IScope, expr:string, resourceName:string, params:DSFilterParams, cb?:(err:DSError, items:Array)=>void):Function; + + bindOne(scope:ng.IScope, expr:string, resourceName:string, id:string, cb?:(err:DSError, item:T)=>void):Function; + bindOne(scope:ng.IScope, expr:string, resourceName:string, id:number, cb?:(err:DSError, item:T)=>void):Function; + } +} \ No newline at end of file diff --git a/js-data/js-data.d.ts b/js-data/js-data.d.ts new file mode 100644 index 000000000..ce06edd89 --- /dev/null +++ b/js-data/js-data.d.ts @@ -0,0 +1,394 @@ +// Type definitions for JSData v1.3.0 +// Project: https://github.com/js-data/js-data +// Definitions by: Stefan Steinhart +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/////////////////////////////////////////////////////////////////////////////// +// Promises in js-data are ES6 polyfill promises +/////////////////////////////////////////////////////////////////////////////// + +/// + +declare class JSDataPromise extends Promise { + + // enhanced with finally + finally(finallyCb?: () => U): Promise; +} + +/////////////////////////////////////////////////////////////////////////////// +// js-data module (js-data.js) +/////////////////////////////////////////////////////////////////////////////// + +// Support AMD require +declare module 'js-data' { + export = JSData; +} + +declare module JSData { + + class DS { + + constructor(config?:DSConfiguration); + + defaults:DSConfiguration; + + //TODO check if still exists + adapters:any; // Object consists of key-values pairs where the key is the name of the adapter and the value is + // the adapter itself. + //TODO check if still exists + errors:DSErrors; + + changeHistory(resourceName:string, id?:string):Array; + changeHistory(resourceName:string, id?:number):Array; + + changes(resourceName:string, id:string):Object; + changes(resourceName:string, id:number):Object; + + compute(resourceName:string, id:number):T; + compute(resourceName:string, id:string):T; + compute(resourceName:string, instance:Object):T; + + create(resourceName:string, attrs:any, options?:DSConfiguration):JSDataPromise; + + createInstance(resourceName:string, attrs?:T, options?:DSAdapterOperationConfiguration):T; + + defineResource(resourceName:string):DSResourceDefinition; + defineResource(definition:DSResourceDefinitionConfiguration):DSResourceDefinition; + + destroy(resourceName:string, id:string, options?:DSAdapterOperationConfiguration):JSDataPromise; + destroy(resourceName:string, id:number, options?:DSAdapterOperationConfiguration):JSDataPromise; + + destroyAll(resourceName:string, params?:DSFilterParams, options?:DSAdapterOperationConfiguration):JSDataPromise; + + digest():void; + + eject(resourceName:string, id:string, options?:DSConfiguration):T; + eject(resourceName:string, id:number, options?:DSConfiguration):T; + + ejectAll(resourceName:string, params:DSFilterParams, options?:DSConfiguration):Array; + + filter(resourceName:string, params:DSFilterParams, options?:DSConfiguration):Array; + + find(resourceName:string, id:string, options?:DSAdapterOperationConfiguration):JSDataPromise; + find(resourceName:string, id:number, options?:DSAdapterOperationConfiguration):JSDataPromise; + + findAll(resourceName:string, params:DSFilterParams, options?:DSAdapterOperationConfiguration):JSDataPromise>; + + get(resourceName:string, id:string, options?:DSConfiguration):T; + get(resourceName:string, id:number, options?:DSConfiguration):T; + + getAll(resourceName:string, ids?:Array):Array; + getAll(resourceName:string, ids?:Array):Array; + + hasChanges(resourceName:string, id:string):boolean; + hasChanges(resourceName:string, id:number):boolean; + + inject(resourceName:string, attrs:T, options?:DSConfiguration):T; + inject(resourceName:string, items:Array, options?:DSConfiguration):Array; + + is(resourceName:string, object:Object): boolean; + + lastModified(resourceName:string, id?:string):number; // timestamp + lastModified(resourceName:string, id?:number):number; // timestamp + + lastSaved(resourceName:string, id?:string):number; // timestamp + lastSaved(resourceName:string, id?:number):number; // timestamp + + link(resourceName:string, id:string, relations?:Array):T; + link(resourceName:string, id:number, relations?:Array):T; + + linkAll(resourceName:string, params:DSFilterParams, relations?:Array):T; + + linkInverse(resourceName:string, id:string, relations?:Array):T; + linkInverse(resourceName:string, id:number, relations?:Array):T; + + loadRelations(resourceName:string, id:string, relations:string, options?:DSAdapterOperationConfiguration):JSDataPromise; + loadRelations(resourceName:string, id:number, relations:string, options?:DSAdapterOperationConfiguration):JSDataPromise; + loadRelations(resourceName:string, instance:Object, relations:string, options?:DSAdapterOperationConfiguration):JSDataPromise; + loadRelations(resourceName:string, id:string, relations:Array, options?:DSAdapterOperationConfiguration):JSDataPromise; + loadRelations(resourceName:string, id:number, relations:Array, options?:DSAdapterOperationConfiguration):JSDataPromise; + loadRelations(resourceName:string, instance:Object, relations:Array, options?:DSAdapterOperationConfiguration):JSDataPromise; + + previous(resourceName:string, id:string):T; + previous(resourceName:string, id:number):T; + + reap(resourceName:string, options?:DSConfiguration):JSDataPromise; + + refresh(resourceName:string, id:string, options?:DSAdapterOperationConfiguration):JSDataPromise; + refresh(resourceName:string, id:number, options?:DSAdapterOperationConfiguration):JSDataPromise; + + registerAdapter(adapterId: string, adapter:IDSAdapter, options?:{default: boolean}):void; + + save(resourceName:string, id:string, options?:DSSaveConfiguration):JSDataPromise; + save(resourceName:string, id:number, options?:DSSaveConfiguration):JSDataPromise; + + unlinkInverse(resourceName:string, id:string, relations?:Array):T; + unlinkInverse(resourceName:string, id:number, relations?:Array):T; + + update(resourceName:string, id:string, attrs:any, options?:DSSaveConfiguration):JSDataPromise; + update(resourceName:string, id:number, attrs:any, options?:DSSaveConfiguration):JSDataPromise; + + updateAll(resourceName:string, attrs:any, params:DSFilterParams, options?:DSAdapterOperationConfiguration):JSDataPromise>; + } + + interface DSConfiguration extends IDSResourceLifecycleEventHandlers { + actions?: Object; + allowSimpleWhere?: boolean; + basePath?: string; + bypassCache?: boolean; + cacheResponse?: boolean; + defaultAdapter?: string; + defaultFilter?: (collection:Array, resourceName:string, params:DSFilterParams, options:DSConfiguration)=>Array; + eagerEject?: boolean; + endpoint?: string; + error?: (message?: any, ...optionalParams: any[])=> void; + fallbackAdapters?: Array; + findAllFallbackAdapters?: Array; + findAllStrategy?: string; + findBelongsTo?: boolean; + findFallbackAdapters?: Array; + findHasOne?: boolean; + findHasMany?: boolean; + findInverseLinks?: boolean; + findStrategy?: string + idAttribute?: string; + ignoredChanges?:Array; + keepChangeHistory?: boolean; + loadFromServer?: boolean; + log?: any; + // log: (message?: any, ...optionalParams: any[])=> void; + // log: boolean; + maxAge?: number; + notify?: boolean; + reapAction?: string; + reapInterval?: number; + resetHistoryOnInject?: boolean; + strategy?: string; + upsert?: boolean; + useClass?: boolean; + useFilter: boolean; + } + + interface DSAdapterOperationConfiguration extends DSConfiguration { + adapter?: string + } + + interface DSSaveConfiguration extends DSAdapterOperationConfiguration { + changesOnly?: boolean; + } + + interface DSResourceDefinitionConfiguration extends DSConfiguration { + name: string; + computed?: any; + methods?: any; + relations?: { + hasMany?: Object; + hasOne?: Object; + belongsTo?: Object; + }; + } + + interface DSResourceDefinition extends DSResourceDefinitionConfiguration { + + changeHistory(id?:string):Array; + changeHistory(id?:number):Array; + + changes(id:string):Object; + changes(id:number):Object; + + compute(id:number):T; + compute(id:string):T; + compute(instance:Object):T; + + create(attrs:any, options?:DSConfiguration):JSDataPromise; + + createInstance(attrs?:T, options?:DSAdapterOperationConfiguration):T; + + defineResource(resourceName:string):DSResourceDefinition; + defineResource(definition:DSResourceDefinitionConfiguration):DSResourceDefinition; + + destroy(id:string, options?:DSAdapterOperationConfiguration):JSDataPromise; + destroy(id:number, options?:DSAdapterOperationConfiguration):JSDataPromise; + + destroyAll(params?:DSFilterParams, options?:DSAdapterOperationConfiguration):JSDataPromise; + + digest():void; + + eject(id:string, options?:DSConfiguration):T; + eject(id:number, options?:DSConfiguration):T; + + ejectAll(params:DSFilterParams, options?:DSConfiguration):Array; + + filter(params:DSFilterParams, options?:DSConfiguration):Array; + + find(id:string, options?:DSAdapterOperationConfiguration):JSDataPromise; + find(id:number, options?:DSAdapterOperationConfiguration):JSDataPromise; + + findAll(params:DSFilterParams, options?:DSAdapterOperationConfiguration):JSDataPromise>; + + get(id:string, options?:DSConfiguration):T; + get(id:number, options?:DSConfiguration):T; + + getAll(ids?:Array):Array; + getAll(ids?:Array):Array; + + hasChanges(id:string):boolean; + hasChanges(id:number):boolean; + + inject(attrs:T, options?:DSConfiguration):T; + inject(items:Array, options?:DSConfiguration):Array; + + is(object:Object): boolean; + + lastModified(id?:string):number; // timestamp + lastModified(id?:number):number; // timestamp + + lastSaved(id?:string):number; // timestamp + lastSaved(id?:number):number; // timestamp + + link(id:string, relations?:Array):T; + link(id:number, relations?:Array):T; + + linkAll(params:DSFilterParams, relations?:Array):T; + + linkInverse(id:string, relations?:Array):T; + linkInverse(id:number, relations?:Array):T; + + loadRelations(id:string, relations:string, options?:DSAdapterOperationConfiguration):JSDataPromise; + loadRelations(id:number, relations:string, options?:DSAdapterOperationConfiguration):JSDataPromise; + loadRelations(instance:Object, relations:string, options?:DSAdapterOperationConfiguration):JSDataPromise; + loadRelations(id:string, relations:Array, options?:DSAdapterOperationConfiguration):JSDataPromise; + loadRelations(id:number, relations:Array, options?:DSAdapterOperationConfiguration):JSDataPromise; + loadRelations(instance:Object, relations:Array, options?:DSAdapterOperationConfiguration):JSDataPromise; + + previous(id:string):T; + previous(id:number):T; + + reap(options?:DSConfiguration):JSDataPromise; + + refresh(id:string, options?:DSAdapterOperationConfiguration):JSDataPromise; + refresh(id:number, options?:DSAdapterOperationConfiguration):JSDataPromise; + + save(id:string, options?:DSSaveConfiguration):JSDataPromise; + save(id:number, options?:DSSaveConfiguration):JSDataPromise; + + unlinkInverse(id:string, relations?:Array):T; + unlinkInverse(id:number, relations?:Array):T; + + update(id:string, attrs:any, options?:DSSaveConfiguration):JSDataPromise; + update(id:number, attrs:any, options?:DSSaveConfiguration):JSDataPromise; + + updateAll(attrs:any, params:DSFilterParams, options?:DSAdapterOperationConfiguration):JSDataPromise>; + } + + interface DSFilterParams { + where?: Object; + + limit?: number; + + skip?: number; + offset?: number; + + orderBy?: any; + // wait for union types to be supported + //orderBy?: Array>; + //orderBy?: Array; + //orderBy?: string; + + sort?: any; + // wait for union types to be supported + //sort?: string; + //sort?: Array; + //sort?: Array>; + } + + interface IDSResourceLifecycleValidateEventHandlers { + beforeValidate?: (resourceName:string, data:any, cb:(err:any, data?:any)=>void)=>void; + validate?: (resourceName:string, data:any, cb:(err:any, data?:any)=>void)=>void; + afterValidate?: (resourceName:string, data:any, cb:(err:any, data?:any)=>void)=>void; + } + + interface IDSResourceLifecycleCreateEventHandlers { + beforeCreate?: (resourceName:string, data:any, cb:(err:any, data?:any)=>void)=>void; + afterCreate?: (resourceName:string, data:any, cb:(err:any, data?:any)=>void)=>void; + } + + interface IDSResourceLifecycleCreateInstanceEventHandlers { + beforeCreateInstance?: (resourceName:string, data:any)=>void; + afterCreateInstance?: (resourceName:string, data:any)=>void; + } + + interface IDSResourceLifecycleUpdateEventHandlers { + beforeUpdate?: (resourceName:string, data:any, cb:(err:any, data?:any)=>void)=>void; + afterUpdate?: (resourceName:string, data:any, cb:(err:any, data?:any)=>void)=>void; + } + + interface IDSResourceLifecycleDestroyEventHandlers { + beforeDestroy?: (resourceName:string, data:any, cb:(err:any, data?:any)=>void)=>void; + afterDestroy?: (resourceName:string, data:any, cb:(err:any, data?:any)=>void)=>void; + } + + interface IDSResourceLifecycleInjectEventHandlers { + beforeInject?: (resourceName:string, data:any)=>void; + afterInject?: (resourceName:string, data:any)=>void; + } + + interface IDSResourceLifecycleEjectEventHandlers { + beforeEject?: (resourceName:string, data:any)=>void; + afterEject?: (resourceName:string, data:any)=>void; + } + + interface IDSResourceLifecycleReapEventHandlers { + beforeReap?: (resourceName:string, data:any)=>void; + afterReap?: (resourceName:string, data:any)=>void; + } + + interface IDSResourceLifecycleEventHandlers extends IDSResourceLifecycleCreateEventHandlers, + IDSResourceLifecycleCreateInstanceEventHandlers, + IDSResourceLifecycleValidateEventHandlers, + IDSResourceLifecycleUpdateEventHandlers, + IDSResourceLifecycleDestroyEventHandlers, + IDSResourceLifecycleInjectEventHandlers, + IDSResourceLifecycleEjectEventHandlers, + IDSResourceLifecycleReapEventHandlers { + + } + + //TODO check if those are still valid + // errors + interface DSErrors { + + // types + IllegalArgumentError:DSError + NonexistentResourceError:DSError + RuntimeError:DSError + } + + //TODO check if those are still valid + interface DSError { + new (message?:string):DSError; + message: string; + type: string; + } + + // DSAdapter interface + interface IDSAdapter { + create(config:DSResourceDefinition, attrs:any, options?:DSConfiguration):JSDataPromise; + + destroy(config:DSResourceDefinition, id:string, options?:DSConfiguration):JSDataPromise; + destroy(config:DSResourceDefinition, id:number, options?:DSConfiguration):JSDataPromise; + + destroyAll(config:DSResourceDefinition, params:DSFilterParams, options?:DSConfiguration):JSDataPromise; + + find(config:DSResourceDefinition, id:string, options?:DSConfiguration):JSDataPromise; + find(config:DSResourceDefinition, id:number, options?:DSConfiguration):JSDataPromise; + + findAll(config:DSResourceDefinition, params?:DSFilterParams, options?:DSConfiguration):JSDataPromise; + + update(config:DSResourceDefinition, id:string, attrs:any, options?:DSConfiguration):JSDataPromise; + update(config:DSResourceDefinition, id:number, attrs:any, options?:DSConfiguration):JSDataPromise; + + updateAll(config:DSResourceDefinition, attrs:any, params?:DSFilterParams, options?:DSConfiguration):JSDataPromise; + } +} + From 143ee58d484a6fca6f59314ed141a16d55535fc7 Mon Sep 17 00:00:00 2001 From: reppners Date: Thu, 26 Feb 2015 09:53:11 +0100 Subject: [PATCH 111/185] + added tests + changed type definition to expose definitions as module and as globally defined namespace var --- js-data-angular/js-data-angular-tests.ts | 78 ++++ js-data-angular/js-data-angular.d.ts | 23 +- js-data/js-data-node-tests.ts | 17 + js-data/js-data-tests.ts | 493 +++++++++++++++++++++++ js-data/js-data.d.ts | 84 ++-- 5 files changed, 652 insertions(+), 43 deletions(-) create mode 100644 js-data-angular/js-data-angular-tests.ts create mode 100644 js-data/js-data-node-tests.ts create mode 100644 js-data/js-data-tests.ts diff --git a/js-data-angular/js-data-angular-tests.ts b/js-data-angular/js-data-angular-tests.ts new file mode 100644 index 000000000..670857dec --- /dev/null +++ b/js-data-angular/js-data-angular-tests.ts @@ -0,0 +1,78 @@ +/// + +interface IUser { + +} + +interface CustomScope extends ng.IScope { + + comments: Array; + user: IUser; + users: Array; +} + +angular.module('myApp') + .controller('commentsCtrl', function ($scope:CustomScope, store:JSData_.DS, Comment:JSData_.DSResourceDefinition, User:JSData_.DSResourceDefinition) { + + Comment.findAll().then(function (comments) { + $scope.comments = comments; + }); + + // shortest version + User.bindOne(1, $scope, 'user'); + +// short version + store.bindOne('user', 1, $scope, 'user'); + +// long version + $scope.$watch(function () { + return store.lastModified('user', 1); + }, function () { + $scope.user = store.get('user', 1); + }); + + var params = { + where: { + age: { + '>': 30 + } + } + }; + +// shortest verions + User.bindAll(params, $scope, 'users'); + +// short version + store.bindAll('user', params, $scope, 'users'); + +// long version + $scope.$watch(function () { + return store.lastModified('user'); + }, function () { + $scope.users = store.filter('user', params); + }); + }); + +angular.module('myApp') + .run(function (DS:JSData_.DS) { + // We don't register the "User" resource + // as a service, so it can only be used + // via DS.('user', ...) + // The advantage here is that this code + // is guaranteed to be executed, and you + // only ever have to inject "DS" + DS.defineResource('user'); + }) + .factory('Comment', function (DS:JSData_.DS) { + // This code won't execute unless you actually + // inject "Comment" somewhere in your code. + // Thanks Angular... + // Some like injecting actual Resource + // definitions, instead of just "DS" + return DS.defineResource('comment'); + }); + +angular.module('myApp') + .config(function (DSProvider:JSData_.DSProvider) { + DSProvider.defaults.basePath = '/myApi'; // etc. + }); \ No newline at end of file diff --git a/js-data-angular/js-data-angular.d.ts b/js-data-angular/js-data-angular.d.ts index a7c035722..851512d15 100644 --- a/js-data-angular/js-data-angular.d.ts +++ b/js-data-angular/js-data-angular.d.ts @@ -6,14 +6,25 @@ /// /// -declare module JSData { +declare module JSData_ { - class ngDS extends DS { + interface DSProvider { + defaults:DSConfiguration; + } - // sync methods - bindAll(scope:ng.IScope, expr:string, resourceName:string, params:DSFilterParams, cb?:(err:DSError, items:Array)=>void):Function; + interface DS { - bindOne(scope:ng.IScope, expr:string, resourceName:string, id:string, cb?:(err:DSError, item:T)=>void):Function; - bindOne(scope:ng.IScope, expr:string, resourceName:string, id:number, cb?:(err:DSError, item:T)=>void):Function; + bindAll(resourceName:string, params:DSFilterParams, scope:ng.IScope, expr:string, cb?:(err:DSError, items:Array)=>void):Function; + + bindOne(resourceName:string, id:string, scope:ng.IScope, expr:string, cb?:(err:DSError, item:T)=>void):Function; + bindOne(resourceName:string, id:number, scope:ng.IScope, expr:string, cb?:(err:DSError, item:T)=>void):Function; + } + + interface DSResourceDefinition { + + bindAll(params:DSFilterParams, scope:ng.IScope, expr:string, cb?:(err:DSError, items:Array)=>void):Function; + + bindOne(id:string, scope:ng.IScope, expr:string, cb?:(err:DSError, item:T)=>void):Function; + bindOne(id:number, scope:ng.IScope, expr:string, cb?:(err:DSError, item:T)=>void):Function; } } \ No newline at end of file diff --git a/js-data/js-data-node-tests.ts b/js-data/js-data-node-tests.ts new file mode 100644 index 000000000..a0b39a161 --- /dev/null +++ b/js-data/js-data-node-tests.ts @@ -0,0 +1,17 @@ +/// + +import JSData = require('js-data'); +//TODO +//import DSRedisAdapter = require('js-data-redis') +var store = new JSData.DS(); + +// register and use http by default for async operations +//TODO +//store.registerAdapter('redis', new DSRedisAdapter(), {default: true}); + +// simplest model definition +var User = store.defineResource('user'); + +User.find(1).then(function (user: any) { + user; // { id: 1, name: 'John' } +}); \ No newline at end of file diff --git a/js-data/js-data-tests.ts b/js-data/js-data-tests.ts new file mode 100644 index 000000000..1cb3e8e72 --- /dev/null +++ b/js-data/js-data-tests.ts @@ -0,0 +1,493 @@ +/// + +interface IUser { + id?: number; + name?: string; + age?: number; + first?: string; + last?: string; + comments?:Array; + profile?:any; +} + +interface IUserWithMethod extends IUser { + fullName?: () => string; +} + +interface IUserWithComputedProperty extends IUser { + fullName?: string; +} + +var store = new JSData.DS(); + +// register and use http by default for async operations +//TODO +//store.registerAdapter('http', new DSHttpAdapter(), {default: true}); + +// simplest model definition +var User = store.defineResource('user'); + +User.find(1).then(function (user:IUser) { + user; // { id: 1, name: 'John' } +}); + +var user:IUser = User.createInstance({name: 'John'}); + +var store = new JSData.DS(); +var User = store.defineResource('user'); +var user:IUser = User.inject({id: 1, name: 'John'}); +var user2:IUser = User.inject({id: 1, age: 30}); + +user; // User { id: 1, name: 'John', age: 30 } +user2; // User { id: 1, name: 'John', age: 30 } +User.get(1); // User { id: 1, name: 'John', age: 30 } +user === user2; // true +user === User.get(1); // true +user2 === User.get(1); // true + +var store = new JSData.DS({ + // set a default lifecycle hook + afterCreate: function () { + } +}); + +var User = store.defineResource({ + name: 'user', + // override the hook for this resource + afterCreate: function () { + } +}); + +User.create({ + name: 'john' +}, { + // override the hook just for this method call + afterCreate: function () { + } +}).then(()=> { + +}); + +var store = new JSData.DS(); + +var UserWithMethod = store.defineResource({ + name: 'user', + methods: { + fullName: function () { + return this.first + ' ' + this.last; + } + } +}); + +var userWithMethod = UserWithMethod.createInstance({first: 'John', last: 'Anderson'}); + +userWithMethod.fullName(); // "John Anderson" + +var store = new JSData.DS(); + +var UserWithComputedProperty = store.defineResource({ + name: 'user', + computed: { + // each function's argument list defines the fields + // that the computed property depends on + fullName: ['first', 'last', function (first: string, last: string) { + return first + ' ' + last; + }], + // shortand, use the array syntax above if you want + // you computed properties to work after you've + // minified your code. Shorthand style won't work when minified + initials: function (first: string, last: string) { + return first.toUpperCase()[0] + '. ' + last.toUpperCase()[0] + '.'; + } + } +}); + +var userWithComputedProperty:IUserWithComputedProperty = UserWithComputedProperty.inject({ + id: 1, + first: 'John', + last: 'Anderson' +}); + +userWithComputedProperty.fullName; // "John Anderson" + +userWithComputedProperty.first = 'Fred'; + +// js-data relies on dirty-checking, so the +// computed property (probably) hasn't been updated yet +userWithComputedProperty.fullName; // "John Anderson" + +// If your browser supports Object.observe this will have no effect +// otherwise it will trigger the dirty-checking +store.digest(); + +userWithComputedProperty.fullName; // "Fred Anderson" + +interface IComment { + comments?: any; + profile?: any; +} + +var aComment:JSData_.DSResourceDefinition = store.defineResource('comment'); + +// Get all comments where comment.userId == 5 +aComment.filter({ + where: { + userId: { + '==': 5 + } + } +}); + +// Get all comments where comment.userId == 5 +aComment.filter({ + userId: 5 +}); + +// Get all comments where comment.userId === 5 +aComment.filter({ + where: { + userId: { + '===': 5 + } + } +}); + +// Get all comments where comment.userId != 5 +aComment.filter({ + where: { + userId: { + '!=': 5 + } + } +}); + +// Get all comments where comment.userId !== 5 +aComment.filter({ + where: { + userId: { + '!==': 5 + } + } +}); + +// Get all users where user.age > 30 +User.filter({ + where: { + age: { + '>': 30 + } + } +}); + +// Get all users where user.age >= 30 +User.filter({ + where: { + age: { + '>=': 30 + } + } +}); + +// Get all users where user.age < 30 +User.filter({ + where: { + age: { + '<': 30 + } + } +}); + +// Get all users where user.name is in "John Anderson" +User.filter({ + where: { + name: { + 'in': 'John Anderson' + } + } +}); + +// Get all users where user.role is in ["admin", "owner"] +User.filter({ + where: { + role: { + 'in': ['admin', 'owner'] + } + } +}); + +// Get all users where user.name is NOT in "John Anderson" +User.filter({ + where: { + name: { + 'notIn': 'John Anderson' + } + } +}); + +// Get all users where user.role is NOT in ["admin", "owner"] +User.filter({ + where: { + role: { + 'notIn': ['admin', 'owner'] + } + } +}); + +// Get all users where user.name contains "John" +User.filter({ + where: { + name: { + 'contains': 'John' + } + } +}); + +// Get all users where user.roles contains "admin" +User.filter({ + where: { + roles: { + 'contains': 'admin' + } + } +}); + +// Sorts users by age in ascending order +User.filter({ + orderBy: 'age' +}); + +// Sorts users by age in descending order +User.filter({ + orderBy: ['age', 'DESC'] +}); + +// Sorts users by age in descending order and then sort by name in ascending order to break a tie +User.filter({ + orderBy: [ + ['age', 'DESC'], + ['name', 'ASC'] + ] +}); + +var PAGE_SIZE = 20; +var currentPage = 1; + +interface IPost { + +} + +var Post:JSData_.DSResourceDefinition; + +// Grab the first "page" of posts +Post.filter({ + offset: PAGE_SIZE * (currentPage - 1), + limit: PAGE_SIZE +}); + +var User = store.defineResource({ + name: 'user', + relations: { + hasMany: { + comment: { + localField: 'comments', + foreignKey: 'userId' + } + }, + hasOne: { + profile: { + localField: 'profile', + foreignKey: 'userId' + } + }, + belongsTo: { + organization: { + localKey: 'organizationId', + localField: 'organization', + + // if you add this to a belongsTo relation + // then js-data will attempt to use + // a nested url structure, e.g. /organization/15/user/4 + parent: true + } + } + } +}); + +var Organization = store.defineResource({ + name: 'organization', + relations: { + hasMany: { + // this is an example of multiple relations + // of the same type to the same resource + user: [ + { + localField: 'users', + foreignKey: 'organizationId' + }, + { + localField: 'owners', + foreignKey: 'organizationId' + } + ] + } + } +}); + +var Profile = store.defineResource({ + name: 'profile', + relations: { + belongsTo: { + user: { + localField: 'user', + localKey: 'userId' + } + } + } +}); + +var OtherComment = store.defineResource({ + name: 'comment', + relations: { + belongsTo: { + user: { + localField: 'user', + localKey: 'userId' + } + } + } +}); + +User.find(10).then(function (user:IUser) { + // let's assume the server only returned the user + user.comments; // undefined + user.profile; // undefined + + User.loadRelations(user, ['comment', 'profile']).then(function (user:IUser) { + user.comments; // array + user.profile; // object + }); +}); + +var OtherOtherComment = store.defineResource({ + name: 'comment', + relations: { + belongsTo: { + post: { + parent: true, + localKey: 'postId', + localField: 'post' + } + } + } +}); + +// The comment isn't in the data store yet, so js-data wouldn't know +// what the id of the parent "post" would be, so we pass it in manually +OtherOtherComment.find(5, {params: {postId: 4}}); // GET /post/4/comment/5 + +// vs + +OtherOtherComment.find(5); // GET /comment/5 + +OtherOtherComment.inject({id: 1, postId: 2}); + +// We don't have to provide the parentKey here +// because js-data found it in the comment +OtherOtherComment.update(1, {content: 'stuff'}); // PUT /post/2/comment/1 + +// If you don't want the nested for just one of the calls then +// you can do the following: +OtherOtherComment.update(1, {content: 'stuff'}, {params: {postId: false}}); // PUT /comment/1 + +var store = new JSData.DS({ + // set the default + beforeCreate: function (resource, data, cb) { + // do something general + cb(null, data); + } +}); + +var User = store.defineResource({ + name: 'user', + // set just for this resource + beforeCreate: function (resource, data, cb) { + // do something more specific to "users" + cb(null, data); + } +}); + +User.create({name: 'John'}, { + // set just for this method call + beforeCreate: function (resource, data, cb) { + // do something specific for this method call + cb(null, data); + } +}); + +module CustomAdapterTest { + + class MyCustomAdapter implements JSData_.IDSAdapter { + + // All of the methods shown here must return a promise + +// "definition" is a resource defintion that would +// be returned by DS#defineResource + +// "options" would be the options argument that +// was passed into the DS method that is calling +// the adapter method + + create(definition:JSData_.DSResourceDefinition, attrs:Object, options:JSData_.DSConfiguration):JSData_.JSDataPromise { + // Must resolve the promise with the created item + + var promise:JSData_.JSDataPromise; + return promise; + } + + find(definition:JSData_.DSResourceDefinition, id:any, options:JSData_.DSConfiguration):JSData_.JSDataPromise { + // Must resolve the promise with the found item + + var promise:JSData_.JSDataPromise; + return promise; + } + + findAll(definition:JSData_.DSResourceDefinition, params:JSData_.DSFilterParams, options:JSData_.DSConfiguration):JSData_.JSDataPromise { + // Must resolve the promise with the found items + + var promise:JSData_.JSDataPromise; + return promise; + } + + update(definition:JSData_.DSResourceDefinition, id:any, attrs:Object, options:JSData_.DSConfiguration):JSData_.JSDataPromise { + // Must resolve the promise with the updated items + + var promise:JSData_.JSDataPromise; + return promise; + } + + updateAll(definition:JSData_.DSResourceDefinition, attrs:Object, params:JSData_.DSFilterParams, options:JSData_.DSConfiguration):JSData_.JSDataPromise { + // Must resolve the promise with the updated items + + var promise:JSData_.JSDataPromise; + return promise; + } + + destroy(definition:JSData_.DSResourceDefinition, id:any, options:JSData_.DSConfiguration):JSData_.JSDataPromise { + // Must return a promise + + var promise:JSData_.JSDataPromise; + return promise; + } + + destroyAll(definition:JSData_.DSResourceDefinition, params:JSData_.DSFilterParams, options:JSData_.DSConfiguration):JSData_.JSDataPromise { + // Must return a promise + + var promise:JSData_.JSDataPromise; + return promise; + } + } + + var store = new JSData.DS(); + store.registerAdapter('mca', new MyCustomAdapter(), {default: true}); + // the data store will now use your custom adapter by default +} \ No newline at end of file diff --git a/js-data/js-data.d.ts b/js-data/js-data.d.ts index ce06edd89..13fc5e691 100644 --- a/js-data/js-data.d.ts +++ b/js-data/js-data.d.ts @@ -9,35 +9,29 @@ /// -declare class JSDataPromise extends Promise { - - // enhanced with finally - finally(finallyCb?: () => U): Promise; -} - /////////////////////////////////////////////////////////////////////////////// // js-data module (js-data.js) /////////////////////////////////////////////////////////////////////////////// -// Support AMD require -declare module 'js-data' { - export = JSData; -} +// defining what exists in JSData and how it looks +declare module JSData_ { -declare module JSData { + class JSDataPromise extends Promise { - class DS { + // enhanced with finally + finally(finallyCb?:() => U):Promise; + } - constructor(config?:DSConfiguration); + //TODO switch to class again when typescript supports open ended class declaration + interface DS { + + new(config?:DSConfiguration):DS; + + // rather undocumented + errors:DSErrors; defaults:DSConfiguration; - //TODO check if still exists - adapters:any; // Object consists of key-values pairs where the key is the name of the adapter and the value is - // the adapter itself. - //TODO check if still exists - errors:DSErrors; - changeHistory(resourceName:string, id?:string):Array; changeHistory(resourceName:string, id?:number):Array; @@ -72,7 +66,7 @@ declare module JSData { find(resourceName:string, id:string, options?:DSAdapterOperationConfiguration):JSDataPromise; find(resourceName:string, id:number, options?:DSAdapterOperationConfiguration):JSDataPromise; - findAll(resourceName:string, params:DSFilterParams, options?:DSAdapterOperationConfiguration):JSDataPromise>; + findAll(resourceName:string, params?:DSFilterParams, options?:DSAdapterOperationConfiguration):JSDataPromise>; get(resourceName:string, id:string, options?:DSConfiguration):T; get(resourceName:string, id:number, options?:DSConfiguration):T; @@ -117,7 +111,7 @@ declare module JSData { refresh(resourceName:string, id:string, options?:DSAdapterOperationConfiguration):JSDataPromise; refresh(resourceName:string, id:number, options?:DSAdapterOperationConfiguration):JSDataPromise; - registerAdapter(adapterId: string, adapter:IDSAdapter, options?:{default: boolean}):void; + registerAdapter(adapterId:string, adapter:IDSAdapter, options?:{default: boolean}):void; save(resourceName:string, id:string, options?:DSSaveConfiguration):JSDataPromise; save(resourceName:string, id:number, options?:DSSaveConfiguration):JSDataPromise; @@ -128,7 +122,7 @@ declare module JSData { update(resourceName:string, id:string, attrs:any, options?:DSSaveConfiguration):JSDataPromise; update(resourceName:string, id:number, attrs:any, options?:DSSaveConfiguration):JSDataPromise; - updateAll(resourceName:string, attrs:any, params:DSFilterParams, options?:DSAdapterOperationConfiguration):JSDataPromise>; + updateAll(resourceName:string, attrs:any, params?:DSFilterParams, options?:DSAdapterOperationConfiguration):JSDataPromise>; } interface DSConfiguration extends IDSResourceLifecycleEventHandlers { @@ -140,8 +134,10 @@ declare module JSData { defaultAdapter?: string; defaultFilter?: (collection:Array, resourceName:string, params:DSFilterParams, options:DSConfiguration)=>Array; eagerEject?: boolean; + // TODO enable when eagerInject in DS#create is implemented + //eagerInject?: boolean; endpoint?: string; - error?: (message?: any, ...optionalParams: any[])=> void; + error?: (message?:any, ...optionalParams:any[])=> void; fallbackAdapters?: Array; findAllFallbackAdapters?: Array; findAllStrategy?: string; @@ -152,10 +148,13 @@ declare module JSData { findInverseLinks?: boolean; findStrategy?: string idAttribute?: string; - ignoredChanges?:Array; + ignoredChanges?: Array; + // TODO ignoreMissing is undocumented + //ignoreMissing: boolean; keepChangeHistory?: boolean; loadFromServer?: boolean; log?: any; + // TODO wait for union types to be supported // log: (message?: any, ...optionalParams: any[])=> void; // log: boolean; maxAge?: number; @@ -166,7 +165,7 @@ declare module JSData { strategy?: string; upsert?: boolean; useClass?: boolean; - useFilter: boolean; + useFilter?: boolean; } interface DSAdapterOperationConfiguration extends DSConfiguration { @@ -224,7 +223,7 @@ declare module JSData { find(id:string, options?:DSAdapterOperationConfiguration):JSDataPromise; find(id:number, options?:DSAdapterOperationConfiguration):JSDataPromise; - findAll(params:DSFilterParams, options?:DSAdapterOperationConfiguration):JSDataPromise>; + findAll(params?:DSFilterParams, options?:DSAdapterOperationConfiguration):JSDataPromise>; get(id:string, options?:DSConfiguration):T; get(id:number, options?:DSConfiguration):T; @@ -256,10 +255,10 @@ declare module JSData { loadRelations(id:string, relations:string, options?:DSAdapterOperationConfiguration):JSDataPromise; loadRelations(id:number, relations:string, options?:DSAdapterOperationConfiguration):JSDataPromise; - loadRelations(instance:Object, relations:string, options?:DSAdapterOperationConfiguration):JSDataPromise; + loadRelations(instance:T, relations:string, options?:DSAdapterOperationConfiguration):JSDataPromise; loadRelations(id:string, relations:Array, options?:DSAdapterOperationConfiguration):JSDataPromise; loadRelations(id:number, relations:Array, options?:DSAdapterOperationConfiguration):JSDataPromise; - loadRelations(instance:Object, relations:Array, options?:DSAdapterOperationConfiguration):JSDataPromise; + loadRelations(instance:T, relations:Array, options?:DSAdapterOperationConfiguration):JSDataPromise; previous(id:string):T; previous(id:number):T; @@ -278,7 +277,7 @@ declare module JSData { update(id:string, attrs:any, options?:DSSaveConfiguration):JSDataPromise; update(id:number, attrs:any, options?:DSSaveConfiguration):JSDataPromise; - updateAll(attrs:any, params:DSFilterParams, options?:DSAdapterOperationConfiguration):JSDataPromise>; + updateAll(attrs:any, params?:DSFilterParams, options?:DSAdapterOperationConfiguration):JSDataPromise>; } interface DSFilterParams { @@ -290,13 +289,13 @@ declare module JSData { offset?: number; orderBy?: any; - // wait for union types to be supported + // TODO wait for union types to be supported //orderBy?: Array>; //orderBy?: Array; //orderBy?: string; sort?: any; - // wait for union types to be supported + // TODO wait for union types to be supported //sort?: string; //sort?: Array; //sort?: Array>; @@ -354,18 +353,19 @@ declare module JSData { } - //TODO check if those are still valid // errors interface DSErrors { // types - IllegalArgumentError:DSError - NonexistentResourceError:DSError - RuntimeError:DSError + IllegalArgumentError:DSError; + IA:DSError; + RuntimeError:DSError; + R:DSError; + NonexistentResourceError:DSError; + NER:DSError; } - //TODO check if those are still valid - interface DSError { + interface DSError extends Error { new (message?:string):DSError; message: string; type: string; @@ -392,3 +392,13 @@ declare module JSData { } } +// declaring the existing global js object +declare var JSData:{ + DS: JSData_.DS +}; + +//Support node require +declare module 'js-data' { + + export = JSData; +} \ No newline at end of file From cb67739c13ed9104d4527e7ed25ec726c2361fb8 Mon Sep 17 00:00:00 2001 From: reppners Date: Thu, 26 Feb 2015 10:01:27 +0100 Subject: [PATCH 112/185] + initial commit for ds-http-adapter definition --- js-data-http/js-data-http.d.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 js-data-http/js-data-http.d.ts diff --git a/js-data-http/js-data-http.d.ts b/js-data-http/js-data-http.d.ts new file mode 100644 index 000000000..60a279103 --- /dev/null +++ b/js-data-http/js-data-http.d.ts @@ -0,0 +1,13 @@ +// Type definitions for JSData Http Adapter v1.2.0 +// Project: https://github.com/js-data/js-data-http +// Definitions by: Stefan Steinhart +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module JSData_ { + + interface DSHttpAdapter extends IDSAdapter { + + } +} \ No newline at end of file From 3c74c3686d57ef41ee0a3261c5cde9fa77b2ea0b Mon Sep 17 00:00:00 2001 From: Marcin Porebski Date: Thu, 26 Feb 2015 10:31:53 +0100 Subject: [PATCH 113/185] split def. added --- split/split-tests.ts | 16 ++++++++++++++++ split/split.d.ts | 17 +++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 split/split-tests.ts create mode 100644 split/split.d.ts diff --git a/split/split-tests.ts b/split/split-tests.ts new file mode 100644 index 000000000..71af1a085 --- /dev/null +++ b/split/split-tests.ts @@ -0,0 +1,16 @@ +/// +/// + +import stream = require("stream"); +import split = require("split"); + +var testStream = new stream.Readable(); + +testStream.pipe = function(dest) { + dest.write("This is \r\n new \r\n line"); + return dest; +}; + +testStream.pipe(split(/(\r?\n)/, null, {maxLength: 20})).on("data", function(line) { + console.log("Line: " + line + "\r\n"); +}); diff --git a/split/split.d.ts b/split/split.d.ts new file mode 100644 index 000000000..9bf6a9320 --- /dev/null +++ b/split/split.d.ts @@ -0,0 +1,17 @@ +// Type definitions for split v0.3.3 +// Project: https://github.com/dominictarr/split +// Definitions by: Marcin Porębski +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module "split" { + + interface SplitOptions { + maxLength: number + } + + function split(matcher?:any, mapper?:any, options?: SplitOptions):any; + + export = split; +} \ No newline at end of file From 8385575c31441ffa956768161ebb653f51e7e706 Mon Sep 17 00:00:00 2001 From: reppners Date: Thu, 26 Feb 2015 10:35:21 +0100 Subject: [PATCH 114/185] + ds-http-adapter definition complete with tests --- js-data-http/js-data-http-tests.ts | 167 +++++++++++++++++++++++++++++ js-data-http/js-data-http.d.ts | 35 +++++- 2 files changed, 201 insertions(+), 1 deletion(-) create mode 100644 js-data-http/js-data-http-tests.ts diff --git a/js-data-http/js-data-http-tests.ts b/js-data-http/js-data-http-tests.ts new file mode 100644 index 000000000..41459ed81 --- /dev/null +++ b/js-data-http/js-data-http-tests.ts @@ -0,0 +1,167 @@ +/// + +var adapter = new DSHttpAdapter(); +var store = new JSData.DS(); +store.registerAdapter('http', adapter, { default: true }); + +var ADocument:JSData_.DSResourceDefinition = store.defineResource('document'); + +ADocument.inject({ id: 5, author: 'John' }); + +// bypass the data store +adapter.update(ADocument, 5, { author: 'Johnny' }).then(function (document:any) { + document; // { id: 5, author: 'Johnny' } + + // The updated document has NOT been injected into the data store because we bypassed the data store + ADocument.get(document.id); // { id: 5, author: 'John' } +}); + +// Normally you would just go through the data store +ADocument.update(5, { author: 'Johnny' }).then(function (document:any) { + document; // { id: 5, author: 'Johnny' } + + // the updated document has been injected into the data store + ADocument.get(document.id); // { id: 5, author: 'Johnny' } +}); + +ADocument.inject({ id: 5, author: 'John' }); +ADocument.inject({ id: 6, author: 'John' }); + +// bypass the data store +adapter.updateAll(ADocument, { author: 'Johnny' }, { author: 'John' }).then(function (documents) { + documents[0]; // { id: 5, author: 'Johnny' } + + // The updated documents have NOT been injected into the data store because we bypassed the data store + ADocument.filter({ author: 'John' }); // [{...}, {...}] + ADocument.filter({ author: 'Johnny' }); // [] +}); + +// Normally you would just go through the data store +ADocument.updateAll({ author: 'Johnny' }, { author: 'John' }).then(function (documents) { + documents[0]; // { id: 5, author: 'Johnny' } + + // the updated documents have been injected into the data store + ADocument.filter({ author: 'John' }); // [] + ADocument.filter({ author: 'Johnny' }); // [{...}, {...}] +}); + +adapter.PUT('/user/1', { name: 'Johnny' }).then(function (data) { + data.data; // { id: 1, name: 'Johnny', ... } + data.headers; // {...} + data.status; // 200 + data.config; //{...} +}); + +adapter.POST('/user/1', { name: 'John' }).then(function (data) { + data.data; // { id: 1, name: 'John', ... } + data.headers; // {...} + data.status; // 200 + data.config; //{...} +}); + +adapter.HTTP({ url: '/user/1', method: 'put', data: { name: 'Johnny' }}).then(function (data) { + data.data; // { id: 1, name: 'Johnny', ... } + data.headers; // {...} + data.status; // 200 + data.config; //{...} +}); + +adapter.GET('/user/1').then(function (data) { + data.data; // { id: 1, ... } + data.headers; // {...} + data.status; // 200 + data.config; //{...} +}); + +var User:JSData_.DSResourceDefinition = store.defineResource('user'); + +var params:any = { + age: { + '>': 30 + } +}; + +// bypass the data store +adapter.findAll(User, params).then(function (users) { + // users[0].age; 55 // etc., etc. + + // the users have NOT been injected into the data store because we bypassed the data store + User.filter(params); // [] +}); + +// normally you would go through the data store +User.findAll(params).then(function (users) { + // users[0].age; 55 // etc., etc. + + // the users have been injected into the data store + User.filter(params); // [{...}, {...}, ...] +}); + +// bypass the data store +adapter.find(ADocument, 5).then(function (document:any) { + document; // { id: 5, author: 'John Anderson' } + + // the document has NOT been injected into the data store because we bypassed the data store + ADocument.get(document.id); // undefined +}); + +// Normally you would just go through the data store +ADocument.find(5).then(function (document:any) { + document; // { id: 5, author: 'John Anderson' } + + // the document has been injected into the data store + ADocument.get(document.id); // { id: 5, author: 'John Anderson' } +}); + +var params:any = { + author: 'John' +}; + +// bypass the data store +adapter.destroyAll(ADocument, params).then(function () { + // the documents have NOT been ejected from the data store because we bypassed the data store + ADocument.filter(params); // [{...}, {...}, ...] +}); + +// normally you would go through the data store +ADocument.destroyAll(params).then(function () { + // the documents have been ejected from the data store + ADocument.filter(params); // [] +}); + +ADocument.inject({ id: 5, author: 'John' }); + +// bypass the data store +adapter.destroy(ADocument, 5).then(function () { + // the document is still in the data store because we bypassed the data store + //ADocument.get(document.id); // { id: 5, author: 'John' } +}); + +// Normally you would just go through the data store +ADocument.destroy(5).then(function () { + // the document has been ejected from the data store + //ADocument.get(document.id); // undefined +}); + +adapter.DEL('/user/1').then(function (data) { + data.data; // 1 + data.headers; // {...} + data.status; // 204 + data.config; //{...} +}); + +// bypass the data store +adapter.create(ADocument, { author: 'John' }).then(function (document:any) { + document; // { id: 5, author: 'John' } + + // The new document has NOT been injected into the data store because we bypassed the data store + ADocument.get(document.id); // undefined +}); + +// Normally you would just go through the data store +ADocument.create({ author: 'John' }).then(function (document:any) { + document; // { id: 5, author: 'John' } + + // the new document has been injected into the data store + ADocument.get(document.id); // { id: 5, author: 'John' } +}); \ No newline at end of file diff --git a/js-data-http/js-data-http.d.ts b/js-data-http/js-data-http.d.ts index 60a279103..3a8a8adf0 100644 --- a/js-data-http/js-data-http.d.ts +++ b/js-data-http/js-data-http.d.ts @@ -6,8 +6,41 @@ /// declare module JSData_ { + + interface DSHttpAdapterOptions { + serialize?: (resourceName:string, data:any)=>any; + deserialize?: (resourceName:string, data:any)=>any; + queryTransform?: (resourceName:string, params:DSFilterParams)=>any; + httpConfig?: any; + forceTrailingSlash?: boolean; + log?: any; + // TODO wait for union types to be supported + // log: (message?: any, ...optionalParams: any[])=> void; + // log: boolean; + error?: any; + // TODO wait for union types to be supported + // error: (message?: any, ...optionalParams: any[])=> void; + // error: boolean; + } + + interface DSHttpAdapterPromiseResolveType { + data: any; + headers: any; + status: number; + config: any; + } interface DSHttpAdapter extends IDSAdapter { + new(options?:DSHttpAdapterOptions):DSHttpAdapter; + + // DSHttpAdapter uses axios so options are axios config objects. + HTTP(options?:Object):Promise; + DEL(url:string, data?:Object, options?:Object):Promise; + GET(url:string, data?:Object, options?:Object):Promise; + POST(url:string, data?:Object, options?:Object):Promise; + PUT(url:string, data?:Object, options?:Object):Promise; } -} \ No newline at end of file +} + +declare var DSHttpAdapter:JSData_.DSHttpAdapter; \ No newline at end of file From b164150c4016cabd95376d2bfb6360bc158485f7 Mon Sep 17 00:00:00 2001 From: Marcin Porebski Date: Thu, 26 Feb 2015 10:46:05 +0100 Subject: [PATCH 115/185] split def. fix --- split/split-tests.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/split/split-tests.ts b/split/split-tests.ts index 71af1a085..b9aef877f 100644 --- a/split/split-tests.ts +++ b/split/split-tests.ts @@ -6,11 +6,11 @@ import split = require("split"); var testStream = new stream.Readable(); -testStream.pipe = function(dest) { +testStream.pipe = function(dest: stream.Writable) { dest.write("This is \r\n new \r\n line"); return dest; }; -testStream.pipe(split(/(\r?\n)/, null, {maxLength: 20})).on("data", function(line) { - console.log("Line: " + line + "\r\n"); +testStream.pipe(split(/(\r?\n)/, null, {maxLength: 20})).on("data", function(line: Buffer) { + console.log("Line: " + line.toString('ascii') + "\r\n"); }); From 5aff697f459908c67510bde299a048801dc78a58 Mon Sep 17 00:00:00 2001 From: grapswiz Date: Thu, 26 Feb 2015 19:19:03 +0900 Subject: [PATCH 116/185] Added google.picker.d.ts --- google.picker/google.picker-tests.ts | 18 +++ google.picker/google.picker.d.ts | 224 +++++++++++++++++++++++++++ 2 files changed, 242 insertions(+) create mode 100644 google.picker/google.picker-tests.ts create mode 100644 google.picker/google.picker.d.ts diff --git a/google.picker/google.picker-tests.ts b/google.picker/google.picker-tests.ts new file mode 100644 index 000000000..280765354 --- /dev/null +++ b/google.picker/google.picker-tests.ts @@ -0,0 +1,18 @@ +/// + +var createPicker = () => { + var picker = new google.picker.PickerBuilder() + .addView(new google.picker.DocsUploadView()) + .setOAuthToken("accessToken") + .setDeveloperKey("developerKey") + .setCallback((data:any) => { + var url = "nothing"; + if (data[google.picker.Response.ACTION] == google.picker.Action.PICKED) { + var doc = data[google.picker.Response.DOCUMENTS][0]; + url = doc[google.picker.Document.URL]; + } + }) + .setOrigin("origin") + .build(); + picker.setVisible(true); +}; diff --git a/google.picker/google.picker.d.ts b/google.picker/google.picker.d.ts new file mode 100644 index 000000000..6d0d5a0e3 --- /dev/null +++ b/google.picker/google.picker.d.ts @@ -0,0 +1,224 @@ +// Type definitions for Google Picker API +// Project: https://developers.google.com/picker/ +// Definitions by: grapswiz +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module google { + module picker { + export class PickerBuilder { + constructor(); + + // Add a View to the navigation pane. + addView(viewOrId:any):PickerBuilder; + + // Add a ViewGroup to the top-level navigation pane. + addViewGroup(viewGroup:any):PickerBuilder; + + // Disable a picker feature. + disableFeature(feature:string):PickerBuilder; + + // Enable a picker feature. + enableFeature(feature:string):PickerBuilder; + + // Get the relay URL, used for gadgets.rpc. + getRelayUrl():string; + + // Get the dialog title. + getTitle():string; + + // Disable the title bar from being shown. To re-enable, call setTitle with a non-empty title or undefined. + hideTitleBar():PickerBuilder; + + // Check if a picker Feature is enabled. + isFeatureEnabled(feature:string):boolean; + + // Sets the Google Drive App ID needed to allow application to access the user's files via the Google Drive API. + setAppId(appId:string):PickerBuilder; + + // Set the callback method called when the user picks and item (or items), or cancels. The callback method receives a single callback object. The structure of the callback object is described in the JSON Guide. + setCallback(method:Function):PickerBuilder; + + // Sets the Browser API key obtained from Google Developers Console. See the Developer's Guide for details on how to obtain the Browser API key. + setDeveloperKey(key:string):PickerBuilder; + + // Set the document. + setDocument(document:string):PickerBuilder; + + // ISO 639 language code. If the language is not supported, en-US is used. This method provides an alternative to setting the locale at google.load() time. See the Developer's Guide for a list of supported locales. + setLocale(locale:string):PickerBuilder; + + // Sets an OAuth token to use for authenticating the current user. Depending on the scope of the token, only certain views will display data. Valid scopes are Google Docs, Drive, Photos, YouTube. + setOAuthToken(token:string):PickerBuilder; + + // Sets the origin of picker dialog. The origin should be set to the window.location.protocol + '//' + window.location.host of the top-most page, if your application is running in an iframe. + setOrigin(origin:string):PickerBuilder; + + // Set the relay URL, used for gadgets.rpc. + setRelayUrl(url:string):PickerBuilder; + + // Set the list of MIME types which will be selectable. Use commas to separate MIME types if more than one is required. + setSelectableMimeTypes(type:string):PickerBuilder; + + // Set the preferred dialog size. The dialog will be auto-centered. It has a minimum size of (566,350) and a maximum size of (1051,650). + setSize():PickerBuilder; + + // Set the dialog title. + setTitle(title:string):PickerBuilder; + + // Specify an album ID for photo uploads. See Picasa Web Albums Data API documentation for more information about albums. + setUploadToAlbumId(albumId:string):PickerBuilder; + + // Returns the URI generated by this builder. + toUri():string; + + // Construct the Picker object. The Picker object is returned. + build():Picker; + } + + /** + * Picker is the top level object representing the UI action with the user. These objects are not created directly, but instead use the PickerBuilder object. + */ + export interface Picker { + isVisible(): boolean; + setCallback():Picker; + setRelayUrl(url:string):Picker; + setVisible(visible:boolean):Picker; + } + + /** + * Use DocsUploadView to upload documents to Google Drive. + */ + export class DocsUploadView { + constructor(); + + // Allows the user to select a folder in Google Drive to upload to. + setIncludeFolders(included:boolean):DocsUploadView; + + // Sets the upload destination to the specified folder. This overrides ".setIncludeFolders" to false. + setParent(parentId:string):DocsUploadView; + } + + /** + * DocsView is a subclass of View that can be used for Google Drive views. + */ + export class DocsView { + // Constructor. The ViewId must be one of the Google Drive views. Default is ViewId.DOCS. + constructor(viewId?:string); + + // Show folders in the view items. + setIncludeFolders(included:boolean):DocsView; + + // Allows the user to select a folder in Google Drive. + setSelectFolderEnabled(enabled:boolean):DocsView; + + // Selects which mode the view will use to display the documents. + setMode(mode:string):DocsView; + + // Filters the documents based on whether they are owned by the user, or shared with the user. + setOwnedByMe(me?:boolean):DocsView; + + // Sets the initial parent folder to display. + setParent(parentId:string):DocsView; + + // Filters the documents based on whether they are starred by the user. + setStarred(starred:boolean):DocsView; + } + + /** + * DocsViewMode is an enumerated type for displaying data within a DocsView. Use these values in calls to DocsView.setMode. + */ + export var DocsViewMode:{ + // Display documents in a thumbnail grid. + GRID: string; + // Display documents in a detailed list. + LIST: string; + }; + + export var Feature:{ + // Show only documents owned by the user when showing items from Google Drive. + MINE_ONLY: string; + + // Allow user to choose more than one item. + MULTISELECT_ENABLED: string; + + // Hide the navigation pane. If the navigation pane is hidden, users can only select from the first view chosen. + NAV_HIDDEN: string; + + // For photo uploads, controls whether per-photo selection (as opposed to per-album) selection is enabled. + SIMPLE_UPLOAD_ENABLED: string; + }; + + export var ViewId:{ + DOCS: string; + DOCS_IMAGES: string; + DOCS_IMAGES_AND_VIDEOS: string; + DOCS_VIDEOS: string; + DOCUMENTS: string; + DRAWINGS: string; + FOLDERS: string; + FORMS: string; + IMAGE_SEARCH: string; + MAPS: string; + PDFS: string; + PHOTOS: string; + PHOTO_ALBUMS: string; + PHOTO_UPLOAD: string; + PRESENTATIONS: string; + RECENTLY_PICKED: string; + SPREADSHEETS: string; + VIDEO_SEARCH: string; + WEBCAM: string; + YOUTUBE: string; + }; + + export var Action:{ + CANCEL: string; + PICKED: string; + }; + + /** + * Document is an enumerated type used to convey information about a specific picked item. Only fields which are relevant to the selected item are returned. This value will be in the Response.DOCUMENTS field in the callback data. + */ + export var Document:{ + ADDRESS_LINES: string; + AUDIENCE: string; + DESCRIPTION: string; + DURATION: string; + EMBEDDABLE_URL: string; + ICON_URL: string; + ID: string; + IS_NEW: string; + LAST_EDITED_UTC: string; + LATITUDE: string; + LONGITUDE: string; + MIME_TYPE: string; + NAME: string; + NUM_CHILDREN: string; + PARENT_ID: string; + PHONE_NUMBERS: string; + SERVICE_ID: string; + THUMBNAILS: string; + TYPE: string; + URL: string; + }; + + /** + * Response is an enumerated type used to convey information about the user's picked items. + */ + export var Response:{ + ACTION: string; + DOCUMENTS: string; + PARENTS: string; + VIEW: string; + }; + + export var Type:{ + ALBUM: string; + DOCUMENT: string; + LOCATION: string; + PHOTO: string; + URL: string; + VIDEO: string; + }; + } +} \ No newline at end of file From f9341f81d08e9f8d778a2cc944060321f325e28c Mon Sep 17 00:00:00 2001 From: Michael Zabka Date: Thu, 26 Feb 2015 11:50:56 +0100 Subject: [PATCH 117/185] Add library hooker * on github is named javascript-hooker in case of already existance of hooker repo --- hooker/hooker-tests.ts | 72 ++++++++++++++++++++++++++++++++++++++++++ hooker/hooker.d.ts | 42 ++++++++++++++++++++++++ 2 files changed, 114 insertions(+) create mode 100644 hooker/hooker-tests.ts create mode 100644 hooker/hooker.d.ts diff --git a/hooker/hooker-tests.ts b/hooker/hooker-tests.ts new file mode 100644 index 000000000..d9aea606c --- /dev/null +++ b/hooker/hooker-tests.ts @@ -0,0 +1,72 @@ +/// + +import hooker = require('hooker'); + +// Type definitions for JavaScript Hooker v0.2.3 +// Project: https://github.com/cowboy/javascript-hooker +// Definitions by: Michael Zabka +// Definitions: https://github.com/borisyankov/DefinitelyTyped +function tests() { + var objectToHook: any = { + hello: 'world' + }; + hooker.hook(objectToHook, 'hello', () => { }); + hooker.hook(objectToHook, 'hello', () => { + return null; + }); + hooker.hook(objectToHook, ['hello', 'foo'], () => { }); + hooker.hook(objectToHook, ['hello', 'bar'], () => { + return null; + }); + hooker.hook(objectToHook, 'bar', () => { + return hooker.filter(this, ['foo', 'bar']); + }); + hooker.hook(objectToHook, 'bar', () => { + return hooker.override('good'); + }); + hooker.hook(objectToHook, 'bar', () => { + return hooker.preempt('good'); + }); + hooker.orig(objectToHook, 'hello'); + hooker.orig(objectToHook, ['hello', 'foo']); + hooker.hook(objectToHook, 'foo', { + pre: () => { } + }); + hooker.hook(objectToHook, 'foo', { + pre: () => { + return hooker.preempt(1); + } + }); + hooker.hook(objectToHook, 'foo', { + pre: () => { + return hooker.override(1); + } + }); + hooker.hook(objectToHook, 'foo', { + pre: () => { + return hooker.filter(1, ['abc']); + } + }); + hooker.hook(objectToHook, 'foo', { + post: () => { } + }); + hooker.hook(objectToHook, 'foo', { + post: () => { + return hooker.filter(1, ['abc']); + } + }); + hooker.hook(objectToHook, 'foo', { + once: false + }); + hooker.hook(objectToHook, 'foo', { + passName: true + }); + hooker.hook(objectToHook, 'foo', { + pre: () => { }, + post: () => { + return hooker.filter(this, []); + }, + once: true, + passName: false + }); +} diff --git a/hooker/hooker.d.ts b/hooker/hooker.d.ts new file mode 100644 index 000000000..570805d39 --- /dev/null +++ b/hooker/hooker.d.ts @@ -0,0 +1,42 @@ +// Type definitions for JavaScript Hooker v0.2.3 +// Project: https://github.com/cowboy/javascript-hooker +// Definitions by: Michael Zabka +// Definitions: https://github.com/borisyankov/DefinitelyTyped + + +declare type HookerPostHookFunction = (result: any, ...args: any[]) => IHookerPostHookResult|void; +declare type HookerPreHookFunction = (...args: any[]) => IHookerPreHookResult|void; + +declare module "hooker" { + function hook(object: any, props: string|string[], options: IHookerOptions): void; + function hook(object: any, props: string|string[], prehookFunction: HookerPreHookFunction): void; + function unhook(object: any, props?: string|string[]): string[]; + function orig(object: any, props: string|string[]): Function; + function override(value: any): HookerOverride; + function preempt(value: any): HookerPreempt; + function filter(context: any, args: any[]): HookerFilter; +} + +declare class HookerOverride implements IHookerPostHookResult, IHookerPreHookResult { + value: any; +} + +declare class HookerPreempt implements IHookerPreHookResult { + value: any; +} + +declare class HookerFilter implements IHookerPreHookResult { + context: any; + args: any[]; +} + +interface IHookerPostHookResult {} + +interface IHookerPreHookResult {} + +interface IHookerOptions { + pre?: HookerPreHookFunction; + post?: HookerPostHookFunction; + once?: boolean; + passName?: boolean; +} From 9b250438beb6e455761358c9788768b4f759682b Mon Sep 17 00:00:00 2001 From: Oguzhan Ergin Date: Thu, 26 Feb 2015 15:52:44 +0200 Subject: [PATCH 118/185] Add keys method --- memory-cache/memory-cache.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/memory-cache/memory-cache.d.ts b/memory-cache/memory-cache.d.ts index 1eb9c61cf..ca3ffd738 100644 --- a/memory-cache/memory-cache.d.ts +++ b/memory-cache/memory-cache.d.ts @@ -17,4 +17,5 @@ declare module "memory-cache" { export function debug(bool: boolean): void; export function hits(): number; export function misses(): number; + export function keys() : any; } From b69a3a08f39f0267d38edd38d69a80f2c49c613a Mon Sep 17 00:00:00 2001 From: Robert Imig Date: Thu, 26 Feb 2015 09:09:24 -0500 Subject: [PATCH 119/185] Add definitions for jquery-galleria http://galleria.io/ --- jquery-galleria/jquery-galleria-tests.ts | 23 ++++++++++++++ jquery-galleria/jquery-galleria.d.ts | 39 ++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 jquery-galleria/jquery-galleria-tests.ts create mode 100644 jquery-galleria/jquery-galleria.d.ts diff --git a/jquery-galleria/jquery-galleria-tests.ts b/jquery-galleria/jquery-galleria-tests.ts new file mode 100644 index 000000000..413e368f8 --- /dev/null +++ b/jquery-galleria/jquery-galleria-tests.ts @@ -0,0 +1,23 @@ +/// +module JqueryGalleriaTests { + var container = document.createElement("galleria"); + + var gOptions: GalleriaJS.GalleriaOptions; + + gOptions.lightbox = true; + gOptions.autoplay = true; + + Galleria.run("galleria", gOptions); + + gOptions.lightbox = false; + + Galleria.ready(function() { + this.configure(gOptions).refreshImage(); + }); + + Galleria.run("galleria"); + + gOptions.autoplay = false; + + Galleria.run(); +} \ No newline at end of file diff --git a/jquery-galleria/jquery-galleria.d.ts b/jquery-galleria/jquery-galleria.d.ts new file mode 100644 index 000000000..95b94aa50 --- /dev/null +++ b/jquery-galleria/jquery-galleria.d.ts @@ -0,0 +1,39 @@ +// Type definitions for galleria.js v1.4.2 +// Project: https://github.com/aino/galleria +// Definitions by: Robert Imig +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module GalleriaJS { + + interface GalleriaOptions { + dataSource: GalleriaEntry[]; + autoplay?: boolean; + lightbox?: boolean; + } + + interface GalleriaEntry { + image?: string; + thumbnail?: string; + title?: string; + description?: string; + } + + interface GalleriaFactory { + run(): GalleriaFactory; + run(selector: String): GalleriaFactory; + run(selector: String, options: GalleriaOptions): GalleriaFactory; + + loadTheme(url : String): GalleriaFactory; + configure(options: GalleriaOptions): GalleriaFactory; + + ready( method: () => any): void; + + refreshImage(): GalleriaFactory; + resize(): GalleriaFactory; + load( data: GalleriaEntry[]): GalleriaFactory; + setOptions( options: GalleriaOptions): GalleriaFactory; + } + +} + +declare var Galleria: GalleriaJS.GalleriaFactory; \ No newline at end of file From 93dd2e916d2b19c19c66bca76c2bc601c685c79c Mon Sep 17 00:00:00 2001 From: Heiko Heijenga Date: Thu, 26 Feb 2015 14:34:51 -0800 Subject: [PATCH 120/185] Fixed bad character --- dojo/dojo.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dojo/dojo.d.ts b/dojo/dojo.d.ts index 650258c4a..63cda16dd 100644 --- a/dojo/dojo.d.ts +++ b/dojo/dojo.d.ts @@ -9754,7 +9754,7 @@ declare module dojo { * * * - * + * */ init(): void; } @@ -18375,7 +18375,7 @@ declare module dojo { * * * - * + * */ init(): void; } @@ -25085,7 +25085,7 @@ declare module dojo { * * * - * + * */ init(): void; } From a9facb35210d2cd07ead36c365a2b036c900fbd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A9nes=20Harmath?= Date: Fri, 27 Feb 2015 00:27:57 +0100 Subject: [PATCH 121/185] Add overload for HTML5 polyfill --- jquery.contextMenu/jquery.contextMenu.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/jquery.contextMenu/jquery.contextMenu.d.ts b/jquery.contextMenu/jquery.contextMenu.d.ts index 95e890c20..620564fcd 100644 --- a/jquery.contextMenu/jquery.contextMenu.d.ts +++ b/jquery.contextMenu/jquery.contextMenu.d.ts @@ -1,4 +1,4 @@ -// Type definitions for jQuery contextMenu 1.5.25 +// Type definitions for jQuery contextMenu 1.6.6 // Project: http://medialize.github.com/jQuery-contextMenu/ // Definitions by: Natan Vivo // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -30,4 +30,5 @@ interface JQueryContextMenuOptions { interface JQueryStatic { contextMenu(options?: JQueryContextMenuOptions): JQuery; + contextMenu(type: string): JQuery; } From 79509620fd85e21f91d703574ee02f3c2e3b2f32 Mon Sep 17 00:00:00 2001 From: nojaf Date: Fri, 27 Feb 2015 07:51:31 +0100 Subject: [PATCH 122/185] Added execSync to child_process --- node/node.d.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/node/node.d.ts b/node/node.d.ts index b1e849535..0fff702b3 100644 --- a/node/node.d.ts +++ b/node/node.d.ts @@ -650,6 +650,19 @@ declare module "child_process" { env?: any; encoding?: string; }): ChildProcess; + export function execSync(command: string, options?: { + cwd?: string; + input?: string|Buffer; + stdio?: any; + env?: any; + uid?:number; + gid?:number; + timeout?: number; + maxBuffer?: number; + killSignal?: string; + maxBuffer?:number; + encoding?: string; + }); } declare module "url" { From cc0422bd72640ee8ee721ae245174647f28ef311 Mon Sep 17 00:00:00 2001 From: nojaf Date: Fri, 27 Feb 2015 07:54:52 +0100 Subject: [PATCH 123/185] Removed duplicate member --- node/node.d.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/node/node.d.ts b/node/node.d.ts index 0fff702b3..deae056a1 100644 --- a/node/node.d.ts +++ b/node/node.d.ts @@ -655,14 +655,13 @@ declare module "child_process" { input?: string|Buffer; stdio?: any; env?: any; - uid?:number; - gid?:number; + uid?: number; + gid?: number; timeout?: number; maxBuffer?: number; killSignal?: string; - maxBuffer?:number; encoding?: string; - }); + }): ChildProcess; } declare module "url" { From bb81c937ca33d9d49acd1bbb7df6babf9749dba6 Mon Sep 17 00:00:00 2001 From: Ben Duffield Date: Fri, 27 Feb 2015 05:59:50 -0800 Subject: [PATCH 124/185] Add toArray to moment --- moment/moment.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/moment/moment.d.ts b/moment/moment.d.ts index 841ecd09a..834cc0462 100644 --- a/moment/moment.d.ts +++ b/moment/moment.d.ts @@ -224,7 +224,8 @@ declare module moment { diff(b: Moment): number; diff(b: Moment, unitOfTime: string): number; diff(b: Moment, unitOfTime: string, round: boolean): number; - + + toArray(): number[]; toDate(): Date; toISOString(): string; toJSON(): string; From dcf8a7b14e9c32e4679c89020ff27fb9426fa1c8 Mon Sep 17 00:00:00 2001 From: Max Date: Fri, 27 Feb 2015 17:13:37 -0500 Subject: [PATCH 125/185] Added definitions for Annotation Chart --- .../google.visualization.d.ts | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/google.visualization/google.visualization.d.ts b/google.visualization/google.visualization.d.ts index d9d53ab2b..222faec1d 100644 --- a/google.visualization/google.visualization.d.ts +++ b/google.visualization/google.visualization.d.ts @@ -722,6 +722,49 @@ declare module google { width?: number; } + //#endregion + //#region AnnotationChart + + // https://developers.google.com/chart/interactive/docs/gallery/annotationchart + export class AnnotationChart extends CoreChartBase + { + draw(data: DataTable, options: AnnotationChartOptions): void; + draw(data: DataView, options: AnnotationChartOptions): void; + setVisibleChartRange(start: Date, end: Date): void; + getVisibleChartRange(): {start: Date; end: Date }; + hideDataColumns(columnIndexes: number | number[]): void; + showDataColumns(columnIndexes: number | number[]): void; + } + + // https://developers.google.com/chart/interactive/docs/gallery/annotationchart#Configuration_Options + export interface AnnotationChartOptions + { + allowHtml?: boolean; + allValuesSuffix?: string; + annotationsWidth?: number; + colors?: string[]; + dateFormat?: string; + displayAnnotations?: boolean; + displayAnnotationsFilter?: boolean; + displayDateBarSeparator?: boolean; + displayExactValues?: boolean; + displayLegendDots?: boolean; + displayLegendValues?: boolean; + displayRangeSelector?: boolean; + displayZoomButtons?: boolean; + fill?: number; + legendPosition?: string; + max?: number; + min?: number; + numberFormats?: any; + scaleColumns?: number[]; + scaleFormat?: string; + scaleType?: string; + thickness?: number; + zoomEndTime?: Date; + zoomStartTime?: Date; + } + //#endregion //#region SteppedAreaChart From 819aa8bc552c8aacf526ebf6aa4b2d3a70084688 Mon Sep 17 00:00:00 2001 From: Yuki KAN Date: Sat, 28 Feb 2015 09:34:04 +0900 Subject: [PATCH 126/185] node.d.ts: child_process#send() 2nd argument is optional --- node/node.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/node.d.ts b/node/node.d.ts index b1e849535..c30b2a9b4 100644 --- a/node/node.d.ts +++ b/node/node.d.ts @@ -609,7 +609,7 @@ declare module "child_process" { stderr: stream.Readable; pid: number; kill(signal?: string): void; - send(message: any, sendHandle: any): void; + send(message: any, sendHandle?: any): void; disconnect(): void; } From eb75fdf39e21adcca4fbcd975c79a96a42d07535 Mon Sep 17 00:00:00 2001 From: Vasya Aksyonov Date: Sat, 28 Feb 2015 11:57:08 +0500 Subject: [PATCH 127/185] Expect.js commonjs modules support and tests --- expect.js/expect.js-tests.ts | 4 ++-- expect.js/expect.js.d.ts | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/expect.js/expect.js-tests.ts b/expect.js/expect.js-tests.ts index 098df13bb..7b19219bb 100644 --- a/expect.js/expect.js-tests.ts +++ b/expect.js/expect.js-tests.ts @@ -28,7 +28,7 @@ function test_expect_properties() { expect(0).to.not.include; expect(0).to.not.only.have.own; expect(0).to.only.have.own; - expect(0).be + expect(0).be; } function test_ok() { @@ -118,4 +118,4 @@ function test_lessThan() { function test_fail() { expect().fail(); expect().fail('Custom failure message'); -} +} \ No newline at end of file diff --git a/expect.js/expect.js.d.ts b/expect.js/expect.js.d.ts index 8e5cfe142..2db884b97 100644 --- a/expect.js/expect.js.d.ts +++ b/expect.js/expect.js.d.ts @@ -214,3 +214,9 @@ declare module Expect { own: Assertion; } } + +declare module "expect.js" { + + export = expect; + +} \ No newline at end of file From becc12d995aaba7aaf1db8175124162305549ff5 Mon Sep 17 00:00:00 2001 From: Vasya Aksyonov Date: Sat, 28 Feb 2015 13:46:30 +0500 Subject: [PATCH 128/185] Tests missing --- expect.js/expect.js-commonjs-tests.ts | 123 ++++++++++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 expect.js/expect.js-commonjs-tests.ts diff --git a/expect.js/expect.js-commonjs-tests.ts b/expect.js/expect.js-commonjs-tests.ts new file mode 100644 index 000000000..e95b870d9 --- /dev/null +++ b/expect.js/expect.js-commonjs-tests.ts @@ -0,0 +1,123 @@ +/// + +import expect = require("expect.js"); + +function test_expect() { + expect(); + expect(1); + expect(true); + expect({}); + expect(0); +} + +function test_expect_properties() { + expect(0).be.an; + expect(0).have.own; + expect(0).not.be.an; + expect(0).not.have.own; + expect(0).not.include; + expect(0).not.only.have.own; + expect(0).not.to.be; + expect(0).not.to.have.own; + expect(0).not.to.include; + expect(0).not.to.only.have.own; + expect(0).only.have.own; + expect(0).to.be.an; + expect(0).to.have.own; + expect(0).to.include; + expect(0).to.not.be.an; + expect(0).to.not.have.own; + expect(0).to.not.include; + expect(0).to.not.only.have.own; + expect(0).to.only.have.own; + expect(0).be; +} + +function test_ok() { + expect(true).to.be.ok(); +} + +function test_be() { + expect(1).to.be(1); +} + +function test_equal() { + expect(1).to.equal(1); +} + +function test_eql() { + expect({ a: 'b' }).to.eql({ a: 'b' }); +} + +function test_a() { + // string + expect(5).to.be.a('number'); + expect([]).to.be.an('array'); + + // constructors + expect(5).to.be.a(Number); + expect([]).to.be.an(Array); +} + +function test_match() { + expect('1.2.3').to.match(/[0-9]+\.[0-9]+\.[0-9]+/); +} + +function test_contain() { + // string + expect('hello world').to.contain('world'); + expect('hello world').to.string('world'); + // any + expect([1, 2]).to.contain(1); + expect([1, 2]).to.string(1); +} + +function test_length() { + expect([1,2,3]).to.have.length(3); +} + +function test_empty() { + expect([]).to.be.empty(); +} + +function test_property() { + expect(window).to.have.property('expect'); + expect(window).to.have.property('expect', expect); +} + +function test_key() { + expect({ a: 'b' }).to.have.key('a'); + expect({ a: 'b' }).to.include.key('a'); + expect({ a: 'b', c: 'd' }).to.only.have.keys('a', 'c'); + expect({ a: 'b', c: 'd' }).to.only.have.keys(['a', 'c']); + expect({ a: 'b', c: 'd' }).to.not.only.have.key('a'); +} + +function test_throwException() { + var fn = () => {}; + expect(fn).to.throwError(); + expect(fn).to.throwException(function (e) { + expect(e).to.be.a(SyntaxError); + }); + expect(fn).to.throwException(/matches the exception message/); + expect(fn).to.not.throwException(); +} + +function test_within() { + expect(1).to.be.within(0, Infinity); +} + +function test_greaterThan() { + expect(5).to.be.greaterThan(3); + expect(3).to.be.above(0); +} + +function test_lessThan() { + expect(1).to.be.lessThan(3); + expect(0).to.be.below(3); +} + +function test_fail() { + expect().fail(); + expect().fail('Custom failure message'); +} \ No newline at end of file From c562cf82d4e1a05656057a53a50b4b582621bbdb Mon Sep 17 00:00:00 2001 From: Thomas Stig Jacobsen Date: Sat, 28 Feb 2015 23:38:17 +0100 Subject: [PATCH 129/185] Support for Chrome Cast --- chrome/chrome-cast.ts | 1033 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1033 insertions(+) create mode 100644 chrome/chrome-cast.ts diff --git a/chrome/chrome-cast.ts b/chrome/chrome-cast.ts new file mode 100644 index 000000000..71a530542 --- /dev/null +++ b/chrome/chrome-cast.ts @@ -0,0 +1,1033 @@ +// Type definitions for Chrome Cast application development +// Project: https://developers.google.com/cast/ +// Definitions by: Thomas Stig Jacobsen +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +//////////////////// +// Cast +// @see https://code.google.com/p/chromium/codesearch#chromium/src/ui/file_manager/externs/chrome_cast.js +//////////////////// +declare module chrome.cast { + /** + * @enum {string} + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.AutoJoinPolicy + */ + interface AutoJoinPolicy { + TAB_AND_ORIGIN_SCOPED: string; + ORIGIN_SCOPED: string; + PAGE_SCOPED: string; + } + + /** + * @enum {string} + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.DefaultActionPolicy + */ + interface DefaultActionPolicy { + CREATE_SESSION: string; + CAST_THIS_TAB: string; + } + + /** + * @enum {string} + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.Capability + */ + interface Capability { + VIDEO_OUT: string; + AUDIO_OUT: string; + VIDEO_IN: string; + AUDIO_IN: string; + } + + /** + * @enum {string} + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.ErrorCode + */ + interface ErrorCode { + CANCEL: string; + TIMEOUT: string; + API_NOT_INITIALIZED: string; + INVALID_PARAMETER: string; + EXTENSION_NOT_COMPATIBLE: string; + EXTENSION_MISSING: string; + RECEIVER_UNAVAILABLE: string; + SESSION_ERROR: string; + CHANNEL_ERROR: string; + LOAD_MEDIA_FAILED: string; + } + + /** + * @enum {string} + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.ReceiverAvailability + */ + interface ReceiverAvailability { + AVAILABLE: string; + UNAVAILABLE: string; + } + + /** + * @enum {string} + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.SenderPlatform + */ + interface SenderPlatform { + CHROME: string; + IOS: string; + ANDROID: string; + } + + /** + * @enum {string} + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.ReceiverType + */ + interface ReceiverType { + CAST: string; + HANGOUT: string; + CUSTOM: string; + } + + /** + * @enum {string} + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.ReceiverAction + */ + interface ReceiverAction { + CAST: string; + STOP: string; + } + + + + /** + * @enum {string} + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.SessionStatus + */ + interface SessionStatus { + CONNECTED: string; + DISCONNECTED: string; + STOPPED: string; + } + + /** + * @const {!Array.} + * @see https://developers.google.com/cast/docs/reference/chrome/ + */ + var VERSION: Array; + + /** + * @type {boolean} + */ + var isAvailable: boolean; + + /** + * @param {!chrome.cast.ApiConfig} apiConfig + * @param {function()} successCallback + * @param {function(chrome.cast.Error)} errorCallback + */ + export function initialize( + apiConfig: chrome.cast.ApiConfig, + successCallback: Function, + errorCallback: (error: chrome.cast.Error) => void + ): void; + + /** + * @param {function(!chrome.cast.Session)} successCallback + * @param {function(chrome.cast.Error)} errorCallback + * @param {chrome.cast.SessionRequest=} opt_sessionRequest + * @param {string=} opt_label + */ + export function requestSession( + successCallback: (session: chrome.cast.Session) => void, + errorCallback: (error: chrome.cast.Error) => void, + sessionRequest?: chrome.cast.SessionRequest, + label?: string + ): void + + /** + * @param {string} sessionId The id of the session to join. + */ + export function requestSessionById( + sessionId: string + ): void + + /** + * @param {chrome.cast.ReceiverActionListener} listener + */ + export function addReceiverActionListener( + listener: (receiver: chrome.cast.Receiver, receiverAction: chrome.cast.ReceiverAction) => void + ): void + + /** + * @param {chrome.cast.ReceiverActionListener} listener + */ + export function removeReceiverActionListener( + listener: (receiver: chrome.cast.Receiver, receiverAction: chrome.cast.ReceiverAction) => void + ): void + + /** + * @param {string} message The message to log. + */ + export function logMessage( + message: string + ): void + + /** + * @param {!Array.} receivers + * @param {function()} successCallback + * @param {function(chrome.cast.Error)} errorCallback + */ + export function setCustomReceivers( + receivers: Array, + successCallback: Function, + errorCallback: (error: chrome.cast.Error) => void + ): void + + /** + * @param {!chrome.cast.Receiver} receiver + * @param {function()} successCallback + * @param {function(chrome.cast.Error)} errorCallback + */ + export function setReceiverDisplayStatus( + receiver: chrome.cast.Receiver, + successCallback: Function, + errorCallback: (error: chrome.cast.Error) => void + ) + + interface ApiConfig { + /** + * @param {!chrome.cast.SessionRequest} sessionRequest + * @param {function(!chrome.cast.Session)} sessionListener + * @param {function(!chrome.cast.ReceiverAvailability,Array.)} + * receiverListener + * @param {chrome.cast.AutoJoinPolicy=} opt_autoJoinPolicy + * @param {chrome.cast.DefaultActionPolicy=} opt_defaultActionPolicy + * @constructor + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.ApiConfig + */ + new( + sessionRequest: chrome.cast.SessionRequest, + sessionListener: (session: chrome.cast.Session) => void, + receiverListener: (receiverAvailability: chrome.cast.ReceiverAvailability) => void, + autoJoinPolicy?: chrome.cast.AutoJoinPolicy, + defaultActionPolicy: chrome.cast.DefaultActionPolicy + ); + + sessionRequest: chrome.cast.SessionRequest; + sessionListener: (session: chrome.cast.Session) => void; + receiverListener: (receiverAvailability: chrome.cast.ReceiverAvailability) => void; + autoJoinPolicy?: chrome.cast.AutoJoinPolicy; + defaultActionPolicy: chrome.cast.DefaultActionPolicy; + } + + /** + * @param {!chrome.cast.ErrorCode} code + * @param {string=} opt_description + * @param {Object=} opt_details + * @constructor + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.Error + */ + interface Error { + new( + code: chrome.cast.ErrorCode, + description?: string, + details?: Object + ); + + code: chrome.cast.ErrorCode; + description?: string; + details?: string; + + } + + interface Image { + /** + * @param {string} url + * @constructor + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.Image + */ + new( + url: string + ); + + url: string; + height?: number; + width?: number; + } + + interface SenderApplication { + + new( + platform: chrome.cast.SenderPlatform + ); + + platform: chrome.cast.SenderPlatform; + url?: string; + packageId?: string; + } + + interface SessionRequest { + /** + * @param {string} appId + * @param {!Array.=} opt_capabilities + * @param {number=} opt_timeout + * @constructor + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.SessionRequest + */ + new( + appId: string, + capabilities?: Array, + timeout?: number + ); + + appId: string; + capabilities: Array; + requestSessionTimeout: number; + language?: string; + } + + interface Session { + /** + * @param {string} sessionId + * @param {string} appId + * @param {string} displayName + * @param {!Array.} appImages + * @param {!chrome.cast.Receiver} receiver + * @constructor + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.Session + */ + new( + sessionId: string, + appId: string, + displayName: string, + appImages: Array, + receiver: chrome.cast.Receiver + ); + + sessionId: string; + appId: string; + displayName: string; + appImages: Array; + receiver: chrome.cast.Receiver; + senderApps: Array; + namespaces: Array<{name: string}>; + media: Array; + status: chrome.cast.SessionStatus + + /** + * @param {number} newLevel + * @param {function()} successCallback + * @param {function(chrome.cast.Error)} errorCallback + */ + setReceiverVolumeLevel( + newLevel: number, + successCallback: Function, + errorCallback: (error: chrome.cast.Error) => void + ) + + /** + * @param {boolean} muted + * @param {function()} successCallback + * @param {function(chrome.cast.Error)} errorCallback + */ + setReceiverMuted( + muted: boolean, + successCallback: Function, + errorCallback: (error: chrome.cast.Error) => void + ) + + /** + * @param {function()} successCallback + * @param {function(chrome.cast.Error)} errorCallback + */ + leave( + successCallback: Function, + errorCallback: (error: chrome.cast.Error) => void + ) + + /** + * @param {function()} successCallback + * @param {function(chrome.cast.Error)} errorCallback + */ + stop( + successCallback: Function, + errorCallback: (error: chrome.cast.Error) => void + ) + + /** + * @param {string} namespace + * @param {!Object|string} message + * @param {!function()} successCallback + * @param {function(!chrome.cast.Error)} errorCallback + */ + sendMessage( + namespace: string, + message: string, + successCallback: Function, + errorCallback: (error: chrome.cast.Error) => void + ) + + /** + * @param {function(boolean)} listener + */ + addUpdateListener( + listener: (boolean) => void + ) + + /** + * @param {function(boolean)} listener + */ + removeUpdateListener( + listener: (boolean) => void + ) + + /** + * @param {string} namespace + * @param {function(string,string)} listener + */ + addMessageListener( + namespace: string, + listener: (string, string) => void + ) + + /** + * @param {string} namespace + * @param {function(string,string)} listener + */ + removeMessageListener( + namespace: string, + listener: (string, string) => void + ) + + /** + * @param {function(!chrome.cast.media.Media)} listener + */ + addMediaListener( + listener: (media: chrome.cast.media.Media) => void + ) + + /** + * @param {function(!chrome.cast.media.Media)} listener + */ + removeMediaListener( + listener: (media: chrome.cast.media.Media) => void + ) + + /** + * @param {!chrome.cast.media.LoadRequest} loadRequest + * @param {function(!chrome.cast.media.Media)} successCallback + * @param {function(!chrome.cast.Error)} errorCallback + */ + loadMedia( + loadRequest: chrome.cast.media.LoadRequest, + successCallback: (media: chrome.cast.media.Media) => void, + errorCallback: (error: chrome.cast.Error) => void + ) + } + + interface Receiver { + /** + * @param {string} label + * @param {string} friendlyName + * @param {Array.=} opt_capabilities + * @param {chrome.cast.Volume=} opt_volume + * @constructor + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.Receiver + */ + new( + label: string, + friendlyName: string, + capabilities?: Array, + volume?: chrome.cast.Volume + ); + + label: string; + friendlyName: string; + capabilities: Array; + volume: chrome.cast.Volume; + receiverType: chrome.cast.ReceiverType; + displayStatus: chrome.cast.ReceiverDisplayStatus; + } + + interface ReceiverDisplayStatus { + /** + * @param {string} statusText + * @param {!Array.} appImages + * @constructor + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.ReceiverDisplayStatus + */ + new( + statusText: string, + appImages: Array + ); + + statusText: string; + appImages: Array; + } + + interface Volume { + /** + * @param {?number=} opt_level + * @param {?boolean=} opt_muted + * @constructor + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.Volume + */ + new( + level?: number, + muted?: boolean + ); + + level?: number; + muted?: boolean; + } +} + +declare module chrome.cast.media { + /** + * @enum {string} + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.MediaCommand + */ + interface MediaCommand { + PAUSE: string; + SEEK: string; + STREAM_VOLUME: string; + STREAM_MUTE: string; + } + + /** + * @enum {number} + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.MetadataType + */ + interface MetadataType { + GENERIC: number; + TV_SHOW: number; + MOVIE: number; + MUSIC_TRACK: number; + PHOTO: number; + } + + /** + * @enum {string} + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.PlayerState + */ + interface PlayerState { + IDLE: string; + PLAYING: string; + PAUSED: string; + BUFFERING: string; + } + + /** + * @enum {string} + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.ResumeState + */ + interface ResumeState { + PLAYBACK_START: string; + PLAYBACK_PAUSE: string; + } + + /** + * @enum {string} + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.StreamType + */ + interface StreamType { + BUFFERED: string; + LIVE: string; + OTHER: string; + } + + /** + * @enum {string} + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.IdleReason + */ + interface IdleReason { + CANCELLED: string; + INTERRUPTED: string; + FINISHED: string; + ERROR: string; + } + + /** + * @enum {string} + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.TrackType + */ + interface TrackType { + TEXT: string; + AUDIO: string; + VIDEO: string; + } + + /** + * @enum {string} + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.TextTrackType + */ + interface TextTrackType { + SUBTITLES: string; + CAPTIONS: string; + DESCRIPTIONS: string; + CHAPTERS: string; + METADATA: string; + } + + /** + * @enum {string} + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.TextTrackEdgeType + */ + interface TextTrackEdgeType { + NONE: string; + OUTLINE: string; + DROP_SHADOW: string; + RAISED: string; + DEPRESSED: string; + } + + /** + * @enum {string} + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.TextTrackWindowType + */ + interface TextTrackWindowType { + NONE: string; + NORMAL: string; + ROUNDED_CORNERS: string; + } + + /** + * @enum {string} + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.TextTrackFontGenericFamily + */ + interface TextTrackFontGenericFamily { + SANS_SERIF: string; + MONOSPACED_SANS_SERIF: string; + SERIF: string; + MONOSPACED_SERIF: string; + CASUAL: string; + CURSIVE: string; + SMALL_CAPITALS: string; + } + + /** + * @enum {string} + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.TextTrackFontStyle + */ + interface TextTrackFontStyle { + NORMAL: string; + BOLD: string; + BOLD_ITALIC: string; + ITALIC: string; + } + + interface GetStatusRequest { + /** + * @constructor + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.GetStatusRequest + */ + new(); + + customData: Object; + } + + interface PauseRequest { + /** + * @constructor + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.PauseRequest + */ + new(); + + customData: Object; + } + + interface PlayRequest { + /** + * @constructor + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.PlayRequest + */ + new(); + + customData: Object; + } + + interface SeekRequest { + /** + * @constructor + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.SeekRequest + */ + new(); + + currentTime: number; + resumeState: chrome.cast.media.ResumeState; + customData: Object; + } + + interface StopRequest { + /** + * @constructor + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.StopRequest + */ + new(); + + customData: Object; + } + + interface VolumeRequest { + /** + * @param {!chrome.cast.Volume} volume + * @constructor + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.VolumeRequest + */ + new( + volume: chrome.cast.Volume + ); + + volume: chrome.cast.Volume; + customData: Object; + } + + interface LoadRequest { + /** + * @param {!chrome.cast.media.MediaInfo} mediaInfo + * @constructor + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.LoadRequest + */ + new( + mediaInfo: chrome.cast.media.MediaInfo + ); + + activeTrackIds: Array; + autoplay: boolean; + currentTime: number; + customData: Object; + media: chrome.cast.media.MediaInfo; + } + + interface EditTracksInfoRequest { + /** + * @param {Array.=} opt_activeTrackIds + * @param {chrome.cast.media.TextTrackStyle=} opt_textTrackStyle + * @constructor + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.EditTracksInfoRequest + */ + new( + activeTrackIds?: Array, + textTrackStyle?: chrome.cast.media.TextTrackStyle + ); + + activeTrackIds: Array; + textTrackStyle: chrome.cast.media.TextTrackStyle; + } + + interface GenericMediaMetadata { + /** + * @constructor + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.GenericMediaMetadata + */ + new(); + + metadataType: chrome.cast.media.MetadataType; + title: string; + subtitle: string; + images: Array; + releaseDate: string; + + // Deprecated + type: chrome.cast.media.MetadataType; + releaseYear: number; + } + + interface MovieMediaMetadata { + /** + * @constructor + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.MovieMediaMetadata + */ + new(); + + metadataType: chrome.cast.media.MetadataType; + title: string; + studio: string; + subtitle: string; + images: Array; + releaseDate: string; + + // Deprecated + type: chrome.cast.media.MetadataType; + releaseYear: number; + } + + interface TvShowMediaMetadata { + /** + * @constructor + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.TvShowMediaMetadata + */ + new(); + + metadataType: chrome.cast.media.MetadataType; + seriesTitle: string; + title: string; + season: number; + episode: number; + images: Array; + originalAirdate: string; + + // Deprecated + type: chrome.cast.media.MetadataType; + episodeTitle: string; + seasonNumber: number; + episodeNumber: number; + releaseYear: number; + } + + interface MusicTrackMediaMetadata { + /** + * @constructor + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.MusicTrackMediaMetadata + */ + new(); + + metadataType: chrome.cast.media.MetadataType; + albumName: string; + title: string; + albumArtist: string; + artist: string; + composer: string; + songName: string; + trackNumber: number; + discNumber: number; + images: Array; + releaseDate: string; + + // Deprecated + type: chrome.cast.media.MetadataType; + artistName: string; + releaseYear: number; + } + + interface PhotoMediaMetadata { + /** + * @constructor + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.PhotoMediaMetadata + */ + new(); + + metadataType: chrome.cast.media.MetadataType; + title: string; + artist: string; + location: string; + images: Array; + latitude: number; + longitude: number; + width: number; + height: number; + creationDateTime: string; + + // Deprecated + type: chrome.cast.media.MetadataType; + } + + interface MediaInfo { + /** + * @param {string} contentId + * @param {string} contentType + * @constructor + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.MediaInfo + */ + new( + contentId: string, + contentType: string + ); + + contentId: string; + streamType: chrome.cast.media.StreamType; + contentType: string; + metadata: Object; + duration: number; + tracks: Array; + textTrackStyle: chrome.cast.media.TextTrackStyle; + customData: Object; + } + + interface Media { + /** + * @param {string} sessionId + * @param {number} mediaSessionId + * @constructor + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.Media + */ + new( + sessionId: string, + mediaSessionId: number + ); + + sessionId: string; + mediaSessionId: number; + media: chrome.cast.media.MediaInfo; + playbackRate: number; + playerState: chrome.cast.media.PlayerState; + supportedMediaCommands: Array; + volume: chrome.cast.Volume; + idleReason: chrome.cast.media.IdleReason; + activeTrackIds: Array; + customData: Object; + + // Deprecated + currentTime: number; + + /** + * @param {chrome.cast.media.GetStatusRequest} getStatusRequest + * @param {function()} successCallback + * @param {function(!chrome.cast.Error)} errorCallback + */ + getStatus( + getStatusRequest: chrome.cast.media.GetStatusRequest, + successCallback: Function, + errorCallback: (error: chrome.cast.Error) => void + ): void + + /** + * @param {chrome.cast.media.PlayRequest} playRequest + * @param {function()} successCallback + * @param {function(!chrome.cast.Error)} errorCallback + */ + play( + playRequest: chrome.cast.media.PlayRequest, + successCallback: Function, + errorCallback: (error: chrome.cast.Error) => void + ): void + + /** + * @param {chrome.cast.media.PauseRequest} pauseRequest + * @param {function()} successCallback + * @param {function(!chrome.cast.Error)} errorCallback + */ + pause( + pauseRequest: chrome.cast.media.PauseRequest, + successCallback: Function, + errorCallback: (error: chrome.cast.Error) => void + ): void + + /** + * @param {!chrome.cast.media.SeekRequest} seekRequest + * @param {function()} successCallback + * @param {function(!chrome.cast.Error)} errorCallback + */ + seek( + seekRequest: chrome.cast.media.SeekRequest, + successCallback: Function, + errorCallback: (error: chrome.cast.Error) => void + ): void + + /** + * @param {chrome.cast.media.StopRequest} stopRequest + * @param {function()} successCallback + * @param {function(!chrome.cast.Error)} errorCallback + */ + stop( + stopRequest: chrome.cast.media.StopRequest, + successCallback: Function, + errorCallback: (error: chrome.cast.Error) => void + ): void + + /** + * @param {!chrome.cast.media.VolumeRequest} volumeRequest + * @param {function()} successCallback + * @param {function(!chrome.cast.Error)} errorCallback + */ + setVolume( + volumeRequest: chrome.cast.media.VolumeRequest, + successCallback: Function, + errorCallback: (error: chrome.cast.Error) => void + ): void + + /** + * @param {!chrome.cast.media.EditTracksInfoRequest} editTracksInfoRequest + * @param {function()} successCallback + * @param {function(!chrome.cast.Error)} errorCallback + */ + editTracksInfo( + editTracksInfoRequest: chrome.cast.media.EditTracksInfoRequest, + successCallback: Function, + errorCallback: (error: chrome.cast.Error) => void + ): void + + /** + * @param {!chrome.cast.media.MediaCommand} command + * @return {boolean} + */ + supportsCommand( + command: chrome.cast.media.MediaCommand + ): boolean + + /** + * @param {function(boolean)} listener + */ + addUpdateListener( + listener: (boolean) => void + ) + + /** + * @param {function(boolean)} listener + */ + removeUpdateListener( + listener: (boolean) => void + ) + + // Deprecated + /** + * @return {number} + * @suppress {deprecated} Uses currentTime member to compute estimated time. + */ + getEstimatedTime(): number + } + + interface Track { + /** + * @param {number} trackId + * @param {!chrome.cast.media.TrackType} trackType + * @constructor + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.Track + */ + new( + trackId: number, + trackType: chrome.cast.media.TrackType + ); + + trackId: number; + trackContentId: string; + trackContentType: string; + type: chrome.cast.media.TrackType; + name: string; + language: string; + subtype: chrome.cast.media.TextTrackType; + customData: Object; + } + + interface TextTrackStyle { + /** + * @constructor + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.TextTrackStyle + */ + new(); + + foregroundColor: string; + backgroundColor: string; + edgeType: chrome.cast.media.TextTrackEdgeType; + edgeColor: string; + windowType: chrome.cast.media.TextTrackWindowType; + windowColor: string; + windowRoundedCornerRadius: number; + fontScale: number; + fontFamily: string; + fontGenericFamily: chrome.cast.media.TextTrackFontGenericFamily; + fontStyle: chrome.cast.media.TextTrackFontStyle; + customData: Object; + } +} + +/** + * @namespace + * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.timeout + */ +declare module chrome.cast.media.timeout { + var load: number; + var getStatus: number; + var play: number; + var pause: number; + var seek: number; + var stop: number; + var setVolume: number; + var editTracksInfo: number; +} \ No newline at end of file From 6ea56ebe073a0440da302db4331683afbe513c47 Mon Sep 17 00:00:00 2001 From: jeremyhayes Date: Sat, 28 Feb 2015 22:13:50 -0500 Subject: [PATCH 130/185] codemirror: add Doc.findMarks --- codemirror/codemirror.d.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/codemirror/codemirror.d.ts b/codemirror/codemirror.d.ts index 08005eb67..a187d8ec1 100644 --- a/codemirror/codemirror.d.ts +++ b/codemirror/codemirror.d.ts @@ -544,6 +544,9 @@ declare module CodeMirror { insertLeft?: boolean; }): CodeMirror.TextMarker; + /** Returns an array of all the bookmarks and marked ranges found between the given positions. */ + findMarks(from: CodeMirror.Position, to: CodeMirror.Position): TextMarker[]; + /** Returns an array of all the bookmarks and marked ranges present at the given position. */ findMarksAt(pos: CodeMirror.Position): TextMarker[]; From 5c604dd321634153b4754fc07205c9bedf469d06 Mon Sep 17 00:00:00 2001 From: Steve Schmitt Date: Sat, 28 Feb 2015 21:03:45 -0800 Subject: [PATCH 131/185] Added 'any'/'all' constructors to Predicate; updated heading to breeze 1.5.x --- breeze/breeze-tests.ts | 5 +++++ breeze/breeze.d.ts | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/breeze/breeze-tests.ts b/breeze/breeze-tests.ts index 2510ce9ca..979bc5683 100644 --- a/breeze/breeze-tests.ts +++ b/breeze/breeze-tests.ts @@ -405,6 +405,11 @@ function test_entityQuery() { .where("toUpper(substring(CompanyName, 1, 2))", breeze.FilterQueryOp.Equals, "OM"); var q2 = query.toType("foo").orderBy("foo2"); + var pred = new breeze.Predicate('items', 'any', 'serialNumber', 'contains', '12345'); + var pred = new breeze.Predicate('items', breeze.FilterQueryOp.Any, 'serialNumber', breeze.FilterQueryOp.Contains, '12345'); + var pred = breeze.Predicate.create('items', 'any', 'serialNumber', 'contains', '12345'); + var pred = breeze.Predicate.create('items', breeze.FilterQueryOp.Any, 'serialNumber', breeze.FilterQueryOp.Contains, '12345'); + var json = query.toJSON(); } diff --git a/breeze/breeze.d.ts b/breeze/breeze.d.ts index cc7438e45..8d1a0bdad 100644 --- a/breeze/breeze.d.ts +++ b/breeze/breeze.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Breeze 1.4 +// Type definitions for Breeze 1.5.x // Project: http://www.breezejs.com/ // Definitions by: Boris Yankov // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -10,6 +10,7 @@ // Updated Aug 22 2014 for Breeze 1.4.17 and removing Q dependency - Steve Schmitt ( www.ideablade.com) // Updated Jan 16 2015 for Breeze 1.4.17 to add support for noimplicitany - Kevin Wilson ( www.kwilson.me.uk ) // Updated Jan 20 2015 for Breeze 1.5.2 and merging changes from DefinitelyTyped +// Updated Feb 28 2015 add any/all clause on Predicate declare module breeze.core { @@ -770,6 +771,8 @@ declare module breeze { constructor(property: string, operator: FilterQueryOpSymbol, value: any); constructor(property: string, operator: string, value: { value: any; isLiteral?: boolean; dataType?: breeze.DataType }); constructor(property: string, operator: FilterQueryOpSymbol, value: { value: any; isLiteral?: boolean; dataType?: breeze.DataType }); + constructor(property: string, filterop: FilterQueryOpSymbol, property2: string, filterop2: FilterQueryOpSymbol, value: any); // for any/all clauses + constructor(property: string, filterop: string, property2: string, filterop2: string, value: any); // for any/all clauses /** Create predicate from an expression tree */ constructor(tree: Object); @@ -798,6 +801,8 @@ declare module breeze { (...predicates: Predicate[]): Predicate; (property: string, operator: string, value: any, valueIsLiteral?: boolean): Predicate; (property: string, operator: FilterQueryOpSymbol, value: any, valueIsLiteral?: boolean): Predicate; + (property: string, filterop: FilterQueryOpSymbol, property2: string, filterop2: FilterQueryOpSymbol, value: any): Predicate; // for any/all clauses + (property: string, filterop: string, property2: string, filterop2: string, value: any): Predicate; // for any/all clauses } class QueryOptions { From 4cec771c4d6fde7373e7d04550bda7428f39d655 Mon Sep 17 00:00:00 2001 From: VILIC VANE Date: Mon, 2 Mar 2015 17:22:10 +0800 Subject: [PATCH 132/185] add gsap TweenLite declarations --- gsap/Core.d.ts | 184 ++++++++++++++++++++++++++++++++++++++++++++ gsap/Ease.d.ts | 11 +++ gsap/TweenLite.d.ts | 127 ++++++++++++++++++++++++++++++ gsap/gsap-tests.ts | 6 ++ 4 files changed, 328 insertions(+) create mode 100644 gsap/Core.d.ts create mode 100644 gsap/Ease.d.ts create mode 100644 gsap/TweenLite.d.ts create mode 100644 gsap/gsap-tests.ts diff --git a/gsap/Core.d.ts b/gsap/Core.d.ts new file mode 100644 index 000000000..94ad72d63 --- /dev/null +++ b/gsap/Core.d.ts @@ -0,0 +1,184 @@ +// Type definitions for GSAP v1.16.0 +// Project: http://greensock.com/ +// Definitions by: VILIC VANE +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare class Animation { + /** Base class for all TweenLite, TweenMax, TimelineLite, and TimelineMax classes, providing core methods/properties/functionality, but there is no reason to create an instance of this class directly. */ + constructor(duration?: number, vars?: any); + + /** A place to store any data you want (initially populated with vars.data if it exists). */ + data: any; + + /** [Read-only] Parent timeline. */ + timeline: SimpleTimeLine; + + /** The vars object passed into the constructor which stores configuration variables like onComplete, onUpdate, etc. */ + vars: any; + + /** Gets or sets the animation's initial delay which is the length of time in seconds (or frames for frames-based tweens) before the animation should begin. */ + delay(): number; + delay(value: number): Animation; + + /** Gets or sets the animation's duration, not including any repeats or repeatDelays (which are only available in TweenMax and TimelineMax). */ + duration(): number; + duration(value: number): Animation; + + /** Gets or sets an event callback like "onComplete", "onUpdate", "onStart", "onReverseComplete" or "onRepeat" (onRepeat only applies to TweenMax or TimelineMax instances) along with any parameters that should be passed to that callback. */ + eventCallback(type: string): Function; + eventCallback(type: string, callback: Function, params?: any[], scope?: any): Animation; + + /** Clears any initialization data (like starting/ending values in tweens) which can be useful if, for example, you want to restart a tween without reverting to any previously recorded starting values. */ + invalidate(): Animation; + + /** Indicates whether or not the animation is currently active (meaning the virtual playhead is actively moving across this instance's time span and it is not paused, nor are any of its ancestor timelines). */ + isActive(): boolean; + + /** Kills the animation entirely or in part depending on the parameters. */ + kill(vars?: any, target?: any): Animation; + + /** Pauses the instance, optionally jumping to a specific time. */ + pause(atTime?: any, suppressEvents?: boolean): Animation; + + /** Gets or sets the animation's paused state which indicates whether or not the animation is currently paused. */ + paused(): boolean; + paused(value: boolean): Animation; + + /** Begins playing forward, optionally from a specific time (by default playback begins from wherever the playhead currently is). */ + play(from?: any, suppressEvents?: boolean): Animation; + + /** Gets or sets the animations's progress which is a value between 0 and 1 indicating the position of the virtual playhead (excluding repeats) where 0 is at the beginning, 0.5 is at the halfway point, and 1 is at the end (complete). */ + progress(): number; + progress(value: number, suppressEvents?: boolean): Animation; + + /** Restarts and begins playing forward from the beginning. */ + restart(includeDelay?: boolean, suppressEvents?: boolean): Animation; + + /** Resumes playing without altering direction (forward or reversed), optionally jumping to a specific time first. */ + resume(from?: any, suppressEvents?: boolean): Animation; + + /** Reverses playback so that all aspects of the animation are oriented backwards including, for example, a tween's ease. */ + reverse(from?: any, suppressEvents?: boolean): Animation; + + /** Gets or sets the animation's reversed state which indicates whether or not the animation should be played backwards. */ + reversed(): boolean; + reversed(value: boolean): Animation; + + /** Jumps to a specific time without affecting whether or not the instance is paused or reversed. */ + seek(time: any, suppressEvents?: boolean): Animation; + + /** Gets or sets the time at which the animation begins on its parent timeline (after any delay that was defined). */ + startTime(): number; + startTime(value: number): Animation; + + /** Gets or sets the local position of the playhead (essentially the current time), described in seconds (or frames for frames-based animations) which will never be less than 0 or greater than the animation's duration. */ + time(): number; + time(value: number, suppressEvents?: boolean): Animation; + + /** Factor that's used to scale time in the animation where 1 = normal speed (the default), 0.5 = half speed, 2 = double speed, etc. */ + timeScale(): number; + timeScale(value: number): Animation; + + /** Gets or sets the animation's total duration including any repeats or repeatDelays (which are only available in TweenMax and TimelineMax). */ + totalDuration(): number; + totalDuration(value: number): Animation; + + /** Gets or sets the animation's total progress which is a value between 0 and 1 indicating the position of the virtual playhead (including repeats) where 0 is at the beginning, 0.5 is at the halfway point, and 1 is at the end (complete). */ + totalProgress(): number; + totalProgress(value: number, suppressEvents?: boolean): Animation; + + /** Gets or sets the position of the playhead according to the totalDuration which includes any repeats and repeatDelays (only available in TweenMax and TimelineMax). */ + totalTime(): number; + totalTime(time: number, suppressEvents?: boolean): Animation; +} + +declare class SimpleTimeLine extends Animation { + /** SimpleTimeline is the base class for TimelineLite and TimelineMax, providing the most basic timeline functionality and it is used for the root timelines in TweenLite but is only intended for internal use in the GreenSock tweening platform. It is meant to be very fast and lightweight. */ + constructor(vars?: any); + + /** If true, child tweens/timelines will be removed as soon as they complete. */ + autoRemoveChildren: boolean; + + /** Controls whether or not child tweens/timelines are repositioned automatically (changing their startTime) in order to maintain smooth playback when properties are changed on-the-fly. */ + smoothChildTiming: boolean; + + /** Adds a TweenLite, TweenMax, TimelineLite, or TimelineMax instance to the timeline at a specific time. */ + add(child: any, position?: any, align?: string, stagger?: number): SimpleTimeLine; + + /** renders */ + render(time: number, suppressEvents?: boolean, force?: boolean): SimpleTimeLine; + + // INHERITANCE FROM ANIMATION + + /** Gets or sets the animation's initial delay which is the length of time in seconds (or frames for frames-based tweens) before the animation should begin. */ + delay(): number; + delay(value: number): SimpleTimeLine; + + /** Gets or sets the animation's duration, not including any repeats or repeatDelays (which are only available in TweenMax and TimelineMax). */ + duration(): number; + duration(value: number): SimpleTimeLine; + + /** Gets or sets an event callback like "onComplete", "onUpdate", "onStart", "onReverseComplete" or "onRepeat" (onRepeat only applies to TweenMax or TimelineMax instances) along with any parameters that should be passed to that callback. */ + eventCallback(type: string): Function; + eventCallback(type: string, callback: Function, params?: any[], scope?: any): SimpleTimeLine; + + /** Clears any initialization data (like starting/ending values in tweens) which can be useful if, for example, you want to restart a tween without reverting to any previously recorded starting values. */ + invalidate(): SimpleTimeLine; + + /** Kills the animation entirely or in part depending on the parameters. */ + kill(vars?: any, target?: any): SimpleTimeLine; + + /** Pauses the instance, optionally jumping to a specific time. */ + pause(atTime?: any, suppressEvents?: boolean): SimpleTimeLine; + + /** Gets or sets the animation's paused state which indicates whether or not the animation is currently paused. */ + paused(): boolean; + paused(value: boolean): SimpleTimeLine; + + /** Begins playing forward, optionally from a specific time (by default playback begins from wherever the playhead currently is). */ + play(from?: any, suppressEvents?: boolean): SimpleTimeLine; + + /** Gets or sets the animations's progress which is a value between 0 and 1 indicating the position of the virtual playhead (excluding repeats) where 0 is at the beginning, 0.5 is at the halfway point, and 1 is at the end (complete). */ + progress(): number; + progress(value: number, suppressEvents?: boolean): SimpleTimeLine; + + /** Restarts and begins playing forward from the beginning. */ + restart(includeDelay?: boolean, suppressEvents?: boolean): SimpleTimeLine; + + /** Resumes playing without altering direction (forward or reversed), optionally jumping to a specific time first. */ + resume(from?: any, suppressEvents?: boolean): SimpleTimeLine; + + /** Reverses playback so that all aspects of the animation are oriented backwards including, for example, a tween's ease. */ + reverse(from?: any, suppressEvents?: boolean): SimpleTimeLine; + + /** Gets or sets the animation's reversed state which indicates whether or not the animation should be played backwards. */ + reversed(): boolean; + reversed(value: boolean): SimpleTimeLine; + + /** Jumps to a specific time without affecting whether or not the instance is paused or reversed. */ + seek(time: any, suppressEvents?: boolean): SimpleTimeLine; + + /** Gets or sets the time at which the animation begins on its parent timeline (after any delay that was defined). */ + startTime(): number; + startTime(value: number): SimpleTimeLine; + + /** Gets or sets the local position of the playhead (essentially the current time), described in seconds (or frames for frames-based animations) which will never be less than 0 or greater than the animation's duration. */ + time(): number; + time(value: number, suppressEvents?: boolean): SimpleTimeLine; + + /** Factor that's used to scale time in the animation where 1 = normal speed (the default), 0.5 = half speed, 2 = double speed, etc. */ + timeScale(): number; + timeScale(value: number): SimpleTimeLine; + + /** Gets or sets the animation's total duration including any repeats or repeatDelays (which are only available in TweenMax and TimelineMax). */ + totalDuration(): number; + totalDuration(value: number): SimpleTimeLine; + + /** Gets or sets the animation's total progress which is a value between 0 and 1 indicating the position of the virtual playhead (including repeats) where 0 is at the beginning, 0.5 is at the halfway point, and 1 is at the end (complete). */ + totalProgress(): number; + totalProgress(value: number, suppressEvents?: boolean): SimpleTimeLine; + + /** Gets or sets the position of the playhead according to the totalDuration which includes any repeats and repeatDelays (only available in TweenMax and TimelineMax). */ + totalTime(): number; + totalTime(time: number, suppressEvents?: boolean): SimpleTimeLine; +} \ No newline at end of file diff --git a/gsap/Ease.d.ts b/gsap/Ease.d.ts new file mode 100644 index 000000000..26689f438 --- /dev/null +++ b/gsap/Ease.d.ts @@ -0,0 +1,11 @@ +// Type definitions for GSAP v1.16.0 +// Project: http://greensock.com/ +// Definitions by: VILIC VANE +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare class Ease { + constructor(func?: Function, extraParams?: any[], type?: number, power?: number); + + /** Translates the tween's progress ratio into the corresponding ease ratio. */ + getRatio(p: number): number; +} \ No newline at end of file diff --git a/gsap/TweenLite.d.ts b/gsap/TweenLite.d.ts new file mode 100644 index 000000000..fb0e4d61a --- /dev/null +++ b/gsap/TweenLite.d.ts @@ -0,0 +1,127 @@ +// Type definitions for GSAP v1.16.0 +// Project: http://greensock.com/ +// Definitions by: VILIC VANE +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare class TweenLite { + constructor(target: any, duration: number, vars: any); + + /** Provides An easy way to change the default easing equation. */ + static defaultEase: Ease; + + /** Provides An easy way to change the default overwrite mode. */ + static defaultOverwrite: string; + + /** The selector engine (like jQuery) that should be used when a tween receives a string as its target, like TweenLite.to("#myID", 1, {x:"100px"}). */ + static selector: (query: string) => any; + + /** [READ-ONLY] Target object (or array of objects) whose properties the tween affects. */ + target: any; + + /** The object that dispatches a "tick" event each time the engine updates, making it easy for you to add your own listener(s) to run custom logic after each update (great for game developers). */ + static ticker: any; + + /** Provides a simple way to call a function after a set amount of time (or frames). */ + static delayedCall(delay: number, callback: Function, params?: any[], scope?: any, useFrames?: boolean): TweenLite; + + /** Static method for creating a TweenLite instance that tweens backwards - you define the BEGINNING values and the current values are used as the destination values which is great for doing things like animating objects onto the screen because you can set them up initially the way you want them to look at the end of the tween and then animate in from elsewhere. */ + static from(target: any, duration: number, vars: any): TweenLite; + + /** Static method for creating a TweenLite instance that allows you to define both the starting and ending values (as opposed to to() and from() tweens which are based on the target's current values at one end or the other). */ + static fromTo(target: any, duration: number, fromVars: any, toVars: any): TweenLite; + + /** Returns an array containing all the tweens of a particular target (or group of targets) that have not been released for garbage collection yet which typically happens within a few seconds after the tween completes. */ + static getTweensOf(target: any, onlyActive?: boolean): TweenLite[]; + + /** [override] Clears any initialization data (like starting/ending values in tweens) which can be useful if, for example, you want to restart a tween without reverting to any previously recorded starting values. */ + invalidate(): TweenLite; + + /** Immediately kills all of the delayedCalls to a particular function. */ + static killDelayedCallsTo(func: Function): void; + + /** Kills all the tweens (or specific tweening properties) of a particular object or delayedCalls to a particular function. */ + static killTweensOf(target: any, onlyActive?: boolean, vars?: any): void; + + /** Permits you to control what happens when too much time elapses between two ticks (updates) of the engine, adjusting the core timing mechanism to compensate and avoid "jumps". */ + static lagSmoothing(threshold: number, adjustedLag: number): void; + + /** Forces a render of all active tweens which can be useful if, for example, you set up a bunch of from() tweens and then you need to force an immediate render (even of "lazy" tweens) to avoid a brief delay before things render on the very next tick. */ + static render(): void; + + /** Immediately sets properties of the target accordingly - essentially a zero-duration to() tween with a more intuitive name. */ + static set(target: any, vars: any): TweenLite; + + /** Static method for creating a TweenLite instance that animates to the specified destination values (from the current values). */ + static to(target: any, duration: number, vars: any): TweenLite; + + // INHERITANCE FROM ANIMATION + + /** Gets or sets the animation's initial delay which is the length of time in seconds (or frames for frames-based tweens) before the animation should begin. */ + delay(): number; + delay(value: number): TweenLite; + + /** Gets or sets the animation's duration, not including any repeats or repeatDelays (which are only available in TweenMax and TimelineMax). */ + duration(): number; + duration(value: number): TweenLite; + + /** Gets or sets an event callback like "onComplete", "onUpdate", "onStart", "onReverseComplete" or "onRepeat" (onRepeat only applies to TweenMax or TimelineMax instances) along with any parameters that should be passed to that callback. */ + eventCallback(type: string): Function; + eventCallback(type: string, callback: Function, params?: any[], scope?: any): TweenLite; + + /** Kills the animation entirely or in part depending on the parameters. */ + kill(vars?: any, target?: any): TweenLite; + + /** Pauses the instance, optionally jumping to a specific time. */ + pause(atTime?: any, suppressEvents?: boolean): TweenLite; + + /** Gets or sets the animation's paused state which indicates whether or not the animation is currently paused. */ + paused(): boolean; + paused(value: boolean): TweenLite; + + /** Begins playing forward, optionally from a specific time (by default playback begins from wherever the playhead currently is). */ + play(from?: any, suppressEvents?: boolean): TweenLite; + + /** Gets or sets the animations's progress which is a value between 0 and 1 indicating the position of the virtual playhead (excluding repeats) where 0 is at the beginning, 0.5 is at the halfway point, and 1 is at the end (complete). */ + progress(): number; + progress(value: number, suppressEvents?: boolean): TweenLite; + + /** Restarts and begins playing forward from the beginning. */ + restart(includeDelay?: boolean, suppressEvents?: boolean): TweenLite; + + /** Resumes playing without altering direction (forward or reversed), optionally jumping to a specific time first. */ + resume(from?: any, suppressEvents?: boolean): TweenLite; + + /** Reverses playback so that all aspects of the animation are oriented backwards including, for example, a tween's ease. */ + reverse(from?: any, suppressEvents?: boolean): TweenLite; + + /** Gets or sets the animation's reversed state which indicates whether or not the animation should be played backwards. */ + reversed(): boolean; + reversed(value: boolean): TweenLite; + + /** Jumps to a specific time without affecting whether or not the instance is paused or reversed. */ + seek(time: any, suppressEvents?: boolean): TweenLite; + + /** Gets or sets the time at which the animation begins on its parent timeline (after any delay that was defined). */ + startTime(): number; + startTime(value: number): TweenLite; + + /** Gets or sets the local position of the playhead (essentially the current time), described in seconds (or frames for frames-based animations) which will never be less than 0 or greater than the animation's duration. */ + time(): number; + time(value: number, suppressEvents?: boolean): TweenLite; + + /** Factor that's used to scale time in the animation where 1 = normal speed (the default), 0.5 = half speed, 2 = double speed, etc. */ + timeScale(): number; + timeScale(value: number): TweenLite; + + /** Gets or sets the animation's total duration including any repeats or repeatDelays (which are only available in TweenMax and TimelineMax). */ + totalDuration(): number; + totalDuration(value: number): TweenLite; + + /** Gets or sets the animation's total progress which is a value between 0 and 1 indicating the position of the virtual playhead (including repeats) where 0 is at the beginning, 0.5 is at the halfway point, and 1 is at the end (complete). */ + totalProgress(): number; + totalProgress(value: number, suppressEvents?: boolean): TweenLite; + + /** Gets or sets the position of the playhead according to the totalDuration which includes any repeats and repeatDelays (only available in TweenMax and TimelineMax). */ + totalTime(): number; + totalTime(time: number, suppressEvents?: boolean): TweenLite; +} \ No newline at end of file diff --git a/gsap/gsap-tests.ts b/gsap/gsap-tests.ts new file mode 100644 index 000000000..7d941d431 --- /dev/null +++ b/gsap/gsap-tests.ts @@ -0,0 +1,6 @@ +var tween = TweenLite + .to(document.getElementById('some-div'), 1, { + width: '200px', + height: '200px' + }) + .seek(0.5); \ No newline at end of file From 0622fda0b682734381819c6add64062da5fef641 Mon Sep 17 00:00:00 2001 From: VILIC VANE Date: Mon, 2 Mar 2015 17:29:31 +0800 Subject: [PATCH 133/185] add explicit references --- gsap/TweenLite.d.ts | 3 +++ gsap/gsap-tests.ts | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/gsap/TweenLite.d.ts b/gsap/TweenLite.d.ts index fb0e4d61a..ef535e189 100644 --- a/gsap/TweenLite.d.ts +++ b/gsap/TweenLite.d.ts @@ -3,6 +3,9 @@ // Definitions by: VILIC VANE // Definitions: https://github.com/borisyankov/DefinitelyTyped +/// +/// + declare class TweenLite { constructor(target: any, duration: number, vars: any); diff --git a/gsap/gsap-tests.ts b/gsap/gsap-tests.ts index 7d941d431..e1740127b 100644 --- a/gsap/gsap-tests.ts +++ b/gsap/gsap-tests.ts @@ -1,4 +1,6 @@ -var tween = TweenLite +/// + +var tween = TweenLite .to(document.getElementById('some-div'), 1, { width: '200px', height: '200px' From d15019856e102264bd42211ca49a01761d683657 Mon Sep 17 00:00:00 2001 From: Aya Morisawa Date: Mon, 2 Mar 2015 23:09:45 +0900 Subject: [PATCH 134/185] Add prelude-ls.d.ts --- prelude-ls/prelude-ls-tests.ts | 365 +++++++++++++++++++++++++++++++++ prelude-ls/prelude-ls.d.ts | 338 ++++++++++++++++++++++++++++++ 2 files changed, 703 insertions(+) create mode 100644 prelude-ls/prelude-ls-tests.ts create mode 100644 prelude-ls/prelude-ls.d.ts diff --git a/prelude-ls/prelude-ls-tests.ts b/prelude-ls/prelude-ls-tests.ts new file mode 100644 index 000000000..b6e50e225 --- /dev/null +++ b/prelude-ls/prelude-ls-tests.ts @@ -0,0 +1,365 @@ +import prelude = require("prelude-ls"); + +prelude.id(5); //=> 5 +prelude.id({}); //=> {} + +prelude.isType("Undefined", void 8); //=> true +prelude.isType("Boolean", true); //=> true +prelude.isType("Number", 1); //=> true +prelude.isType("String", "hi"); //=> true +prelude.isType("Object", {}); //=> true +prelude.isType("Array", []); //=> true + +prelude.replicate(4, 3); //=> [3, 3, 3, 3] +prelude.replicate(4, "a"); //=> ["a", "a", "a", "a"] +prelude.replicate(0, "a"); //=> [] + + +// List + +prelude.each(x => x.push("boom"), [["a"], ["b"], ["c"]]); +//=> [["a", "boom"], ["b", "boom"], ["c", "boom"]] + +prelude.map(x => x * 2, [1, 2, 3, 4, 5]); //=> [2, 4, 6, 8, 10] +prelude.map(x => x.toUpperCase(), ["ha", "ma"]); //=> ["HA", "MA"] +prelude.map(x => x.num, [{num: 3}, {num: 1}]); //=> [3, 1] + +prelude.compact([0, 1, false, true, "", "ha"]) //=> [1, true, "ha"] + +prelude.filter(x => x < 3, [1, 2, 3, 4, 5]); //=> [1, 2] +prelude.filter(prelude.even, [3, 4, 0]); //=> [4, 0] + +prelude.reject(prelude.odd, [1, 2, 3, 4, 5]); //=> [2, 4] + +prelude.partition(x => x > 60, [49, 58, 76, 43, 88, 77, 90]); //=> [[76, 88, 77, 90], [49, 58, 43]] + +prelude.find(prelude.odd, [2, 4, 6, 7, 8, 9, 10]); //=> 7 + +prelude.head([1, 2, 3, 4, 5]); //=> 1 + +prelude.tail([1, 2, 3, 4, 5]); //=> [2, 3, 4, 5] + +prelude.last([1, 2, 3, 4, 5]); //=> 5 + +prelude.initial([1, 2, 3, 4, 5]); //=> [1, 2, 3, 4] + +prelude.empty([]); //=> true + +prelude.reverse([1, 2, 3]); //=> [3, 2, 1] + +prelude.unique([1, 1, 1, 3, 3, 6, 7, 8]); //=> [1, 3, 6, 7, 8] + +prelude.uniqueBy(x => x.length, ["and", "here", "are", "some", "words"]); //=> ["and", "here", "words"] + +prelude.fold(x => y => x + y, 0, [1, 2, 3, 4, 5]); //=> 15 +var product = prelude.fold(x => y => x * y, 1); + +prelude.fold1(x => y => x + y, [1, 2, 3]); //=> 6 + +prelude.foldr(x => y => x - y, 9, [1, 2, 3, 4]); //=> 7 +prelude.foldr(x => y => x + y, "e", ["a", "b", "c", "d"]); //=> "abcde" + +prelude.foldr1(x => y => x - y, [1, 2, 3, 4, 9]); //=> 7 + +prelude.unfoldr(x => x === 0 ? null : [x, x - 1], 10); +//=> [10, 9, 8, 7, 6, 5, 4, 3, 2, 1] + +prelude.concat([[1], [2, 3], [4]]); //=> [1, 2, 3, 4] + +prelude.concatMap(x => ["hoge", x, x + 2], [1, 2, 3]); //=> ["hoge", 1, 3, "hoge", 2, 4, "hoge", 3, 5] + +prelude.flatten([1, [[2], 3], [4, [[5]]]]); //=> [1, 2, 3, 4, 5] + +prelude.difference([1, 2, 3], [1]); //=> [2, 3] +prelude.difference([1, 2, 3, 4, 5], [5, 2, 10], [9]); //=> [1, 3, 4] + +prelude.intersection([2, 3], [9, 8], [12, 1], [99]); //=> [] +prelude.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1], [-1, 0, 1, 2]); //=> [1, 2] +prelude.intersection([1, 2, 3], [2, 1, 3], [3, 1, 2]); //=> [1, 2, 3] + +prelude.union([1, 5, 7], [3, 5], []); //=> [1, 5, 7, 3] + +prelude.countBy(prelude.floor, [4.2, 6.1, 6.4]); //=> {4: 1, 6: 2} +prelude.countBy(x => x.length, ["one", "two", "three"]); //=> {3: 2, 5: 1} + +prelude.groupBy(prelude.floor, [4.2, 6.1, 6.4]); //=> {4: [4.2], 6: [6.1, 6.4]} +prelude.groupBy(x => x.length, ["one", "two", "three"]); //=> {3: ["one", "two"], 5: ["three"]} + +prelude.andList([true, 2 + 2 == 4]); //=> true +prelude.andList([true, true, false]); //=> false +prelude.andList([]); //=> true + +prelude.orList([false, false, true, false]); //=> true +prelude.orList([]); //=> false + +prelude.any(prelude.even, [3, 5, 7, 8, 9]); //=> true +prelude.any(prelude.even, []); //=> false + +prelude.all(prelude.isType("String"), ["ha", "ma", "la"]); //=> true +prelude.all(prelude.isType("String"), []); //=> true + +prelude.sort([3, 1, 5, 2, 4, 6]); //=> [1, 2, 3, 4, 5, 6] + +var f = (x: string) => (y: string) => + x.length > y.length ? + 1 + : x.length < y.length ? + -1 + : + 0; +prelude.sortWith(f, ["three", "one", "two"]); //=> ["one", "two", "three"] + +prelude.sortBy(x => x.length, ["there", "hey", "a", "ha"]); //=> ["a", "ha", "hey", "there"] + +var table = [{ + id: 1, + name: "george" +}, { + id: 2, + name: "mike" +}, { + id: 3, + name: "donald" +}]; +prelude.sortBy(x => x.name, table); +//=> [{"id": 3, "name": "donald"}, {"id": 1, "name": "george"}, {"id": 2, "name": "mike"}] + +prelude.sum([1, 2, 3, 4, 5]); //=> 15 +prelude.sum([]); //=> 0 + +prelude.product([1, 2, 3]); //=> 6 +prelude.product([]); //=> 1 + +prelude.mean([1, 2, 3, 4, 5]); //=> 3 + +prelude.maximum([4, 1, 9, 3]); //=> 9 + +prelude.minimum(["c", "e", "a", "d", "b"]); //=> "a" + +prelude.maximumBy(x => x.length, ["hi", "there", "I", "am", "looooong"]); //=> "looooong" + +prelude.maximumBy(x => x.length, ["hi", "there", "I", "am", "looooong"]); //=> "looooong" + +prelude.scan(x => y => x + y, 0, [1, 2, 3]); //=> [0, 1, 3, 6] + +prelude.scan1(x => y => x + y, [1, 2, 3]); //=> [1, 3, 6] + +prelude.scanr(x => y => x + y, 0, [1, 2, 3]); //=> [6, 5, 3, 0] + +prelude.scanr1(x => y => x + y, [1, 2, 3]); //=> [6, 5, 3] + +prelude.slice(2, 4, [1, 2, 3, 4, 5]); //=> [3, 4] + +prelude.take(2, [1, 2, 3, 4, 5]); //=> [1, 2] + +prelude.drop(2, [1, 2, 3, 4, 5]); //=> [3, 4, 5] + +prelude.splitAt(2, [1, 2, 3, 4, 5]); //=> [[1, 2], [3, 4, 5]] + +prelude.takeWhile(prelude.odd, [1, 3, 5, 4, 8, 7, 9]); //=> [1, 3, 5] + +prelude.dropWhile(prelude.even, [2, 4, 5, 6]); //=> [5, 6] + +prelude.span(prelude.even, [2, 4, 5, 6]); //=> [[2, 4], [5, 6]] + +prelude.breakList(x => x == 3, [1, 2, 3, 4, 5]); //=> [[1, 2], [3, 4, 5]] + +prelude.zip([1, 2, 3], [4, 5, 6]); //=> [[1, 4], [2, 5], [3, 6]] + +prelude.zipWith(x => y => x + y, [1, 2, 3], [4, 5, 6]); //=> [5, 7, 9] + +prelude.zipAll([1, 2, 3], [4, 5, 6], [7, 8, 9]); //=> [[1, 4, 7], [2, 5, 8], [3, 6, 9]] + +prelude.zipAllWith((a, b, c) => a + b + c, [1, 2, 3], [3, 2, 1], [1, 1, 1]); //=> [5, 5, 5] + +prelude.at(2, [1, 2, 3, 4]); //=> 3 +prelude.at(-3, [1, 2, 3, 4]); //=> 2 + +prelude.elemIndex("a", ["c", "a", "b", "a"]); //=> 1 + +prelude.elemIndices("a", ["c", "a", "b", "a"]); //=> [1, 3] + +prelude.findIndex(prelude.even, [1, 2, 3, 4]); //=> 1 + +prelude.findIndices(prelude.even, [1, 2, 3, 4]); //=> [1, 3] + +// Obj + +prelude.keys({a: 2, b: 3, c: 9}); //=> ["a", "b", "c"] + +prelude.values({a: 2, b: 3, c: 9}); //=> [2, 3, 9] + +prelude.pairsToObj([["a", "b"], ["c", "d"], ["e", 1]]); //=> {a: "b", c: "d", e: 1} + +prelude.objToPairs({a: "b", c: "d", e: 1}); //=> [["a", "b"], ["c", "d"], ["e", 1]] + +prelude.listsToObj(["a", "b", "c"], [1, 2, 3]); //=> {a: 1, b: 2, c: 3} + +prelude.objToLists({a: 1, b: 2, c: 3}); //=> [["a", "b", "c"], [1, 2, 3]] + +prelude.Obj.empty({}); //=> true + +var count = 4; +prelude.Obj.each(x => count += x, {a: 1, b: 2, c: 3}); +count; //=> 10 + +prelude.Obj.map(x => x + 2, {a: 2, b: 3, c: 4}); //=> {a: 4, b: 5, c: 6} + +prelude.Obj.compact({a: 0, b: 1, c: false, d: "", e: "ha"}); //=> {b: 1, e: "ha"} + +prelude.Obj.filter(prelude.even, {a: 3, b: 4, c: 0}); //=> {b: 4, c: 0} + +prelude.Obj.reject(x => x == 2, {a: 1, b: 2}); //=> {a: 1} + +prelude.Obj.partition(x => x == 2, {a: 1, b: 2, c: 3}); //=> [{b: 2}, {a: 1, c: 3}] + +prelude.Obj.find(prelude.even, {a: 1, b: 2, c: 3, d: 4}); //=> 2 + + +// Str + +prelude.split("|", "1|2|3"); //=> ["1", "2", "3"] +prelude.join("|", ["1", "2", "3"]); //=> "1|2|3" + +prelude.lines("one\ntwo\nthree"); +//=> ["one", "two", "three"] + +prelude.unlines(["one", "two", "three"]); +//=> "one\ntwo\nthree" + +prelude.words("hello, what is that?"); +//=> ["hello,", "what", "is", "that?"] + +prelude.unwords(["one", "two", "three"]); //=> "one two three" + +prelude.chars("hello"); //=> ["h", "e", "l", "l", "o"] + +prelude.unchars(["t", "h", "e", "r", "e"]); //=> "there" +prelude.unchars(["ma", "ma"]); //=> "mama" + +prelude.repeat(4, "a"); //=> "aaaa" +prelude.repeat(2, "ha"); //=> "haha" + +prelude.capitalize("hi there"); //=> "Hi there" + +prelude.camelize("hi-there"); //=> "hiThere" +prelude.camelize("hi_there"); //=> "hiThere" + +prelude.dasherize("hiThere"); //=> "hi-there" +prelude.dasherize("FooBar"); //=> "foo-bar" +prelude.dasherize("innerHTML"); //=> "inner-HTML" + +prelude.empty(""); //=> true + +prelude.reverse("goat"); //=> "taog" + +prelude.slice(2, 4, "hello"); //=> "ll" + +prelude.take(4, "hello"); //=> "hell" + +prelude.drop(1, "goat"); //=> "oat" + +prelude.splitAt(4, "hello"); //=> ["hell", "o"] + +prelude.takeWhile(x => !prelude.empty(prelude.elemIndices(x, ["a", "b", "c", "d"])), "cabdek"); //=> "cabd" + +prelude.dropWhile(x => x === "m", "mmmmmhmm"); //=> "hmm" + +prelude.span(x => x === "m", "mmmmmhmm"); //=> ["mmmmm", "hmm"] + +prelude.Str.breakStr(x => x === "h", "mmmmmhmm"); //=> ["mmmmm", "hmm"] + + +// Func + +prelude.apply((x, y) => x + y, [2, 3]); //=> 5 + +var add = (x: number, y: number) => x + y; +var addCurried = prelude.curry(add); +var addFour = addCurried(4); +addFour(2); //=> 6 + +var invertedPower = prelude.flip(x => y => Math.pow(x, y)); +invertedPower(2)(3); //=> 9 + +prelude.fix((fib: (n: number) => number) => (n: number) => n <= 1 ? 1 : fib(n - 1) + fib(n - 2))(9); //=> 55 + +var sameLength = prelude.over((x, y) => x == y, x => x.length); +sameLength('hi', 'me'); //=> true +sameLength('one', 'boom'); //=> false + +// Num + +prelude.max(3, 1); //=> 3 +prelude.max("a", "c"); //=> "c" + +prelude.min(3, 1); //=> 1 +prelude.min("a", "c"); //=> "a" + +prelude.negate(3); //=> -3 +prelude.negate(-2); //=> 2 + +prelude.abs(-2); //=> 2 +prelude.abs(2); //=> 2 + +prelude.signum(-5); //=> -1 +prelude.signum(0); //=> 0 +prelude.signum(9); //=> 1 + +prelude.quot(-20, 3); //=> -6 + +prelude.rem(-20, 3); //=> -2 + +prelude.div(-20, 3); //=> -7 + +prelude.mod(-20, 3); //=> 1 + +prelude.recip(4); //=> 0.25 + +prelude.pi; //=> 3.141592653589793 + +prelude.tau; //=> 6.283185307179586 + +prelude.exp(1); //=> 2.718281828459045 + +prelude.sqrt(4); //=> 2 + +prelude.ln(10); //=> 2.302585092994046 + +prelude.pow(-2, 2); //=> 4 + +prelude.sin(prelude.pi / 2); //=> 1 + +prelude.cos(prelude.pi); //=> -1 + +prelude.tan(prelude.pi / 4); //=> 1 + +prelude.asin(0); //=> 0 + +prelude.acos(1); //=> 0 + +prelude.atan(0); //=> 0 + +prelude.atan2(1, 0); //=> 1.5707963267948966 + +prelude.truncate(-1.5); //=> -1 +prelude.truncate(1.5); //=> 1 + +prelude.round(0.6); //=> 1 +prelude.round(0.5); //=> 1 +prelude.round(0.4); //=> 0 + +prelude.ceiling(0.1); //=> 1 + +prelude.floor(0.9); //=> 0 + +prelude.isItNaN(prelude.sqrt(-1)); //=> true + +prelude.even(4); //=> true +prelude.even(0); //=> true + +prelude.odd(3); //=> true + +prelude.gcd(12, 18); //=> 6 + +prelude.lcm(12, 18); //=> 36 \ No newline at end of file diff --git a/prelude-ls/prelude-ls.d.ts b/prelude-ls/prelude-ls.d.ts new file mode 100644 index 000000000..848077c82 --- /dev/null +++ b/prelude-ls/prelude-ls.d.ts @@ -0,0 +1,338 @@ +// Type definitions for prelude.ls 1.1.1 +// Project: http://www.preludels.com +// Definitions by: Aya Morisawa +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module "prelude-ls" { + module PreludeLS { + export function id(x: A): A; + export function isType(type: string): (x: A) => boolean; + export function isType(type: string, x: A): boolean; + export function replicate(n: number): (x: A) => A[]; + export function replicate(n: number, x: A): A[]; + + + // List + + export function each(f: (x: A) => void): (xs: A[]) => void; + export function each(f: (x: A) => void, xs: A[]): void; + export function map(f: (x: A) => B): (xs: A[]) => B[]; + export function map(f: (x: A) => B, xs: A[]): B[]; + export function compact(xs: A[]): A[]; + export function filter(f: (x: A) => boolean): (xs: A[]) => A[]; + export function filter(f: (x: A) => boolean, xs: A[]): A[]; + export function reject(f: (x: A) => boolean): (xs: A[]) => A[]; + export function reject(f: (x: A) => boolean, xs: A[]): A[]; + export function partition(f: (x: A) => Boolean): (xs: A[]) => [A[], A[]]; + export function partition(f: (x: A) => Boolean, xs: A[]): [A[], A[]]; + export function find(f: (x: A) => Boolean): (xs: A[]) => (A | void); + export function find(f: (x: A) => Boolean, xs: A[]): (A | void); + export function head(xs: A[]): (A | void); + export function tail(xs: A[]): A[]; + export function last(xs: A[]): (A | void); + export function initial(xs: A[]): A[]; + export function empty(xs: A[]): boolean; + export function reverse(xs: A[]): A[]; + export function unique(xs: A[]): A[]; + export function uniqueBy(f: (x: A) => B): (xs: A[]) => A[]; + export function uniqueBy(f: (x: A) => B, xs: A[]): A[]; + export function fold(f: (x: A) => (y: B) => A): (memo: A) => (xs: B[]) => A; + export function fold(f: (x: A) => (y: B) => A, memo: A): (xs: B[]) => A; + export function fold(f: (x: A) => (y: B) => A, memo: A, xs: B[]): A; + export function foldl(f: (x: A) => (y: B) => A): (memo: A) => (xs: B[]) => A; + export function foldl(f: (x: A) => (y: B) => A, memo: A): (xs: B[]) => A; + export function foldl(f: (x: A) => (y: B) => A, memo: A, xs: B[]): A; + export function fold1(f: (x: A) => (y: A) => A): (xs: A[]) => A; + export function fold1(f: (x: A) => (y: A) => A, xs: A[]): A; + export function foldl1(f: (x: A) => (y: A) => A): (xs: A[]) => A; + export function foldl1(f: (x: A) => (y: A) => A, xs: A[]): A; + export function foldr(f: (x: A) => (y: B) => B): (memo: B) => (xs: A[]) => B; + export function foldr(f: (x: A) => (y: B) => B, memo: B): (xs: A[]) => B; + export function foldr(f: (x: A) => (y: B) => B, memo: B, xs: A[]): B; + export function foldr1(f: (x: A) => (y: A) => A): (xs: A[]) => A; + export function foldr1(f: (x: A) => (y: A) => A, xs: A[]): A; + export function unfoldr(f: (x: B) => ([A, B] | void)): (x: B) => A[]; + export function unfoldr(f: (x: B) => ([A, B] | void), x: B): A[]; + export function concat(xss: A[][]): A[]; + export function concatMap(f: (x: A) => B[]): (xs: A[]) => B[]; + export function concatMap(f: (x: A) => B[], xs: A[]): B[]; + export function flatten(xs: any[]): any[]; + export function difference(...xss: A[][]): A[]; + export function intersection(...xss: A[]): A[]; + export function union(...xss: A[]): A[]; + export function countBy(f: (x: A) => B): (xs: A[]) => any; + export function countBy(f: (x: A) => B, xs: A[]): any; + export function groupBy(f: (x: A) => B): (xs: A[]) => any; + export function groupBy(f: (x: A) => B, xs: A[]): any; + export function andList(xs: A[]): boolean; + export function orList(xs: A[]): boolean; + export function any(f: (x: A) => boolean): (xs: A[]) => boolean; + export function any(f: (x: A) => boolean, xs: A[]): boolean; + export function all(f: (x: A) => boolean): (xs: A[]) => boolean; + export function all(f: (x: A) => boolean, xs: A[]): boolean; + export function sort(xs: A[]): A[]; + export function sortWith(f: (x: A) => (y: A) => number): (xs: A[]) => A[]; + export function sortWith(f: (x: A) => (y: A) => number, xs: A[]): A[]; + export function sortBy(f: (x: A) => B): (xs: A[]) => A; + export function sortBy(f: (x: A) => B, xs: A[]): A; + export function sum(xs: number[]): number[]; + export function product(xs: number[]): number[]; + export function mean(xs: number[]): number[]; + export function maximum(xs: A[]): A; + export function minimum(xs: A[]): A; + export function maximumBy(f: (x: A) => B): (xs: A[]) => A; + export function maximumBy(f: (x: A) => B, xs: A[]): A; + export function minimumBy(f: (x: A) => B): (xs: A[]) => A; + export function minimumBy(f: (x: A) => B, xs: A[]): A; + export function scan(f: (x: A) => (y: B) => A): (memo: A) => (xs: B[]) => A[]; + export function scan(f: (x: A) => (y: B) => A, memo: A): (xs: B[]) => A[]; + export function scan(f: (x: A) => (y: B) => A, memo: A, xs: B[]): A[]; + export function scanl(f: (x: A) => (y: B) => A): (memo: A) => (xs: B[]) => A[]; + export function scanl(f: (x: A) => (y: B) => A, memo: A): (xs: B[]) => A[]; + export function scanl(f: (x: A) => (y: B) => A, memo: A, xs: B[]): A[]; + export function scan1(f: (x: A) => (y: A) => A): (xs: A[]) => A[]; + export function scan1(f: (x: A) => (y: A) => A, xs: A[]): A[]; + export function scanl1(f: (x: A) => (y: A) => A): (xs: A[]) => A[]; + export function scanl1(f: (x: A) => (y: A) => A, xs: A[]): A[]; + export function scanr(f: (x: A) => (y: B) => B): (memo: B) => (xs: A[]) => B[]; + export function scanr(f: (x: A) => (y: B) => B, memo: B): (xs: A[]) => B[]; + export function scanr(f: (x: A) => (y: B) => B, memo: B, xs: A[]): B[]; + export function scanr1(f: (x: A) => (y: A) => A): (xs: A[]) => A[]; + export function scanr1(f: (x: A) => (y: A) => A, xs: A[]): A[]; + export function slice(x: number): (y: number) => (xs: A[]) => A[]; + export function slice(x: number, y: number): (xs: A[]) => A[]; + export function slice(x: number, y: number, xs: A[]): A[]; + export function take(n: number): (xs: A[]) => A[]; + export function take(n: number, xs: A[]): A[]; + export function drop(n: number): (xs: A[]) => A[]; + export function drop(n: number, xs: A[]): A[]; + export function splitAt(n: number): (xs: A[]) => [A[], A[]]; + export function splitAt(n: number, xs: A[]): [A[], A[]]; + export function takeWhile(p: (x: A) => boolean): (xs: A[]) => A[]; + export function takeWhile(p: (x: A) => boolean, xs: A[]): A[]; + export function dropWhile(p: (x: A) => boolean): (xs: A[]) => A[]; + export function dropWhile(p: (x: A) => boolean, xs: A[]): A[]; + export function span(p: (x: A) => boolean): (xs: A[]) => [A[], A[]]; + export function span(p: (x: A) => boolean, xs: A[]): [A[], A[]]; + export function breakList(p: (x: A) => boolean): (xs: A[]) => [A[], A[]]; + export function breakList(p: (x: A) => boolean, xs: A[]): [A[], A[]]; + export function zip(xs: A[]): (ys: B[]) => [A, B][]; + export function zip(xs: A[], ys: B[]): [A, B][]; + export function zipWith(f: (x: A) => (y: B) => C): (xs: A[]) => (ys: B[]) => C[]; + export function zipWith(f: (x: A) => (y: B) => C, xs: A[]): (ys: B[]) => C[]; + export function zipWith(f: (x: A) => (y: B) => C, xs: A[], ys: B[]): C[]; + export function zipAll(...xss: A[][]): A[][]; + export function zipAllWith(f: (...xs: A[]) => B, ...xss: A[][]): B[]; + export function at(n: number): (xs: A[]) => A; + export function at(n: number, xs: A[]): A; + export function elemIndex(x: A): (xs: A[]) => number; + export function elemIndex(x: A, xs: A[]): number; + export function elemIndices(x: A): (xs: A[]) => number[]; + export function elemIndices(x: A, xs: A[]): number[]; + export function findIndex(f: (x: A) => boolean): (xs: A[]) => number; + export function findIndex(f: (x: A) => boolean, xs: A[]): number; + export function findIndices(f: (x: A) => boolean): (xs: A[]) => number[]; + export function findIndices(f: (x: A) => boolean, xs: A[]): number[]; + + + // Obj + + export function keys(object: { [key: string]: A }): string[]; + export function keys(object: { [key: number]: A }): number[]; + export function values(object: { [key: string]: A }): A[]; + export function values(object: { [key: number]: A }): A[]; + export function pairsToObj(object: [string, A][]): { [key: string]: A }; + export function pairsToObj(object: [number, A][]): { [key: number]: A }; + export function objToPairs(object: { [ key: string]: A }): [string, A][]; + export function objToPairs(object: { [ key: number]: A }): [number, A][]; + export function listsToObj(keys: string[]): (values: A[]) => { [key: string]: A }; + export function listsToObj(keys: string[], values: A[]): { [key: string]: A }; + export function listsToObj(keys: number[]): (values: A[]) => { [key: number]: A }; + export function listsToObj(keys: number[], values: A[]): { [key: number]: A }; + export function objToLists(object: { [key: string]: A }): [string[], A[]]; + export function objToLists(object: { [key: number]: A }): [number[], A[]]; + export function empty(object: any): boolean; + export function each(f: (x: A) => void): (object: { [key: string]: A }) => { [key: string]: A }; + export function each(f: (x: A) => void, object: { [key: string]: A }): { [key: string]: A }; + export function each(f: (x: A) => void): (object: { [key: number]: A }) => { [key: number]: A }; + export function each(f: (x: A) => void, object: { [key: number]: A }): { [key: number]: A }; + export function map(f: (x: A) => B): (object: { [key: string]: A }) => { [key: string]: B }; + export function map(f: (x: A) => B, object: { [key: string]: A }): { [key: string]: B }; + export function map(f: (x: A) => B): (object: { [key: number]: A }) => { [key: number]: B }; + export function map(f: (x: A) => B, object: { [key: number]: A }): { [key: number]: B }; + export function compact(object: { [key: string]: A }): { [key: string]: A }; + export function compact(object: { [key: number]: A }): { [key: number]: A }; + export function filter(f: (x: A) => boolean): (object: { [key: string]: A }) => { [key: string]: A }; + export function filter(f: (x: A) => boolean, object: { [key: string]: A }): { [key: string]: A }; + export function filter(f: (x: A) => boolean): (object: { [key: number]: A }) => { [key: number]: A }; + export function filter(f: (x: A) => boolean, object: { [key: number]: A }): { [key: number]: A }; + export function reject(f: (x: A) => boolean): (object: { [key: string]: A }) => { [key: string]: A }; + export function reject(f: (x: A) => boolean, object: { [key: string]: A }): { [key: string]: A }; + export function reject(f: (x: A) => boolean): (object: { [key: number]: A }) => { [key: number]: A }; + export function reject(f: (x: A) => boolean, object: { [key: number]: A }): { [key: number]: A }; + export function partition(f: (x: A) => boolean): (object: { [key: string]: A }) => [{ [key: string]: A }, { [key: string]: A}]; + export function partition(f: (x: A) => boolean, object: { [key: string]: A }): [{ [key: string]: A }, { [key: string]: A}]; + export function partition(f: (x: A) => boolean): (object: { [key: number]: A }) => [{ [key: number]: A }, { [key: number]: A}]; + export function partition(f: (x: A) => boolean, object: { [key: number]: A }): [{ [key: number]: A }, { [key: number]: A}]; + export function find(f: (x: A) => boolean): (object: { [key: string]: A }) => A; + export function find(f: (x: A) => boolean, object: { [key: string]: A }): A; + export function find(f: (x: A) => boolean): (object: { [key: number]: A }) => A; + export function find(f: (x: A) => boolean, object: { [key: number]: A }): A; + + export module Obj { + export function empty(object: any): boolean; + export function each(f: (x: A) => void): (object: { [key: string]: A }) => { [key: string]: A }; + export function each(f: (x: A) => void, object: { [key: string]: A }): { [key: string]: A }; + export function each(f: (x: A) => void): (object: { [key: number]: A }) => { [key: number]: A }; + export function each(f: (x: A) => void, object: { [key: number]: A }): { [key: number]: A }; + export function map(f: (x: A) => B): (object: { [key: string]: A }) => { [key: string]: B }; + export function map(f: (x: A) => B, object: { [key: string]: A }): { [key: string]: B }; + export function map(f: (x: A) => B): (object: { [key: number]: A }) => { [key: number]: B }; + export function map(f: (x: A) => B, object: { [key: number]: A }): { [key: number]: B }; + export function compact(object: { [key: string]: A }): { [key: string]: A }; + export function compact(object: { [key: number]: A }): { [key: number]: A }; + export function filter(f: (x: A) => boolean): (object: { [key: string]: A }) => { [key: string]: A }; + export function filter(f: (x: A) => boolean, object: { [key: string]: A }): { [key: string]: A }; + export function filter(f: (x: A) => boolean): (object: { [key: number]: A }) => { [key: number]: A }; + export function filter(f: (x: A) => boolean, object: { [key: number]: A }): { [key: number]: A }; + export function reject(f: (x: A) => boolean): (object: { [key: string]: A }) => { [key: string]: A }; + export function reject(f: (x: A) => boolean, object: { [key: string]: A }): { [key: string]: A }; + export function reject(f: (x: A) => boolean): (object: { [key: number]: A }) => { [key: number]: A }; + export function reject(f: (x: A) => boolean, object: { [key: number]: A }): { [key: number]: A }; + export function partition(f: (x: A) => boolean): (object: { [key: string]: A }) => [{ [key: string]: A }, { [key: string]: A}]; + export function partition(f: (x: A) => boolean, object: { [key: string]: A }): [{ [key: string]: A }, { [key: string]: A}]; + export function partition(f: (x: A) => boolean): (object: { [key: number]: A }) => [{ [key: number]: A }, { [key: number]: A}]; + export function partition(f: (x: A) => boolean, object: { [key: number]: A }): [{ [key: number]: A }, { [key: number]: A}]; + export function find(f: (x: A) => boolean): (object: { [key: string]: A }) => A; + export function find(f: (x: A) => boolean, object: { [key: string]: A }): A; + export function find(f: (x: A) => boolean): (object: { [key: number]: A }) => A; + export function find(f: (x: A) => boolean, object: { [key: number]: A }): A; + } + + + // Str + + export function split(separator: string): (str: string) => string[]; + export function split(separator: string, str: string): string[]; + export function join(separator: string): (xs: string[]) => string; + export function join(separator: string, xs: string[]): string; + export function lines(str: string): string[]; + export function unlines(xs: string[]): string; + export function words(str: string): string[]; + export function unwords(xs: string[]): string; + export function chars(str: string): string[]; + export function unchars(xs: string[]): string; + export function repeat(n: number): (str: string) => string; + export function repeat(n: number, str: string): string; + export function capitalize(str: string): string; + export function camelize(str: string): string; + export function dasherize(str: string): string; + export function empty(str: string): boolean; + export function reverse(str: string): string; + export function slice(x: number): (y: number) => (str: string) => string; + export function slice(x: number, y: number): (str: string) => string; + export function slice(x: number, y: number, str: string): string; + export function take(n: number): (str: string) => string; + export function take(n: number, str: string): string; + export function drop(n: number): (str: string) => string; + export function drop(n: number, str: string): string; + export function splitAt(n: number): (str: string) => [string, string]; + export function splitAt(n: number, str: string): [string, string]; + export function takeWhile(f: (str: string) => boolean): (str: string) => string; + export function takeWhile(f: (str: string) => boolean, str: string): string; + export function dropWhile(f: (str: string) => boolean): (str: string) => string; + export function dropWhile(f: (str: string) => boolean, str: string): string; + export function span(f: (str: string) => boolean): (str: string) => [string, string]; + export function span(f: (str: string) => boolean, str: string): [string, string]; + export function breakStr(f: (str: string) => boolean): (str: string) => [string, string]; + export function breakStr(f: (str: string) => boolean, str: string): [string, string]; + + export module Str { + export function empty(str: string): boolean; + export function reverse(str: string): string; + export function slice(x: number): (y: number) => (str: string) => string; + export function slice(x: number, y: number): (str: string) => string; + export function slice(x: number, y: number, str: string): string; + export function take(n: number): (str: string) => string; + export function take(n: number, str: string): string; + export function drop(n: number): (str: string) => string; + export function drop(n: number, str: string): string; + export function splitAt(n: number): (str: string) => [string, string]; + export function splitAt(n: number, str: string): [string, string]; + export function takeWhile(f: (str: string) => boolean): (str: string) => string; + export function takeWhile(f: (str: string) => boolean, str: string): string; + export function dropWhile(f: (str: string) => boolean): (str: string) => string; + export function dropWhile(f: (str: string) => boolean, str: string): string; + export function span(f: (str: string) => boolean): (str: string) => [string, string]; + export function span(f: (str: string) => boolean, str: string): [string, string]; + export function breakStr(f: (str: string) => boolean): (str: string) => [string, string]; + export function breakStr(f: (str: string) => boolean, str: string): [string, string]; + } + + + // Func + + export function apply(f: (...args: A[]) => B): (args: A[]) => B; + export function apply(f: (...args: A[]) => B, args: A[]): B; + export function curry(f: Function): Function; + export function flip(f: (x: A) => (y: B) => C): (y: B) => (x: A) => C; + export function flip(f: (x: A) => (y: B) => C, y: B): (x: A) => C; + export function flip(f: (x: A) => (y: B) => C, y: B, x: A): C; + export function fix(f: Function): Function; + export function over(f: (x: B) => (y: B) => C): (g: (x: A) => B) => (x: A) => (y: A) => C; + export function over(f: (x: B, y: B) => C): (g: (x: A) => B) => (x: A, y: A) => C; + export function over(f: (x: B) => (y: B) => C, g: (x: A) => B): (x: A) => (y: A) => C; + export function over(f: (x: B, y: B) => C, g: (x: A) => B): (x: A, y: A) => C; + export function over(f: (x: B) => (y: B) => C, g: (x: A) => B, x: A): (y: A) => C; + export function over(f: (x: B, y: B) => C, g: (x: A) => B, x: A): (y: A) => C; + export function over(f: (x: B) => (y: B) => C, g: (x: A) => B, x: A, y: A): C; + export function over(f: (x: B, y: B) => C, g: (x: A) => B, x: A, y: A): C; + + + // Num + + export function max(x: Comparable): (y: Comparable) => Comparable; + export function max(x: Comparable, y: Comparable): Comparable; + export function min(x: Comparable): (y: Comparable) => Comparable; + export function min(x: Comparable, y: Comparable): Comparable; + export function negate(x: number): number; + export function abs(x: number): number; + export function signum(x: number): number; + export function quot(x: number): (y: number) => number; + export function quot(x: number, y: number): number; + export function rem(x: number): (y: number) => number; + export function rem(x: number, y: number): number; + export function div(x: number): (y: number) => number; + export function div(x: number, y: number): number; + export function mod(x: number): (y: number) => number; + export function mod(x: number, y: number): number; + export function recip(x: number): number; + export var pi: number; + export var tau: number; + export function exp(x: number): number; + export function sqrt(x: number): number; + export function ln(x: number): number; + export function pow(x: number): (y: number) => number; + export function pow(x: number, y: number): number; + export function sin(x: number): number; + export function cos(x: number): number; + export function tan(x: number): number; + export function asin(x: number): number; + export function acos(x: number): number; + export function atan(x: number): number; + export function atan2(x: number, y: number): number; + export function truncate(x: number): number; + export function round(x: number): number; + export function ceiling(x: number): number; + export function floor(x: number): number; + export function isItNaN(x: number): boolean; + export function even(x: number): boolean; + export function odd(x: number): boolean; + export function gcd(x: number): (y: number) => number; + export function gcd(x: number, y: number): number; + export function lcm(x: number): (y: number) => number; + export function lcm(x: number, y: number): number; + } + + export = PreludeLS; +} \ No newline at end of file From bb465f2cc799a41a7ccb688c6d1a8f5583dda12d Mon Sep 17 00:00:00 2001 From: vvakame Date: Tue, 3 Mar 2015 01:21:06 +0900 Subject: [PATCH 135/185] update CONTRIBUTORS.md --- CONTRIBUTORS.md | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index c870d1977..eb11f9f2a 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -78,7 +78,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](bootstrap.paginator/bootstrap.paginator.d.ts) [bootstrap.paginator](https://github.com/lyonlai/bootstrap-paginator) by [derikwhittaker](https://github.com/derikwhittaker) * [:link:](bootstrap.timepicker/bootstrap.timepicker.d.ts) [bootstrap.timepicker](https://github.com/jdewit/bootstrap-timepicker) by [derikwhittaker](https://github.com/derikwhittaker) * [:link:](box2d/box2dweb.d.ts) [bootstrap.timepicker](http://code.google.com/p/box2dweb) by [jbaldwin](https://github.com/jbaldwin) -* [:link:](breeze/breeze.d.ts) [Breeze](http://www.breezejs.com) by [Boris Yankov](https://github.com/borisyankov), [IdeaBlade](https://github.com/IdeaBlade/Breeze) +* [:link:](breeze/breeze.d.ts) [Breeze 1.5.x](http://www.breezejs.com) by [Boris Yankov](https://github.com/borisyankov), [IdeaBlade](https://github.com/IdeaBlade/Breeze) * [:link:](browser-harness/browser-harness.d.ts) [Browser Harness](https://github.com/scriby/browser-harness) by [Chris Scribner](https://github.com/scriby) * [:link:](browser-sync/browser-sync.d.ts) [browser-sync](http://www.browsersync.io) by [Asana](https://asana.com) * [:link:](browserify/browserify.d.ts) [Browserify](http://browserify.org) by [Andrew Gaspar](https://github.com/AndrewGaspar) @@ -98,6 +98,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](chai-http/chai-http.d.ts) [chai-http](https://github.com/chaijs/chai-http) by [Wim Looman](https://github.com/Nemo157) * [:link:](chai-jquery/chai-jquery.d.ts) [chai-jquery](https://github.com/chaijs/chai-jquery) by [Kazi Manzur Rashid](https://github.com/kazimanzurrashid) * [:link:](chalk/chalk.d.ts) [chalk](https://github.com/sindresorhus/chalk) by [Diullei Gomes](https://github.com/Diullei), [Bart van der Schoor](https://github.com/Bartvds) +* [:link:](chance/chance.d.ts) [Chance](http://chancejs.com) by [Chris Bowdon](https://github.com/cbowdon) * [:link:](change-case/change-case.d.ts) [change-case](https://github.com/blakeembrey/change-case) by [Asana](https://asana.com) * [:link:](chartjs/chart.d.ts) [Chart.js](https://github.com/nnnick/Chart.js) by [Steve Fenton](https://github.com/Steve-Fenton) * [:link:](checksum/checksum.d.ts) [checksum](https://github.com/dshaw/checksum) by [Rogier Schouten](https://github.com/rogierschouten) @@ -223,6 +224,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](ftdomdelegate/ftdomdelegate.d.ts) [ftdomdelegate](https://github.com/ftlabs/ftdomdelegate) by [Christian Holm Nielsen](https://github.com/dotnetnerd) * [:link:](fullCalendar/fullCalendar.d.ts) [FullCalendar](http://arshaw.com/fullcalendar) by [Neil Stalker](https://github.com/nestalk) * [:link:](fuse/fuse.d.ts) [Fuse.js](https://github.com/krisk/Fuse) by [Greg Smith](https://github.com/smrq) +* [:link:](jquery-galleria/jquery-galleria.d.ts) [galleria.js](https://github.com/aino/galleria) by [Robert Imig](https://github.com/rimig) * [:link:](gamepad/gamepad.d.ts) [Gamepad API](http://www.w3.org/TR/gamepad) by [Kon](http://phyzkit.net) * [:link:](gamequery/gamequery.d.ts) [gameQuery](http://gamequeryjs.com) by [David Laubreiter](https://github.com/Laubi) * [:link:](gently/gently.d.ts) [gently](https://www.npmjs.org/package/gently) by [bonnici](https://github.com/bonnici) @@ -238,9 +240,10 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](google.analytics/ga.d.ts) [Google Analytics (Classic and Universal)](https://developers.google.com/analytics/devguides/collection/gajs) by [Ronnie Haakon Hegelund](http://ronniehegelund.blogspot.dk), [Pat Kujawa](http://patkujawa.com) * [:link:](gapi/gapi.d.ts) [Google API Client](https://code.google.com/p/google-api-javascript-client) by [Frank M](https://github.com/sgtfrankieboy) * [:link:](google.feeds/google.feed.api.d.ts) [Google Feed Apis](https://developers.google.com/feed) by [RodneyJT](https://github.com/RodneyJT) -* [:link:](googlemaps/google.maps.d.ts) [Google Geolocation](https://developers.google.com/maps) by [Folia A/S](http://www.folia.dk) * [:link:](google.geolocation/google.geolocation.d.ts) [Google Geolocation](https://code.google.com/p/geo-location-javascript) by [Vincent Bortone](https://github.com/vbortone) +* [:link:](googlemaps/google.maps.d.ts) [Google Geolocation](https://developers.google.com/maps) by [Folia A/S](http://www.folia.dk) * [:link:](gapi.pagespeedonline/gapi.pagespeedonline.d.ts) [Google Page Speed Online Api](https://developers.google.com/speed/pagespeed) by [Frank M](https://github.com/sgtfrankieboy) +* [:link:](google.picker/google.picker.d.ts) [Google Picker API](https://developers.google.com/picker) by [grapswiz](https://github.com/grapswiz) * [:link:](recaptcha/recaptcha.d.ts) [Google Recaptcha](https://www.google.com/recaptcha) by [Brent Jenkins](https://github.com/brentj73) * [:link:](gapi.translate/gapi.translate.d.ts) [Google Translate API](https://developers.google.com/translate) by [Frank M](https://github.com/sgtfrankieboy) * [:link:](gapi.urlshortener/gapi.urlshortener.d.ts) [Google Url Shortener API](https://developers.google.com/url-shortener) by [Frank M](https://github.com/sgtfrankieboy) @@ -251,6 +254,9 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](greensock/greensock.d.ts) [GreenSock Animation Platform](http://www.greensock.com/get-started-js) by [Robert S](https://github.com/codebelt) * [:link:](gridfs-stream/gridfs-stream.d.ts) [gridfs-stream](https://github.com/aheckmann/gridfs-stream) by [Lior Mualem](https://github.com/liorm) * [:link:](gruntjs/gruntjs.d.ts) [Grunt 0.4.x](http://gruntjs.com) by [Jeff May](https://github.com/jeffmay), [Basarat Ali Syed](https://github.com/basarat) +* [:link:](gsap/TweenLite.d.ts) [GSAP](http://greensock.com) by [VILIC VANE](https://vilic.github.io) +* [:link:](gsap/Core.d.ts) [GSAP](http://greensock.com) by [VILIC VANE](https://vilic.github.io) +* [:link:](gsap/Ease.d.ts) [GSAP](http://greensock.com) by [VILIC VANE](https://vilic.github.io) * [:link:](gulp/gulp.d.ts) [Gulp v3.8.x](http://gulpjs.com) by [Drew Noakes](https://drewnoakes.com) * [:link:](gulp-autoprefixer/gulp-autoprefixer.d.ts) [gulp-autoprefixer](https://github.com/sindresorhus/gulp-autoprefixer) by [Asana](https://asana.com) * [:link:](gulp-gh-pages/gulp-gh-pages.d.ts) [gulp-gh-pages](https://github.com/rowoot/gulp-gh-pages) by [Asana](https://asana.com) @@ -294,6 +300,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](interactjs/interact.d.ts) [Interacting for interact.js](https://github.com/taye/interact.js) by [Douglas Eichelberger](https://github.com/dduugg), [Adi Dahiya](https://github.com/adidahiya) * [:link:](intercomjs/intercom.d.ts) [intercom.js](https://github.com/diy/intercom.js) by [spencerwi](http://github.com/spencerwi) * [:link:](cordova-ionic/cordova-ionic.d.ts) [Ionic Cordova plugins](https://github.com/driftyco) by [Hendrik Maus](https://github.com/hendrikmaus) +* [:link:](is_js/is_js.d.ts) [is.js](http://arasatasaygin.github.io/is.js) by [Rodrigo Cabral](https://github.com/cabralRodrigo) * [:link:](iscroll/iscroll.d.ts) [iScroll](http://cubiq.org/iscroll-4) by [Boris Yankov](https://github.com/borisyankov), [Christiaan Rakowski](https://github.com/csrakowski) * [:link:](iscroll/iscroll-5.d.ts) [iScroll 5](http://cubiq.org/iscroll-5-ready-for-beta-test) by [Christiaan Rakowski](https://github.com/csrakowski) * [:link:](iscroll/iscroll-lite.d.ts) [iScroll Lite](http://cubiq.org/iscroll-4) by [Boris Yankov](https://github.com/borisyankov), [Christiaan Rakowski](https://github.com/csrakowski) @@ -307,6 +314,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](jasmine-jquery/jasmine-jquery.d.ts) [Jasmine-JQuery](https://github.com/velesin/jasmine-jquery) by [Gregor Stamac](https://github.com/gstamac) * [:link:](jasmine-matchers/jasmine-matchers.d.ts) [jasmine-matchers](https://github.com/uxebu/jasmine-matchers) by [Bart van der Schoor](https://github.com/Bartvds) * [:link:](java-applet/java-applet.d.ts) [Java Applet](https://www.java.com) by [Cyril Schumacher](https://github.com/cyrilschumacher) +* [:link:](hooker/hooker.d.ts) [JavaScript Hooker](https://github.com/cowboy/javascript-hooker) by [Michael Zabka](https://github.com/misak113) * [:link:](jbinary/jbinary.d.ts) [jBinary](https://github.com/jDataView/jBinary) by [Tim Bureck](https://github.com/tbureck) * [:link:](jdataview/jdataview.d.ts) [jDataView](https://github.com/jDataView/jDataView) by [Ingvar Stepanyan](https://github.com/RReverser) * [:link:](jest/jest.d.ts) [Jest](http://facebook.github.io/jest) by [Asana](https://asana.com) @@ -589,6 +597,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](power-assert-formatter/power-assert-formatter.d.ts) [power-assert-formatter](https://github.com/twada/power-assert-formatter) by [vvakame](https://github.com/vvakame) * [:link:](precise/precise.d.ts) [precise](https://www.npmjs.org/package/precise) by [Peter Harris](https://github.com/codeanimal) * [:link:](preloadjs/preloadjs.d.ts) [PreloadJS](http://www.createjs.com/#!/PreloadJS) by [Pedro Ferreira](https://bitbucket.org/drk4) +* [:link:](prelude-ls/prelude-ls.d.ts) [prelude.ls](http://www.preludels.com) by [Aya Morisawa](https://github.com/AyaMorisawa) * [:link:](progressjs/progress.d.ts) [ProgressJs](http://usablica.github.io/progress.js) by [Shunsuke Ohtani](https://github.com/zaneli) * [:link:](promise-pool/promise-pool.d.ts) [promise-pool](https://github.com/vilic/promise-pool) by [VILIC VANE](https://github.com/vilic) * [:link:](promises-a-plus/promises-a-plus.d.ts) [promises-a-plus](http://promisesaplus.com) by [Igor Oleinikov](https://github.com/Igorbek) @@ -679,6 +688,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](space-pen/space-pen.d.ts) [SpacePen](https://github.com/atom/space-pen) by [vvakame](https://github.com/vvakame) * [:link:](spectrum/spectrum.d.ts) [spectrum](https://github.com/bgrins/spectrum) by [Mordechai Zuber](https://github.com/M-Zuber) * [:link:](spin/spin.d.ts) [Spin.js](http://fgnass.github.com/spin.js) by [Boris Yankov](https://github.com/borisyankov), [Theodore Brown](https://github.com/theodorejb) +* [:link:](split/split.d.ts) [split](https://github.com/dominictarr/split) by [Marcin Porębski](https://github.com/marcinporebski) * [:link:](sprintf/sprintf.d.ts) [sprintff](https://github.com/maritz/node-sprintff) by [Carlos Ballesteros Velasco](https://github.com/soywiz) * [:link:](sharepoint/SharePoint.d.ts) [sptypescript](http://sptypescript.codeplex.com) by [Stanislav Vyshchepan](http://gandjustas.blogspot.ru), [Andrey Markeev](http://markeev.com) * [:link:](sqlite3/sqlite3.d.ts) [sqlite3](https://github.com/mapbox/node-sqlite3) by [Nick Malaguti](https://github.com/nmalaguti) @@ -801,6 +811,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](zepto/zepto.d.ts) [Zepto](http://zeptojs.com) by [Josh Baldwin](https://github.com/jbaldwin) * [:link:](zeroclipboard/zeroclipboard.d.ts) [ZeroClipboard](https://github.com/jonrohan/ZeroClipboard) by [Eric J. Smith](https://github.com/ejsmith), [Blake Niemyjski](https://github.com/niemyjski), [György Balássy](https://github.com/balassy) * [:link:](node_zeromq/zmq.d.ts) [ZeroMQ Node](https://github.com/JustinTulloss/zeromq.node) by [Dave McKeown](http://github.com/davemckeown) +* [:link:](zip.js/zip.js.d.ts) [zip.js 2.x](https://github.com/gildas-lormeau/zip.js) by [Louis Grignon](https://github.com/lgrignon) * [:link:](scroller/easyscroller.d.ts) [Zynga EasyScroller](https://github.com/zynga/scroller) by [Boris Yankov](https://github.com/borisyankov) * [:link:](scroller/scroller.d.ts) [Zynga Scroller](https://github.com/zynga/scroller) by [Boris Yankov](https://github.com/borisyankov) * [:link:](viewporter/viewporter.d.ts) [Zynga Viewporter](https://github.com/zynga/viewporter) by [Boris Yankov](https://github.com/borisyankov) From c874400b6c500617c3a6fdd054edda3f3ca5e3e3 Mon Sep 17 00:00:00 2001 From: Matthew Hamilton Date: Mon, 2 Mar 2015 11:02:42 -0600 Subject: [PATCH 136/185] Fixed #3344: Added definitions and compile tests for angular-idle. --- angular-idle/angular-idle-tests.ts | 23 +++++ angular-idle/angular-idle.d.ts | 134 +++++++++++++++++++++++++++++ 2 files changed, 157 insertions(+) create mode 100644 angular-idle/angular-idle-tests.ts create mode 100644 angular-idle/angular-idle.d.ts diff --git a/angular-idle/angular-idle-tests.ts b/angular-idle/angular-idle-tests.ts new file mode 100644 index 000000000..fc39bf72a --- /dev/null +++ b/angular-idle/angular-idle-tests.ts @@ -0,0 +1,23 @@ +/// + +angular.module('app', ['ngIdle']) + .config(['$keepaliveProvider', '$idleProvider', + ($keepaliveProvider: ng.idle.IKeepAliveProvider, $idleProvider: ng.idle.IIdleProvider) => { + $idleProvider.activeOn('mousemove keydown DOMMouseScroll mousewheel mousedown'); + $idleProvider.idleDuration(5); + $idleProvider.warningDuration(5); + $idleProvider.keepalive(true) + $idleProvider.autoResume(true); + $keepaliveProvider.interval(10); + }]) + .run(['$keepalive', '$idle', ($keepalive: ng.idle.IKeepAliveService, $idle: ng.idle.IIdleService) => { + $idle.watch(); + + if ($idle.running() || $idle.idling()) { + $idle.unwatch(); + } + + $keepalive.start(); + $keepalive.ping(); + $keepalive.stop(); + }]); \ No newline at end of file diff --git a/angular-idle/angular-idle.d.ts b/angular-idle/angular-idle.d.ts new file mode 100644 index 000000000..57ef2380b --- /dev/null +++ b/angular-idle/angular-idle.d.ts @@ -0,0 +1,134 @@ +// Type definitions for ng-idle v0.3.5 +// Project: http://hackedbychinese.github.io/ng-idle/ +// Definitions by: mthamil +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module ng.idle { + + /** + * Used to configure the $keepalive service. + */ + interface IKeepAliveProvider extends IServiceProvider { + + /** + * If configured, options will be used to issue a request using $http. + * If the value is null, no HTTP request will be issued. + * You can specify a string, which it will assume to be a URL to a simple GET request. + * Otherwise, you can use the same options $http takes. However, cache will always be false. + * + * @param value May be string or object, default is null. + */ + http(value: any): void; + + /** + * This specifies how often the keepalive event is triggered and the + * HTTP request is issued. + * + * @param seconds Integer, default is 5 minutes. Must be greater than 0. + */ + interval(seconds: number): void; + } + + /** + * $keepalive will use a timeout to periodically wake, broadcast a $keepalive event on the root scope, + * and optionally make an $http request. By default, the $idle service will stop and start $keepalive + * when a user becomes idle or returns from idle, respectively. It is also started automatically when + * $idle.watch() is called. This can be disabled by configuring the $idleProvider. + */ + interface IKeepAliveService { + + /** + * Starts pinging periodically until stop() is called. + */ + start(): void; + + /** + * Stops pinging. + */ + stop(): void; + + /** + * Performs one ping only. + */ + ping(): void; + } + + /** + * Used to configure the $idle service. + */ + interface IIdleProvider extends IServiceProvider { + + /** + * Specifies the DOM events the service will watch to reset the idle timeout. + * Multiple events should be separated by a space. + * + * @param events string, default 'mousemove keydown DOMMouseScroll mousewheel mousedown' + */ + activeOn(events: string): void; + + /** + * The idle timeout duration in seconds. After this amount of time passes without the user + * performing an action that triggers one of the watched DOM events, the user is considered + * idle. + * + * @param seconds integer, default is 20min + */ + idleDuration(seconds: number): void; + + /** + * The amount of time the user has to respond (in seconds) before they have been considered + * timed out. + * + * @param seconds integer, default is 30s + */ + warningDuration(seconds: number): void; + + /** + * When true, user activity will automatically interrupt the warning countdown and reset the + * idle state. If false, you will need to manually call watch() when you want to start + * watching for idleness again. + * + * @param enabled boolean, default is true + */ + autoResume(enabled: boolean): void; + + /** + * When true, the $keepalive service is automatically stopped and started as needed. + * + * @param enabled boolean, default is true + */ + keepalive(enabled: boolean): void; + } + + /** + * $idle, once watch() is called, will start a timeout which if expires, will enter a warning state + * countdown. Once the countdown reaches zero, idle will broadcast a timeout event indicating the + * user has timed out (where your app should log them out or whatever you like). If the user performs + * an action that triggers a watched DOM event that bubbles up to document.body, this will reset the + * idle/warning state and start the process over again. + */ + interface IIdleService { + + /** + * Whether or not the watch() has been called and it is watching for idleness. + */ + running(): boolean; + + /** + * Whether or not the user appears to be idle. + */ + idling(): boolean; + + /** + * Starts watching for idleness, or resets the idle/warning state and continues watching. + */ + watch(): void; + + /** + * Stops watching for idleness, and resets the idle/warning state. + */ + unwatch(): void; + } +} \ No newline at end of file From 0d3541aec2cbb3010c15e2cec227cfdb271af362 Mon Sep 17 00:00:00 2001 From: NN Date: Thu, 26 Feb 2015 08:26:30 +0200 Subject: [PATCH 137/185] Add global chrome object through window It allows to add a check for existence of 'chrome' object. Without it the strict mode can complain about undefined variable. --- chrome/chrome.d.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/chrome/chrome.d.ts b/chrome/chrome.d.ts index e77f744fa..cbabf893a 100755 --- a/chrome/chrome.d.ts +++ b/chrome/chrome.d.ts @@ -5,6 +5,13 @@ /// +//////////////////// +// Global object +//////////////////// +interface Window { + chrome: typeof chrome; +} + //////////////////// // Alarms //////////////////// From c4e849a93dcd3f215cfb0b99559250d0b686c1e5 Mon Sep 17 00:00:00 2001 From: Eugene <12kb@sibmail.com> Date: Tue, 3 Mar 2015 02:26:03 +0600 Subject: [PATCH 138/185] Update three.d.ts http://threejs.org/docs/#Reference/Extras.Helpers/BoundingBoxHelper .box property type is THREE.Box3, not the array. Seems mistake. --- threejs/three.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/threejs/three.d.ts b/threejs/three.d.ts index 78beab253..b74844407 100644 --- a/threejs/three.d.ts +++ b/threejs/three.d.ts @@ -5613,7 +5613,7 @@ declare module THREE { constructor(object: Object3D, hex?: number); object: Object3D; - box: Box3[]; + box: Box3; update(): void; } From eec429264eb620e1575dd5168fd08cb6cce8e072 Mon Sep 17 00:00:00 2001 From: reppners Date: Mon, 2 Mar 2015 21:27:20 +0100 Subject: [PATCH 139/185] + changing the JSData Promise type to interface + adding definitions object with usage example in tests for enabling custom type definitions of created resource definitions --- js-data/js-data-tests.ts | 35 ++++++++++++++++++++++++++++++++--- js-data/js-data.d.ts | 9 +++++++-- 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/js-data/js-data-tests.ts b/js-data/js-data-tests.ts index 1cb3e8e72..a6ac09a42 100644 --- a/js-data/js-data-tests.ts +++ b/js-data/js-data-tests.ts @@ -90,13 +90,13 @@ var UserWithComputedProperty = store.defineResource({ computed: { // each function's argument list defines the fields // that the computed property depends on - fullName: ['first', 'last', function (first: string, last: string) { + fullName: ['first', 'last', function (first:string, last:string) { return first + ' ' + last; }], // shortand, use the array syntax above if you want // you computed properties to work after you've // minified your code. Shorthand style won't work when minified - initials: function (first: string, last: string) { + initials: function (first:string, last:string) { return first.toUpperCase()[0] + '. ' + last.toUpperCase()[0] + '.'; } } @@ -490,4 +490,33 @@ module CustomAdapterTest { var store = new JSData.DS(); store.registerAdapter('mca', new MyCustomAdapter(), {default: true}); // the data store will now use your custom adapter by default -} \ No newline at end of file +} + +/** + * showing the use of open ended interface to realize typings + * on the Datastore.definitions object where all resource definitions + * are saved. + */ + +interface MyCustomDataStore { + + myResource: JSData_.DSResourceDefinition +} + +interface MyResourceDefinition { + +} + +module JSData_ { + + interface DS { + + definitions: MyCustomDataStore; + } +} + +var store = new JSData.DS(); + +var myResourceDefinition = store.defineResource('myResource'); + +myResourceDefinition = store.definitions.myResource; \ No newline at end of file diff --git a/js-data/js-data.d.ts b/js-data/js-data.d.ts index 13fc5e691..b7271c4e2 100644 --- a/js-data/js-data.d.ts +++ b/js-data/js-data.d.ts @@ -16,7 +16,7 @@ // defining what exists in JSData and how it looks declare module JSData_ { - class JSDataPromise extends Promise { + interface JSDataPromise extends Promise { // enhanced with finally finally(finallyCb?:() => U):Promise; @@ -30,6 +30,10 @@ declare module JSData_ { // rather undocumented errors:DSErrors; + // those are objects containing the defined resources and adapters + definitions:any; + adapters:any; + defaults:DSConfiguration; changeHistory(resourceName:string, id?:string):Array; @@ -394,7 +398,8 @@ declare module JSData_ { // declaring the existing global js object declare var JSData:{ - DS: JSData_.DS + DS: JSData_.DS; + DSErrors: JSData_.DSErrors; }; //Support node require From 337a91729625ee481c5c1d526f54788bcc5ba6d4 Mon Sep 17 00:00:00 2001 From: Yuki KAN Date: Tue, 3 Mar 2015 07:03:28 +0900 Subject: [PATCH 140/185] add png-async definition --- png-async/png-async-tests.ts | 32 ++++++++++++++++++++ png-async/png-async.d.ts | 58 ++++++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+) create mode 100644 png-async/png-async-tests.ts create mode 100644 png-async/png-async.d.ts diff --git a/png-async/png-async-tests.ts b/png-async/png-async-tests.ts new file mode 100644 index 000000000..6523089a2 --- /dev/null +++ b/png-async/png-async-tests.ts @@ -0,0 +1,32 @@ +/// + +import fs = require('fs'); +import png = require('png-async'); + +var devnull = process.platform === 'win32' ? 'nul' : '/dev/null'; + +// stream test +var img = new png.Image({ + width: 1, + height: 1, + fill: true +}) + .pack() + .pipe(png.createImage({ + deflateStrategy: png.EDeflateStrategy.FIXED, + filterType: png.EFilterType.Auto + }) + .on('parsed', function () { + + if (this.data[0] !== 0) { + throw new Error('invalid data'); + } + + this.data[0] = 255; + this.data[3] = 255; + + this.pack().pipe(fs.createWriteStream(devnull)).on('finish', () => { + console.log('done'); + }); + }) + ); diff --git a/png-async/png-async.d.ts b/png-async/png-async.d.ts new file mode 100644 index 000000000..2898c4665 --- /dev/null +++ b/png-async/png-async.d.ts @@ -0,0 +1,58 @@ +// Type definitions for png-async +// Project: https://github.com/kanreisa/node-png-async +// Definitions by: Yuki KAN +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module 'png-async' { + import stream = require('stream'); + + export interface IImageOptions { + width?: number; + height?: number; + fill?: boolean; + checkCRC?: boolean; + deflateChunkSize?: number; + deflateLevel?: number; + deflateStrategy?: EDeflateStrategy; + filterType?: EFilterType; + } + + export enum EDeflateStrategy { + DEFAULT_STRATEGY = 0, + FILTERED = 1, + HUFFMAN_ONLY = 2, + RLE = 3, + FIXED = 4, + } + + export enum EFilterType { + Auto = -1, + None = 0, + Sub = 1, + Up = 2, + Average = 3, + Paeth = 4, + } + + export function createImage(option?: IImageOptions): Image; + + export class Image extends stream.Duplex { + width: number; + height: number; + gamma: number; + data: Buffer; + constructor(option?: IImageOptions); + pack(): Image; + parse(data: Buffer, callback?: (err: Error, image: Image) => void): Image; + write(data: any, cb?: any): boolean; + end(data?: any): void; + bitblt(dst: Image, sx: number, sy: number, w: number, h: number, dx: number, dy: number): Image; + + on(event: string, listener: Function): Image; + once(event: string, listener: Function): Image; + removeListener(event: string, listener: Function): Image; + removeAllListeners(event: string): Image; + } +} From ff82514eca5d50932c31a1e65afc4190b79553a9 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 3 Mar 2015 08:36:11 +0100 Subject: [PATCH 141/185] Added the findIndex function to underscore.d.ts --- underscore/underscore.d.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/underscore/underscore.d.ts b/underscore/underscore.d.ts index aeaf253ca..9f49bc47a 100644 --- a/underscore/underscore.d.ts +++ b/underscore/underscore.d.ts @@ -264,7 +264,22 @@ interface UnderscoreStatic { detect( object: _.Dictionary, iterator: _.ObjectIterator, - context?: any): T; + context?: any): T; + + /** + * Looks through each value in the list, returning the index of the first one that passes a truth + * test (iterator). The function returns as soon as it finds an acceptable element, + * and doesn't traverse the entire list. + * @param list Searches for a value in this list. + * @param iterator Search iterator function for each element in `list`. + * @param context `this` object in `iterator`, optional. + * @return The index of the first acceptable found element in `list`, if nothing is found -1 is returned. + **/ + findIndex( + list: _.List, + iterator: _.ListIterator, + context?: any): T; + /** * Looks through each value in the list, returning an array of all the values that pass a truth From 5bc218fa5c611f0e12a20b2a515ab3731e8a9e37 Mon Sep 17 00:00:00 2001 From: Marc-Andre Roy Date: Tue, 3 Mar 2015 09:30:07 -0500 Subject: [PATCH 142/185] Remove configure() definition in KnockoutValidationStatic since it's now deprecated. Use init() instead. --- knockout.validation/knockout.validation.d.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/knockout.validation/knockout.validation.d.ts b/knockout.validation/knockout.validation.d.ts index f0b956d03..3ce139a99 100644 --- a/knockout.validation/knockout.validation.d.ts +++ b/knockout.validation/knockout.validation.d.ts @@ -108,7 +108,6 @@ interface KnockoutValidationGroup { interface KnockoutValidationStatic { init(options?: KnockoutValidationConfiguration, force?: boolean): void; - configure(options: KnockoutValidationConfiguration): void; reset(): void; group(obj: any, options?: any): KnockoutValidationErrors; From c0c420cd6c77897e6d21de7f2e8ee4e78a37f4f0 Mon Sep 17 00:00:00 2001 From: Jonathan Park Date: Tue, 3 Mar 2015 11:15:49 -0800 Subject: [PATCH 143/185] hotkeys interface supports both string and string[] for combos --- angular-hotkeys/angular-hotkeys-tests.ts | 5 +++++ angular-hotkeys/angular-hotkeys.d.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/angular-hotkeys/angular-hotkeys-tests.ts b/angular-hotkeys/angular-hotkeys-tests.ts index a065d4b21..358410811 100644 --- a/angular-hotkeys/angular-hotkeys-tests.ts +++ b/angular-hotkeys/angular-hotkeys-tests.ts @@ -22,4 +22,9 @@ hotkeyProvider.bindTo(scope) description: 'blah blah', callback: function() {} }); + .add({ + combo: ['w', 'mod+w'], + description: 'blah blah', + callback: function() {} + }); diff --git a/angular-hotkeys/angular-hotkeys.d.ts b/angular-hotkeys/angular-hotkeys.d.ts index 63da273ce..83d5021cc 100644 --- a/angular-hotkeys/angular-hotkeys.d.ts +++ b/angular-hotkeys/angular-hotkeys.d.ts @@ -40,7 +40,7 @@ declare module ng.hotkeys { } interface Hotkey { - combo: string; + combo: string | string[]; description?: string; callback: (event: Event, hotkey: ng.hotkeys.Hotkey) => void; action?: string; From 07305d7e950b258d185e3484300d6353056d696b Mon Sep 17 00:00:00 2001 From: Jonathan Park Date: Tue, 3 Mar 2015 11:50:52 -0800 Subject: [PATCH 144/185] Extend to all interfaces --- angular-hotkeys/angular-hotkeys-tests.ts | 5 ++++- angular-hotkeys/angular-hotkeys.d.ts | 12 ++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/angular-hotkeys/angular-hotkeys-tests.ts b/angular-hotkeys/angular-hotkeys-tests.ts index 358410811..c683540a3 100644 --- a/angular-hotkeys/angular-hotkeys-tests.ts +++ b/angular-hotkeys/angular-hotkeys-tests.ts @@ -6,10 +6,13 @@ var hotkeyProvider: ng.hotkeys.HotkeysProvider; var hotkeyObj: ng.hotkeys.Hotkey; hotkeyProvider.add("mod+s", "saves a file", (event: Event, hotkey: ng.hotkeys.Hotkey) => {} ); +hotkeyProvider.add(["mod+s"], "saves a file", (event: Event, hotkey: ng.hotkeys.Hotkey) => {} ); hotkeyProvider.add(hotkeyObj); hotkeyProvider.bindTo(scope); hotkeyProvider.del("mod+s"); +hotkeyProvider.del(["mod+s"]); hotkeyProvider.get("mod+s"); +hotkeyProvider.get(["mod+s"]); hotkeyProvider.toggleCheatSheet(); hotkeyProvider.add(hotkeyObj.combo, hotkeyObj.description ,hotkeyObj.callback); @@ -21,7 +24,7 @@ hotkeyProvider.bindTo(scope) combo: 'w', description: 'blah blah', callback: function() {} - }); + }) .add({ combo: ['w', 'mod+w'], description: 'blah blah', diff --git a/angular-hotkeys/angular-hotkeys.d.ts b/angular-hotkeys/angular-hotkeys.d.ts index 83d5021cc..0c0b9109a 100644 --- a/angular-hotkeys/angular-hotkeys.d.ts +++ b/angular-hotkeys/angular-hotkeys.d.ts @@ -14,19 +14,19 @@ declare module ng.hotkeys { cheatSheetHotkey: string; cheatSheetDescription: string; - add(combo: string, callback: (event: Event, hotkey?: Hotkey) => void, action?: string, allowIn?: Array, persistent?: boolean): ng.hotkeys.Hotkey; + add(combo: string|string[], callback: (event: Event, hotkey?: Hotkey) => void, action?: string, allowIn?: Array, persistent?: boolean): ng.hotkeys.Hotkey; - add(combo: string, description: string, callback: (event: Event, hotkey?: Hotkey) => void, action?: string, allowIn?: Array, persistent?: boolean): ng.hotkeys.Hotkey; + add(combo: string|string[], description: string, callback: (event: Event, hotkey?: Hotkey) => void, action?: string, allowIn?: Array, persistent?: boolean): ng.hotkeys.Hotkey; add(hotkeyObj: ng.hotkeys.Hotkey): ng.hotkeys.Hotkey; bindTo(scope : ng.IScope): ng.hotkeys.HotkeysProviderChained; - del(combo: string): void; + del(combo: string|string[]): void; del(hotkeyObj: ng.hotkeys.Hotkey): void; - get(combo: string): ng.hotkeys.Hotkey; + get(combo: string|string[]): ng.hotkeys.Hotkey; toggleCheatSheet(): void; @@ -34,13 +34,13 @@ declare module ng.hotkeys { } interface HotkeysProviderChained { - add(combo: string, description: string, callback: (event: Event, hotkeys: ng.hotkeys.Hotkey) => void): HotkeysProviderChained; + add(combo: string|string[], description: string, callback: (event: Event, hotkeys: ng.hotkeys.Hotkey) => void): HotkeysProviderChained; add(hotkeyObj: ng.hotkeys.Hotkey): HotkeysProviderChained; } interface Hotkey { - combo: string | string[]; + combo: string|string[]; description?: string; callback: (event: Event, hotkey: ng.hotkeys.Hotkey) => void; action?: string; From a76035cfb80d12c5f9155bff95040c2d7e3ade31 Mon Sep 17 00:00:00 2001 From: Tim JK Date: Wed, 4 Mar 2015 10:09:03 +1300 Subject: [PATCH 145/185] Add type definitions for polyglot.js --- node-polyglot/node-polyglot-tests.ts | 47 ++++++++++++++++++++++++++++ node-polyglot/node-polyglot.d.ts | 42 +++++++++++++++++++++++++ 2 files changed, 89 insertions(+) create mode 100644 node-polyglot/node-polyglot-tests.ts create mode 100644 node-polyglot/node-polyglot.d.ts diff --git a/node-polyglot/node-polyglot-tests.ts b/node-polyglot/node-polyglot-tests.ts new file mode 100644 index 000000000..fee07d79e --- /dev/null +++ b/node-polyglot/node-polyglot-tests.ts @@ -0,0 +1,47 @@ +import Polyglot = require("node-polyglot"); + +function instantiatePolyglot(): void { + var polyglot = new Polyglot(); + var phrasedPolyglot = new Polyglot({phrases: {"hello": "Hello"}}); + var localePolyglot = new Polyglot({locale: "fr"}); +} + +function translate(): void { + var polyglot = new Polyglot(); + + polyglot.extend({ + "hello": "Hello", + "hello_name": "Hola, %{name}.", + "nav": { + "sidebar": { + "welcome": "Welcome" + } + }, + "num_cars": "%{smart_count} car |||| %{smart_count} cars" + }); + + polyglot.t("hello"); + polyglot.t("hello_name"); + polyglot.t("nav.sidebar.welcome"); + polyglot.t("num_cars", {smart_count: 0}); + polyglot.t("num_cars", 0); + polyglot.t("hello_name", {name: "Spike"}); + polyglot.t("i_like_to_write_in_language", { + _: "I like to write in %{language}.", + language: "Javascript" + }); + + polyglot.replace({ + "hello": "hey", + "nav": { + "sidebar": { + "welcome": "Greetings" + } + } + }); + + polyglot.clear(); + + polyglot.locale("fr"); + polyglot.locale(); +} diff --git a/node-polyglot/node-polyglot.d.ts b/node-polyglot/node-polyglot.d.ts new file mode 100644 index 000000000..1b3469f02 --- /dev/null +++ b/node-polyglot/node-polyglot.d.ts @@ -0,0 +1,42 @@ +// Type definitions for node-polyglot v0.4.1 +// Project: https://github.com/airbnb/polyglot.js +// Definitions by: Tim Jackson-Kiely +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module "node-polyglot" { + module Polyglot { + interface InterpolationOptions { + name?: string; + smart_count?: number; + _?: string; + } + + interface PolyglotOptions { + phrases?: any; + locale?: string; + } + } + + class Polyglot { + constructor(options?: Polyglot.PolyglotOptions); + + extend(phrases: any): void; + + t(phrase: string): string; + + t(phrase: string, smartCount: number): string; + + t(phrase: string, interpolationOptions: Polyglot.InterpolationOptions): string; + + clear(): void; + + replace(phrases: any): void; + + locale(): string; + + locale(locale: string): void; + } + + export = Polyglot; +} + From ac52e5a7324b98731d92717be24cd547a9f78e46 Mon Sep 17 00:00:00 2001 From: Tim Jackson-Kiely Date: Wed, 4 Mar 2015 10:40:18 +1300 Subject: [PATCH 146/185] Remove unnecessary name field --- node-polyglot/node-polyglot.d.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/node-polyglot/node-polyglot.d.ts b/node-polyglot/node-polyglot.d.ts index 1b3469f02..0f5bd8922 100644 --- a/node-polyglot/node-polyglot.d.ts +++ b/node-polyglot/node-polyglot.d.ts @@ -6,7 +6,6 @@ declare module "node-polyglot" { module Polyglot { interface InterpolationOptions { - name?: string; smart_count?: number; _?: string; } From d779349a3e4fffbc08608abafc788978ac492704 Mon Sep 17 00:00:00 2001 From: Nathan Brown Date: Tue, 3 Mar 2015 15:50:12 -0700 Subject: [PATCH 147/185] Update angular.d.ts to fix IHttpPromise. IHttpPromise does not extend IPromise directly. It always transforms it with the response (of type T) as the `data` member. See $httpProvider.$http.sendRec.resolvePromise(response, status, headers, statusText). This matters when exploiting the inheritance to IPromise (for example in a return). --- angularjs/angular.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts index 2f88253f0..217deacf5 100755 --- a/angularjs/angular.d.ts +++ b/angularjs/angular.d.ts @@ -1262,7 +1262,7 @@ declare module ng { statusText?: string; } - interface IHttpPromise extends IPromise { + interface IHttpPromise extends IPromise> { success(callback: IHttpPromiseCallback): IHttpPromise; error(callback: IHttpPromiseCallback): IHttpPromise; then(successCallback: (response: IHttpPromiseCallbackArg) => IPromise|TResult, errorCallback?: (response: IHttpPromiseCallbackArg) => any): IPromise; From 370cffb381ddc2003fbb9214c0cb086741c25a76 Mon Sep 17 00:00:00 2001 From: Wim Looman Date: Wed, 4 Mar 2015 13:49:13 +1300 Subject: [PATCH 148/185] Add definitions for methods to change the default rest client --- rest/rest-tests.ts | 14 ++++++++++++++ rest/rest.d.ts | 28 ++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/rest/rest-tests.ts b/rest/rest-tests.ts index 26346389f..6d267c792 100644 --- a/rest/rest-tests.ts +++ b/rest/rest-tests.ts @@ -135,3 +135,17 @@ client = rest .wrap(fail) .wrap(knownConfig, { prop: 'value' }) .wrap(transformedConfig, { prop: 'value' }); + +import xhrClient = require('rest/client/xhr'); +import nodeClient = require('rest/client/node'); +import jsonpClient = require('rest/client/jsonp'); +import xdrClient = require('rest/client/xdr'); + +rest.setDefaultClient(xhrClient); +rest.setDefaultClient(nodeClient); +rest.setDefaultClient(jsonpClient); +rest.setDefaultClient(xdrClient); + +var defaultClient: rest.Client = rest.getDefaultClient(); + +rest.resetDefaultClient(); diff --git a/rest/rest.d.ts b/rest/rest.d.ts index 37041e150..a96e0822a 100644 --- a/rest/rest.d.ts +++ b/rest/rest.d.ts @@ -14,6 +14,10 @@ declare module "rest" { function rest(request: rest.Request): rest.ResponsePromise; module rest { + export function setDefaultClient(client: Client): void; + export function getDefaultClient(): Client; + export function resetDefaultClient(): void; + export function wrap(interceptor: Interceptor, config?: T): Client; export interface Request { @@ -319,3 +323,27 @@ declare module "rest/mime/registry" { export = registry; } + +declare module "rest/client/xhr" { + import rest = require("rest"); + var xhr: rest.Client; + export = xhr; +} + +declare module "rest/client/node" { + import rest = require("rest"); + var node: rest.Client; + export = node; +} + +declare module "rest/client/jsonp" { + import rest = require("rest"); + var jsonp: rest.Client; + export = jsonp; +} + +declare module "rest/client/xdr" { + import rest = require("rest"); + var xdr: rest.Client; + export = xdr; +} From 8decf27bad87b53c00cb54026faf05cf0002531d Mon Sep 17 00:00:00 2001 From: JasonS Date: Tue, 3 Mar 2015 17:43:45 -0800 Subject: [PATCH 149/185] add bunyan-prettystream definition. --- bunyan-prettystream/bunyan-prettystream.d.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 bunyan-prettystream/bunyan-prettystream.d.ts diff --git a/bunyan-prettystream/bunyan-prettystream.d.ts b/bunyan-prettystream/bunyan-prettystream.d.ts new file mode 100644 index 000000000..cc8fb8219 --- /dev/null +++ b/bunyan-prettystream/bunyan-prettystream.d.ts @@ -0,0 +1,13 @@ +// type definitions for bunyan-prettystream +// project: https://www.npmjs.com/package/bunyan-prettystream +// definitions by jasons@novaleaf.com + +/// + +declare module "bunyan-prettystream" { + import stream = require("stream"); + class PrettyStream extends stream.Writable { + public pipe(destination: T, options?: { end?: boolean; }): T; + } + export = PrettyStream; +} \ No newline at end of file From 0f83c5eb09195da52eb0db3cb441f58cbce64ba2 Mon Sep 17 00:00:00 2001 From: JasonS Date: Tue, 3 Mar 2015 17:48:34 -0800 Subject: [PATCH 150/185] fix relative path to node in bunyan-prettystream definition. --- bunyan-prettystream/bunyan-prettystream.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bunyan-prettystream/bunyan-prettystream.d.ts b/bunyan-prettystream/bunyan-prettystream.d.ts index cc8fb8219..dd7309f03 100644 --- a/bunyan-prettystream/bunyan-prettystream.d.ts +++ b/bunyan-prettystream/bunyan-prettystream.d.ts @@ -2,7 +2,7 @@ // project: https://www.npmjs.com/package/bunyan-prettystream // definitions by jasons@novaleaf.com -/// +/// declare module "bunyan-prettystream" { import stream = require("stream"); From 5143ee98558e88b57b8587d986d99200b0f0ec9d Mon Sep 17 00:00:00 2001 From: JasonS Date: Tue, 3 Mar 2015 18:04:12 -0800 Subject: [PATCH 151/185] bunyan-prettystream: fix formatting of header, add tests, test it --- bunyan-prettystream/bunyan-prettystream-tests.ts | 4 ++++ bunyan-prettystream/bunyan-prettystream.d.ts | 7 ++++--- 2 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 bunyan-prettystream/bunyan-prettystream-tests.ts diff --git a/bunyan-prettystream/bunyan-prettystream-tests.ts b/bunyan-prettystream/bunyan-prettystream-tests.ts new file mode 100644 index 000000000..3dd7b15a3 --- /dev/null +++ b/bunyan-prettystream/bunyan-prettystream-tests.ts @@ -0,0 +1,4 @@ +/// + +import PrettyStream = require("bunyan-prettystream"); +var stream = new PrettyStream(); diff --git a/bunyan-prettystream/bunyan-prettystream.d.ts b/bunyan-prettystream/bunyan-prettystream.d.ts index dd7309f03..9f9fa4f57 100644 --- a/bunyan-prettystream/bunyan-prettystream.d.ts +++ b/bunyan-prettystream/bunyan-prettystream.d.ts @@ -1,6 +1,7 @@ -// type definitions for bunyan-prettystream -// project: https://www.npmjs.com/package/bunyan-prettystream -// definitions by jasons@novaleaf.com +// Type definitions for bunyan-prettystream +// Project: https://www.npmjs.com/package/bunyan-prettystream +// Definitions by: Jason Swearingen +// Definitions: https://github.com/borisyankov/DefinitelyTyped /// From 4837e53d25ed093aed6a5cf3120934f8ce0b9590 Mon Sep 17 00:00:00 2001 From: Keita Kagurazaka Date: Wed, 4 Mar 2015 03:56:11 +0000 Subject: [PATCH 152/185] Add definitions and tests for gulp-concat --- gulp-concat/gulp-concat-tests.ts | 23 +++++++++++++++++ gulp-concat/gulp-concat.d.ts | 42 ++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 gulp-concat/gulp-concat-tests.ts create mode 100644 gulp-concat/gulp-concat.d.ts diff --git a/gulp-concat/gulp-concat-tests.ts b/gulp-concat/gulp-concat-tests.ts new file mode 100644 index 000000000..a2a475b97 --- /dev/null +++ b/gulp-concat/gulp-concat-tests.ts @@ -0,0 +1,23 @@ +/// +/// + +import gulp = require("gulp"); +import concat = require("gulp-concat"); + +gulp.task("concat:simple", () => { + gulp.src(["file*.txt"]) + .pipe(concat("file.txt")) + .pipe(gulp.dest("build")); +}); + +gulp.task("concat:newLine", () => { + gulp.src(["file*.txt"]) + .pipe(concat("file.txt", { newLine: ";" })) + .pipe(gulp.dest("build")); +}); + +gulp.task("concat:vinyl", () => { + gulp.src(["file*.txt"]) + .pipe(concat({ path: "file.txt", stat: { mode: 0666 } })) + .pipe(gulp.dest("build")); +}); diff --git a/gulp-concat/gulp-concat.d.ts b/gulp-concat/gulp-concat.d.ts new file mode 100644 index 000000000..cad21c303 --- /dev/null +++ b/gulp-concat/gulp-concat.d.ts @@ -0,0 +1,42 @@ +// Type definitions for gulp-concat +// Project: http://github.com/wearefractal/gulp-concat +// Definitions by: Keita Kagurazaka +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module "gulp-concat" { + + interface IOptions { + newLine: string; + } + + interface IFsStats { + dev?: number; + ino?: number; + mode?: number; + nlink?: number; + uid?: number; + gid?: number; + rdev?: number; + size?: number; + blksize?: number; + blocks?: number; + atime?: Date; + mtime?: Date; + ctime?: Date; + } + + interface IVinylOptions { + cwd?: string; + base?: string; + path?: string; + stat?: IFsStats; + contents?: NodeJS.ReadableStream | Buffer; + } + + function concat(filename: string, options?: IOptions): NodeJS.ReadWriteStream; + function concat(options: IVinylOptions): NodeJS.ReadWriteStream; + + export = concat; +} From 8c5f9860a49defcaad100aed4c599e57b404f8aa Mon Sep 17 00:00:00 2001 From: Keita Kagurazaka Date: Wed, 4 Mar 2015 04:40:03 +0000 Subject: [PATCH 153/185] Add definitions and tests for gulp-flatten --- gulp-flatten/gulp-flatten-tests.ts | 17 +++++++++++++++++ gulp-flatten/gulp-flatten.d.ts | 17 +++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 gulp-flatten/gulp-flatten-tests.ts create mode 100644 gulp-flatten/gulp-flatten.d.ts diff --git a/gulp-flatten/gulp-flatten-tests.ts b/gulp-flatten/gulp-flatten-tests.ts new file mode 100644 index 000000000..ee5622564 --- /dev/null +++ b/gulp-flatten/gulp-flatten-tests.ts @@ -0,0 +1,17 @@ +/// +/// + +import gulp = require("gulp"); +import flatten = require("gulp-flatten"); + +gulp.task("flatten:simple", () => { + gulp.src(["files/**/*.txt"]) + .pipe(flatten()) + .pipe(gulp.dest("build")); +}); + +gulp.task("flatten:newPath", () => { + gulp.src(["files/**/*.txt"]) + .pipe(flatten({ newPath: "new/path" })) + .pipe(gulp.dest("build")); +}); diff --git a/gulp-flatten/gulp-flatten.d.ts b/gulp-flatten/gulp-flatten.d.ts new file mode 100644 index 000000000..ccd9cedf1 --- /dev/null +++ b/gulp-flatten/gulp-flatten.d.ts @@ -0,0 +1,17 @@ +// Type definitions for gulp-flatten +// Project: https://github.com/armed/gulp-flatten +// Definitions by: Keita Kagurazaka +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module "gulp-flatten" { + + interface IOptions { + newPath: string; + } + + function flatten(options?: IOptions): NodeJS.ReadWriteStream; + + export = flatten; +} From 3613a5f06a168bb83b9a4f0b2c1df02c5a3ab038 Mon Sep 17 00:00:00 2001 From: Keita Kagurazaka Date: Wed, 4 Mar 2015 04:59:29 +0000 Subject: [PATCH 154/185] Add definitions and tests for gulp-inject --- gulp-inject/gulp-inject-tests.ts | 41 ++++++++++++++++++++++++++++++++ gulp-inject/gulp-inject.d.ts | 36 ++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 gulp-inject/gulp-inject-tests.ts create mode 100644 gulp-inject/gulp-inject.d.ts diff --git a/gulp-inject/gulp-inject-tests.ts b/gulp-inject/gulp-inject-tests.ts new file mode 100644 index 000000000..804e6f9b5 --- /dev/null +++ b/gulp-inject/gulp-inject-tests.ts @@ -0,0 +1,41 @@ +/// +/// + +import gulp = require("gulp"); +import inject = require("gulp-inject"); + +gulp.task("inject:simple", () => { + gulp.src("src/index.html") + .pipe(inject(gulp.src(["src/**/*.js", "src/**/*.css"], { read: false }))) + .pipe(gulp.dest("build")); +}); + +gulp.task("inject:relative", () => { + gulp.src(["src/index.html"]) + .pipe(inject(gulp.src(["src/**/*.js", "src/**/*.css"], { read: false }), { relative: true })) + .pipe(gulp.dest("build")); +}); + +gulp.task("inject:starttag", () => { + gulp.src(["src/index.html"]) + .pipe(inject(gulp.src(["src/**/*.js", "src/**/*.css"], { read: false }), { starttag: "" })) + .pipe(gulp.dest("build")); +}); + +gulp.task("inject:name", () => { + gulp.src(["src/index.html"]) + .pipe(inject(gulp.src(["src/**/*.js", "src/**/*.css"], { read: false }), { name: "head" })) + .pipe(gulp.dest("build")); +}); + +gulp.task("inject:transform", () => { + gulp.src(["files.json"]) + .pipe(inject(gulp.src(["src/**/*.js", "src/**/*.css", "src/**/*.html"], { read: false }), { + starttag: "\"{{ext}}\": [", + endtag: "]", + transform: (filepath, file, i, length) => { + return " \"" + filepath + "\"" + (i + 1 < length ? "," : ""); + } + })) + .pipe(gulp.dest("build")); +}); diff --git a/gulp-inject/gulp-inject.d.ts b/gulp-inject/gulp-inject.d.ts new file mode 100644 index 000000000..42f5fb348 --- /dev/null +++ b/gulp-inject/gulp-inject.d.ts @@ -0,0 +1,36 @@ +// Type definitions for gulp-inject +// Project: https://github.com/klei/gulp-inject +// Definitions by: Keita Kagurazaka +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// +/// + +declare module "gulp-inject" { + + import File = require("vinyl"); + + interface ITagFunction { + (targetExt: string, sourceExt: string): string; + } + + interface ITransformFunction { + (filepath: string, file?: File, index?: number, length?: number, targetFile?: File): string; + } + + interface IOptions { + ignorePath?: string | string[]; + relative?: boolean; + addPrefix?: string; + addRootSlash?: boolean; + name?: string; + starttag?: string | ITagFunction; + endtag?: string | ITagFunction; + transform?: ITransformFunction; + selfClosingTag?: boolean; + } + + function inject(sources: NodeJS.ReadableStream, options?: IOptions): NodeJS.ReadWriteStream; + + export = inject; +} From 4c11c0079c1c28c6dee540914b8b220172b98ef7 Mon Sep 17 00:00:00 2001 From: Keita Kagurazaka Date: Wed, 4 Mar 2015 05:28:53 +0000 Subject: [PATCH 155/185] Add definitions and tests for gulp-less --- gulp-less/gulp-less-tests.ts | 13 +++++++++++++ gulp-less/gulp-less.d.ts | 18 ++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 gulp-less/gulp-less-tests.ts create mode 100644 gulp-less/gulp-less.d.ts diff --git a/gulp-less/gulp-less-tests.ts b/gulp-less/gulp-less-tests.ts new file mode 100644 index 000000000..76e0a697c --- /dev/null +++ b/gulp-less/gulp-less-tests.ts @@ -0,0 +1,13 @@ +/// +/// + +import gulp = require("gulp"); +import less = require("gulp-less"); + +gulp.task("less", () => { + gulp.src("less/**/*.less") + .pipe(less({ + paths: ["less/includes"] + })) + .pipe(gulp.dest("public/css")); +}); diff --git a/gulp-less/gulp-less.d.ts b/gulp-less/gulp-less.d.ts new file mode 100644 index 000000000..9ca5e35b7 --- /dev/null +++ b/gulp-less/gulp-less.d.ts @@ -0,0 +1,18 @@ +// Type definitions for gulp-less +// Project: https://github.com/plus3network/gulp-less +// Definitions by: Keita Kagurazaka +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module "gulp-less" { + + interface IOptions { + paths: string[]; + plugins?: any[]; + } + + function less(options?: IOptions): NodeJS.ReadWriteStream; + + export = less; +} From ab697a6bbdedefc89af863b16e35c51eb57dbafa Mon Sep 17 00:00:00 2001 From: Keita Kagurazaka Date: Wed, 4 Mar 2015 06:15:45 +0000 Subject: [PATCH 156/185] Add definitions and tests for gulp-minify-css --- gulp-minify-css/gulp-minify-css-tests.ts | 11 +++++++++ gulp-minify-css/gulp-minify-css.d.ts | 31 ++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 gulp-minify-css/gulp-minify-css-tests.ts create mode 100644 gulp-minify-css/gulp-minify-css.d.ts diff --git a/gulp-minify-css/gulp-minify-css-tests.ts b/gulp-minify-css/gulp-minify-css-tests.ts new file mode 100644 index 000000000..1375042dd --- /dev/null +++ b/gulp-minify-css/gulp-minify-css-tests.ts @@ -0,0 +1,11 @@ +/// +/// + +import gulp = require("gulp"); +import minifyCSS = require("gulp-minify-css"); + +gulp.task("minify-css", () => { + gulp.src("css/**/*.css") + .pipe(minifyCSS({ keepBreaks: true })) + .pipe(gulp.dest("dist")); +}); diff --git a/gulp-minify-css/gulp-minify-css.d.ts b/gulp-minify-css/gulp-minify-css.d.ts new file mode 100644 index 000000000..be6d45b8b --- /dev/null +++ b/gulp-minify-css/gulp-minify-css.d.ts @@ -0,0 +1,31 @@ +// Type definitions for gulp-minify-css +// Project: https://github.com/jonathanepollack/gulp-minify-css +// Definitions by: Keita Kagurazaka +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module "gulp-minify-css" { + + interface IOptions { + cache?: boolean; + advanced?: boolean; + aggressiveMerging?: boolean; + benchmark?: boolean; + compatibility?: string; + debug?: boolean; + inliner?: Object; + keepBreaks?: boolean; + keepSpecialComments?: string | number; + processImport?: boolean; + rebase?: boolean; + relativeTo?: string; + root?: string; + roundingPrecision?: number; + shorthandCompacting?: boolean; + } + + function minifyCSS(options?: IOptions): NodeJS.ReadWriteStream; + + export = minifyCSS; +} From 3492e30a639f3e079dc31bdd4077e4033b67065f Mon Sep 17 00:00:00 2001 From: Keita Kagurazaka Date: Wed, 4 Mar 2015 06:25:34 +0000 Subject: [PATCH 157/185] Add definitions and tests for gulp-tsd --- gulp-tsd/gulp-tsd-tests.ts | 17 +++++++++++++++++ gulp-tsd/gulp-tsd.d.ts | 21 +++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 gulp-tsd/gulp-tsd-tests.ts create mode 100644 gulp-tsd/gulp-tsd.d.ts diff --git a/gulp-tsd/gulp-tsd-tests.ts b/gulp-tsd/gulp-tsd-tests.ts new file mode 100644 index 000000000..9475ace65 --- /dev/null +++ b/gulp-tsd/gulp-tsd-tests.ts @@ -0,0 +1,17 @@ +/// +/// + +import gulp = require("gulp"); +import tsd = require("gulp-tsd"); + +gulp.task("tsd", () => { + gulp.src("gulp_tsd.json") + .pipe(tsd()); +}); + +gulp.task("tsd:options", callback => { + tsd({ + command: "reinstall", + config: "tsd.json" + }, callback); +}); diff --git a/gulp-tsd/gulp-tsd.d.ts b/gulp-tsd/gulp-tsd.d.ts new file mode 100644 index 000000000..68a4c6728 --- /dev/null +++ b/gulp-tsd/gulp-tsd.d.ts @@ -0,0 +1,21 @@ +// Type definitions for gulp-tsd +// Project: https://github.com/moznion/gulp-tsd +// Definitions by: Keita Kagurazaka +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// +/// + +declare module "gulp-tsd" { + + interface IOptions { + command?: string; + latest?: boolean; + config?: string; + opts?: Object; + } + + function tsd(opts?: IOptions, callback?: gulp.ITaskCallback): NodeJS.ReadWriteStream; + + export = tsd; +} From 5bff44a0592dc2de161477d22ff9c2f31105ca81 Mon Sep 17 00:00:00 2001 From: Keita Kagurazaka Date: Wed, 4 Mar 2015 06:46:32 +0000 Subject: [PATCH 158/185] Add definitions and tests for main-bower-files --- main-bower-files/main-bower-files-tests.ts | 31 ++++++++++++++++++++ main-bower-files/main-bower-files.d.ts | 34 ++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 main-bower-files/main-bower-files-tests.ts create mode 100644 main-bower-files/main-bower-files.d.ts diff --git a/main-bower-files/main-bower-files-tests.ts b/main-bower-files/main-bower-files-tests.ts new file mode 100644 index 000000000..1658b3800 --- /dev/null +++ b/main-bower-files/main-bower-files-tests.ts @@ -0,0 +1,31 @@ +/// +/// + +import gulp = require("gulp"); +import mainBowerFiles = require("main-bower-files"); + +gulp.task("main-bower-files:simple", () => { + gulp.src(mainBowerFiles()) + .pipe(gulp.dest("dist/bower")); +}); + +gulp.task("main-bower-files:options", () => { + var files = mainBowerFiles({ + debugging: false, + env: process.env.NODE_ENV, + paths: { + bowerDirectory: "path/for/bower_components", + bowerrc: "path/for/.bowerrc", + bowerJson: "path/for/bower.json" + }, + checkExistence: false, + includeDev: false, + includeSelf: false, + filter: (filepath) => { + return filepath.indexOf("search") >= 0; + } + }); + + gulp.src(files, { base: "path/to/bower_components" }) + .pipe(gulp.dest("dist/bower")); +}); diff --git a/main-bower-files/main-bower-files.d.ts b/main-bower-files/main-bower-files.d.ts new file mode 100644 index 000000000..80a4996db --- /dev/null +++ b/main-bower-files/main-bower-files.d.ts @@ -0,0 +1,34 @@ +// Type definitions for main-bower-files +// Project: https://github.com/ck86/main-bower-files +// Definitions by: Keita Kagurazaka +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module "main-bower-files" { + + interface IPaths { + bowerDirectory?: string; + bowerrc?: string; + bowerJson?: string; + } + + interface IFilterFunction { + (filepath: string): boolean; + } + + interface IOptions { + debugging?: boolean; + main?: string | string[] | Object; + env?: string; + paths?: IPaths | string; + checkExistence?: boolean; + includeDev?: boolean | string; + includeSelf?: boolean; + filter?: RegExp | IFilterFunction | string | string[]; + } + + function mainBowerFiles(options?: IOptions): string[]; + + export = mainBowerFiles; +} From dc2c61c4b295d88befeba7fa542582d0e8ec85dc Mon Sep 17 00:00:00 2001 From: Keita Kagurazaka Date: Wed, 4 Mar 2015 07:21:08 +0000 Subject: [PATCH 159/185] Add definitions and tests for merge-stream --- merge-stream/merge-stream-tests.ts | 13 +++++++++++++ merge-stream/merge-stream.d.ts | 16 ++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 merge-stream/merge-stream-tests.ts create mode 100644 merge-stream/merge-stream.d.ts diff --git a/merge-stream/merge-stream-tests.ts b/merge-stream/merge-stream-tests.ts new file mode 100644 index 000000000..e0c744953 --- /dev/null +++ b/merge-stream/merge-stream-tests.ts @@ -0,0 +1,13 @@ +/// + +import stream = require("stream"); +import Stream = stream.Readable; +import merge = require("merge-stream"); + +var stream1 = new Stream(); +var stream2 = new Stream(); + +var merged = merge(stream1, stream2); + +var stream3 = new Stream(); +merged.add(stream3); diff --git a/merge-stream/merge-stream.d.ts b/merge-stream/merge-stream.d.ts new file mode 100644 index 000000000..6dfffdb95 --- /dev/null +++ b/merge-stream/merge-stream.d.ts @@ -0,0 +1,16 @@ +// Type definitions for merge-stream +// Project: https://github.com/grncdr/merge-stream +// Definitions by: Keita Kagurazaka +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module "merge-stream" { + + interface IMergedStream extends NodeJS.ReadWriteStream { + add: (source: NodeJS.ReadableStream) => IMergedStream; + } + + function merge(...streams: T[]): IMergedStream; + export = merge; +} From 0e40e8a1a4b150bd08cac4c0587e4fde709b6092 Mon Sep 17 00:00:00 2001 From: Keita Kagurazaka Date: Wed, 4 Mar 2015 07:43:52 +0000 Subject: [PATCH 160/185] Add definitions and tests for run-sequence --- run-sequence/run-sequence-tests.ts | 33 ++++++++++++++++++++++++++++++ run-sequence/run-sequence.d.ts | 19 +++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 run-sequence/run-sequence-tests.ts create mode 100644 run-sequence/run-sequence.d.ts diff --git a/run-sequence/run-sequence-tests.ts b/run-sequence/run-sequence-tests.ts new file mode 100644 index 000000000..98e57d9f3 --- /dev/null +++ b/run-sequence/run-sequence-tests.ts @@ -0,0 +1,33 @@ +/// +/// + +import gulp = require("gulp"); +import tmp = require("run-sequence"); +var runSequence = tmp.use(gulp); + +gulp.task("run-sequence", callback => { + runSequence("task1", + ["task2", "task3"], + "taks4", + callback); +}); + +gulp.task("task1", () => { + gulp.src("file1.txt") + .pipe(gulp.dest("build")); +}); + +gulp.task("task2", () => { + gulp.src("file2.txt") + .pipe(gulp.dest("build")); +}); + +gulp.task("task3", () => { + gulp.src("file3.txt") + .pipe(gulp.dest("build")); +}); + +gulp.task("task4", () => { + gulp.src("file4.txt") + .pipe(gulp.dest("build")); +}); diff --git a/run-sequence/run-sequence.d.ts b/run-sequence/run-sequence.d.ts new file mode 100644 index 000000000..3a2cb449c --- /dev/null +++ b/run-sequence/run-sequence.d.ts @@ -0,0 +1,19 @@ +// Type definitions for run-sequence +// Project: https://github.com/OverZealous/run-sequence +// Definitions by: Keita Kagurazaka +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// +/// + +declare module "run-sequence" { + + interface IRunSequence { + (...streams: (string | string[] | gulp.ITaskCallback)[]): NodeJS.ReadWriteStream; + + use(gulp: gulp.Gulp): IRunSequence; + } + + var _tmp: IRunSequence; + export = _tmp; +} From 729356c657f45bef570286595a22ee4ea4e02fd9 Mon Sep 17 00:00:00 2001 From: Keita Kagurazaka Date: Wed, 4 Mar 2015 07:56:14 +0000 Subject: [PATCH 161/185] Add definitions and tests for stream-series --- stream-series/stream-series-tests.ts | 12 ++++++++++++ stream-series/stream-series.d.ts | 11 +++++++++++ 2 files changed, 23 insertions(+) create mode 100644 stream-series/stream-series-tests.ts create mode 100644 stream-series/stream-series.d.ts diff --git a/stream-series/stream-series-tests.ts b/stream-series/stream-series-tests.ts new file mode 100644 index 000000000..2ed31ffb1 --- /dev/null +++ b/stream-series/stream-series-tests.ts @@ -0,0 +1,12 @@ +/// + +import stream = require("stream"); +import Stream = stream.Duplex; +import series = require("stream-series"); + +var stream1 = new Stream(); +var stream2 = new Stream(); +var stream3 = new Stream(); + +var orderedStream = series(stream1, stream3, stream2); +console.log(orderedStream.toString()); diff --git a/stream-series/stream-series.d.ts b/stream-series/stream-series.d.ts new file mode 100644 index 000000000..6c2d07d78 --- /dev/null +++ b/stream-series/stream-series.d.ts @@ -0,0 +1,11 @@ +// Type definitions for stream-series +// Project: https://github.com/rschmukler/stream-series +// Definitions by: Keita Kagurazaka +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module "stream-series" { + function series(...streams: T[]): NodeJS.ReadWriteStream; + export = series; +} From 5f2cc5b96612afdc1583f3171c6cf4038d7368ba Mon Sep 17 00:00:00 2001 From: reppners Date: Wed, 4 Mar 2015 09:09:27 +0100 Subject: [PATCH 162/185] + renaming module JSData_ to JSData since it is possible to declare var and module with the same name --- js-data-angular/js-data-angular-tests.ts | 8 ++--- js-data-angular/js-data-angular.d.ts | 2 +- js-data-http/js-data-http-tests.ts | 4 +-- js-data-http/js-data-http.d.ts | 4 +-- js-data/js-data-tests.ts | 38 ++++++++++++------------ js-data/js-data.d.ts | 6 ++-- 6 files changed, 31 insertions(+), 31 deletions(-) diff --git a/js-data-angular/js-data-angular-tests.ts b/js-data-angular/js-data-angular-tests.ts index 670857dec..8e036212f 100644 --- a/js-data-angular/js-data-angular-tests.ts +++ b/js-data-angular/js-data-angular-tests.ts @@ -12,7 +12,7 @@ interface CustomScope extends ng.IScope { } angular.module('myApp') - .controller('commentsCtrl', function ($scope:CustomScope, store:JSData_.DS, Comment:JSData_.DSResourceDefinition, User:JSData_.DSResourceDefinition) { + .controller('commentsCtrl', function ($scope:CustomScope, store:JSData.DS, Comment:JSData.DSResourceDefinition, User:JSData.DSResourceDefinition) { Comment.findAll().then(function (comments) { $scope.comments = comments; @@ -54,7 +54,7 @@ angular.module('myApp') }); angular.module('myApp') - .run(function (DS:JSData_.DS) { + .run(function (DS:JSData.DS) { // We don't register the "User" resource // as a service, so it can only be used // via DS.('user', ...) @@ -63,7 +63,7 @@ angular.module('myApp') // only ever have to inject "DS" DS.defineResource('user'); }) - .factory('Comment', function (DS:JSData_.DS) { + .factory('Comment', function (DS:JSData.DS) { // This code won't execute unless you actually // inject "Comment" somewhere in your code. // Thanks Angular... @@ -73,6 +73,6 @@ angular.module('myApp') }); angular.module('myApp') - .config(function (DSProvider:JSData_.DSProvider) { + .config(function (DSProvider:JSData.DSProvider) { DSProvider.defaults.basePath = '/myApi'; // etc. }); \ No newline at end of file diff --git a/js-data-angular/js-data-angular.d.ts b/js-data-angular/js-data-angular.d.ts index 851512d15..11a295562 100644 --- a/js-data-angular/js-data-angular.d.ts +++ b/js-data-angular/js-data-angular.d.ts @@ -6,7 +6,7 @@ /// /// -declare module JSData_ { +declare module JSData { interface DSProvider { defaults:DSConfiguration; diff --git a/js-data-http/js-data-http-tests.ts b/js-data-http/js-data-http-tests.ts index 41459ed81..d7c07d654 100644 --- a/js-data-http/js-data-http-tests.ts +++ b/js-data-http/js-data-http-tests.ts @@ -4,7 +4,7 @@ var adapter = new DSHttpAdapter(); var store = new JSData.DS(); store.registerAdapter('http', adapter, { default: true }); -var ADocument:JSData_.DSResourceDefinition = store.defineResource('document'); +var ADocument:JSData.DSResourceDefinition = store.defineResource('document'); ADocument.inject({ id: 5, author: 'John' }); @@ -73,7 +73,7 @@ adapter.GET('/user/1').then(function (data) { data.config; //{...} }); -var User:JSData_.DSResourceDefinition = store.defineResource('user'); +var User:JSData.DSResourceDefinition = store.defineResource('user'); var params:any = { age: { diff --git a/js-data-http/js-data-http.d.ts b/js-data-http/js-data-http.d.ts index 3a8a8adf0..626f55648 100644 --- a/js-data-http/js-data-http.d.ts +++ b/js-data-http/js-data-http.d.ts @@ -5,7 +5,7 @@ /// -declare module JSData_ { +declare module JSData { interface DSHttpAdapterOptions { serialize?: (resourceName:string, data:any)=>any; @@ -43,4 +43,4 @@ declare module JSData_ { } } -declare var DSHttpAdapter:JSData_.DSHttpAdapter; \ No newline at end of file +declare var DSHttpAdapter:JSData.DSHttpAdapter; \ No newline at end of file diff --git a/js-data/js-data-tests.ts b/js-data/js-data-tests.ts index a6ac09a42..35fdbf00f 100644 --- a/js-data/js-data-tests.ts +++ b/js-data/js-data-tests.ts @@ -127,7 +127,7 @@ interface IComment { profile?: any; } -var aComment:JSData_.DSResourceDefinition = store.defineResource('comment'); +var aComment:JSData.DSResourceDefinition = store.defineResource('comment'); // Get all comments where comment.userId == 5 aComment.filter({ @@ -276,7 +276,7 @@ interface IPost { } -var Post:JSData_.DSResourceDefinition; +var Post:JSData.DSResourceDefinition; // Grab the first "page" of posts Post.filter({ @@ -426,7 +426,7 @@ User.create({name: 'John'}, { module CustomAdapterTest { - class MyCustomAdapter implements JSData_.IDSAdapter { + class MyCustomAdapter implements JSData.IDSAdapter { // All of the methods shown here must return a promise @@ -437,52 +437,52 @@ module CustomAdapterTest { // was passed into the DS method that is calling // the adapter method - create(definition:JSData_.DSResourceDefinition, attrs:Object, options:JSData_.DSConfiguration):JSData_.JSDataPromise { + create(definition:JSData.DSResourceDefinition, attrs:Object, options:JSData.DSConfiguration):JSData.JSDataPromise { // Must resolve the promise with the created item - var promise:JSData_.JSDataPromise; + var promise:JSData.JSDataPromise; return promise; } - find(definition:JSData_.DSResourceDefinition, id:any, options:JSData_.DSConfiguration):JSData_.JSDataPromise { + find(definition:JSData.DSResourceDefinition, id:any, options:JSData.DSConfiguration):JSData.JSDataPromise { // Must resolve the promise with the found item - var promise:JSData_.JSDataPromise; + var promise:JSData.JSDataPromise; return promise; } - findAll(definition:JSData_.DSResourceDefinition, params:JSData_.DSFilterParams, options:JSData_.DSConfiguration):JSData_.JSDataPromise { + findAll(definition:JSData.DSResourceDefinition, params:JSData.DSFilterParams, options:JSData.DSConfiguration):JSData.JSDataPromise { // Must resolve the promise with the found items - var promise:JSData_.JSDataPromise; + var promise:JSData.JSDataPromise; return promise; } - update(definition:JSData_.DSResourceDefinition, id:any, attrs:Object, options:JSData_.DSConfiguration):JSData_.JSDataPromise { + update(definition:JSData.DSResourceDefinition, id:any, attrs:Object, options:JSData.DSConfiguration):JSData.JSDataPromise { // Must resolve the promise with the updated items - var promise:JSData_.JSDataPromise; + var promise:JSData.JSDataPromise; return promise; } - updateAll(definition:JSData_.DSResourceDefinition, attrs:Object, params:JSData_.DSFilterParams, options:JSData_.DSConfiguration):JSData_.JSDataPromise { + updateAll(definition:JSData.DSResourceDefinition, attrs:Object, params:JSData.DSFilterParams, options:JSData.DSConfiguration):JSData.JSDataPromise { // Must resolve the promise with the updated items - var promise:JSData_.JSDataPromise; + var promise:JSData.JSDataPromise; return promise; } - destroy(definition:JSData_.DSResourceDefinition, id:any, options:JSData_.DSConfiguration):JSData_.JSDataPromise { + destroy(definition:JSData.DSResourceDefinition, id:any, options:JSData.DSConfiguration):JSData.JSDataPromise { // Must return a promise - var promise:JSData_.JSDataPromise; + var promise:JSData.JSDataPromise; return promise; } - destroyAll(definition:JSData_.DSResourceDefinition, params:JSData_.DSFilterParams, options:JSData_.DSConfiguration):JSData_.JSDataPromise { + destroyAll(definition:JSData.DSResourceDefinition, params:JSData.DSFilterParams, options:JSData.DSConfiguration):JSData.JSDataPromise { // Must return a promise - var promise:JSData_.JSDataPromise; + var promise:JSData.JSDataPromise; return promise; } } @@ -500,14 +500,14 @@ module CustomAdapterTest { interface MyCustomDataStore { - myResource: JSData_.DSResourceDefinition + myResource: JSData.DSResourceDefinition } interface MyResourceDefinition { } -module JSData_ { +module JSData { interface DS { diff --git a/js-data/js-data.d.ts b/js-data/js-data.d.ts index b7271c4e2..cf74b6b79 100644 --- a/js-data/js-data.d.ts +++ b/js-data/js-data.d.ts @@ -14,7 +14,7 @@ /////////////////////////////////////////////////////////////////////////////// // defining what exists in JSData and how it looks -declare module JSData_ { +declare module JSData { interface JSDataPromise extends Promise { @@ -398,8 +398,8 @@ declare module JSData_ { // declaring the existing global js object declare var JSData:{ - DS: JSData_.DS; - DSErrors: JSData_.DSErrors; + DS: JSData.DS; + DSErrors: JSData.DSErrors; }; //Support node require From 369935805c148d1d640fc483d41bed0fb2e38dee Mon Sep 17 00:00:00 2001 From: Rogier Schouten Date: Wed, 4 Mar 2015 13:57:57 +0100 Subject: [PATCH 163/185] Add http.Agent to node.js typings --- node/node-0.10.d.ts | 37 ++++++++++++++++++++++++++++++++++++- node/node-tests.ts | 9 +++++++++ node/node.d.ts | 37 ++++++++++++++++++++++++++++++++++++- 3 files changed, 81 insertions(+), 2 deletions(-) diff --git a/node/node-0.10.d.ts b/node/node-0.10.d.ts index 99ab5eccd..28f0a3bc5 100644 --- a/node/node-0.10.d.ts +++ b/node/node-0.10.d.ts @@ -349,7 +349,42 @@ declare module "http" { pause(): void; resume(): void; } - export interface Agent { maxSockets: number; sockets: any; requests: any; } + + export interface AgentOptions { + /** + * Keep sockets around in a pool to be used by other requests in the future. Default = false + */ + keepAlive?: boolean; + /** + * When using HTTP KeepAlive, how often to send TCP KeepAlive packets over sockets being kept alive. Default = 1000. + * Only relevant if keepAlive is set to true. + */ + keepAliveMsecs?: number; + /** + * Maximum number of sockets to allow per host. Default for Node 0.10 is 5, default for Node 0.12 is Infinity + */ + maxSockets?: number; + /** + * Maximum number of sockets to leave open in a free state. Only relevant if keepAlive is set to true. Default = 256. + */ + maxFreeSockets?: number; + } + + export class Agent { + maxSockets: number; + sockets: any; + requests: any; + + constructor(opts?: AgentOptions); + + /** + * Destroy any sockets that are currently in use by the agent. + * It is usually not necessary to do this. However, if you are using an agent with KeepAlive enabled, + * then it is best to explicitly shut down the agent when you know that it will no longer be used. Otherwise, + * sockets may hang open for quite a long time before the server terminates them. + */ + destroy(): void; + } export var STATUS_CODES: { [errorCode: number]: string; diff --git a/node/node-tests.ts b/node/node-tests.ts index f2702ec4a..b50e01f27 100644 --- a/node/node-tests.ts +++ b/node/node-tests.ts @@ -154,6 +154,15 @@ module http_tests { var code = 100; var codeMessage = http.STATUS_CODES['400']; var codeMessage = http.STATUS_CODES[400]; + + var agent: http.Agent = new http.Agent({ + keepAlive: true, + keepAliveMsecs: 10000, + maxSockets: Infinity, + maxFreeSockets: 256 + }); + + var agent: http.Agent = http.globalAgent; } //////////////////////////////////////////////////// diff --git a/node/node.d.ts b/node/node.d.ts index deae056a1..222963715 100644 --- a/node/node.d.ts +++ b/node/node.d.ts @@ -349,7 +349,42 @@ declare module "http" { pause(): void; resume(): void; } - export interface Agent { maxSockets: number; sockets: any; requests: any; } + + export interface AgentOptions { + /** + * Keep sockets around in a pool to be used by other requests in the future. Default = false + */ + keepAlive?: boolean; + /** + * When using HTTP KeepAlive, how often to send TCP KeepAlive packets over sockets being kept alive. Default = 1000. + * Only relevant if keepAlive is set to true. + */ + keepAliveMsecs?: number; + /** + * Maximum number of sockets to allow per host. Default for Node 0.10 is 5, default for Node 0.12 is Infinity + */ + maxSockets?: number; + /** + * Maximum number of sockets to leave open in a free state. Only relevant if keepAlive is set to true. Default = 256. + */ + maxFreeSockets?: number; + } + + export class Agent { + maxSockets: number; + sockets: any; + requests: any; + + constructor(opts?: AgentOptions); + + /** + * Destroy any sockets that are currently in use by the agent. + * It is usually not necessary to do this. However, if you are using an agent with KeepAlive enabled, + * then it is best to explicitly shut down the agent when you know that it will no longer be used. Otherwise, + * sockets may hang open for quite a long time before the server terminates them. + */ + destroy(): void; + } export var STATUS_CODES: { [errorCode: number]: string; From ea43bdc3d3be5eef770a30bcc5575c5dbdd157f8 Mon Sep 17 00:00:00 2001 From: Wim Looman Date: Thu, 5 Mar 2015 11:28:00 +1300 Subject: [PATCH 164/185] Add more overloads of knockout-transformations map Not yet documented (see One-com/knockout-transformations#5), derived by studying the code (https://github.com/One-com/knockout-transformations/blob/master/lib/map.js) --- .../knockout-transformations-tests.ts | 43 +++++++++++++++++++ .../knockout-transformations.d.ts | 21 ++++++++- 2 files changed, 63 insertions(+), 1 deletion(-) diff --git a/knockout-transformations/knockout-transformations-tests.ts b/knockout-transformations/knockout-transformations-tests.ts index 6b15b3ca0..5f132858c 100644 --- a/knockout-transformations/knockout-transformations-tests.ts +++ b/knockout-transformations/knockout-transformations-tests.ts @@ -161,3 +161,46 @@ var indexedTexts: KnockoutObservable<{ [suffixOrPrefix: string]: string[] }> = t // z: ['baz'], // x: ['qux', 'quux'] // } + + +(() => { + var sourceItems: KnockoutObservableArray = ko.observableArray([1, 2, 3, 4, 5]); + var asString: KnockoutObservableArray; + + asString = sourceItems.map((x: number) => x.toString()); + + asString = sourceItems.map({ + mapping: (x: number) => x.toString(), + }); + + asString = sourceItems.map({ + mapping: (x: number) => x.toString(), + disposeItem: (x: string) => console.log('disposing map to', x), + }); + + asString = sourceItems.map({ + mappingWithDisposeCallback: (x: number) => ({ + mappedValue: x.toString(), + dispose: () => console.log('disposing map from', x), + }), + }); + + asString = sourceItems.map(x => x.toString()); + + asString = sourceItems.map({ + mapping: x => x.toString(), + }); + + asString = sourceItems.map({ + mapping: x => x.toString(), + disposeItem: x => console.log('disposing map to', x), + }); + + asString = sourceItems.map({ + mappingWithDisposeCallback: x => ({ + mappedValue: x.toString(), + dispose: () => console.log('disposing map from', x), + }), + }); + +}); diff --git a/knockout-transformations/knockout-transformations.d.ts b/knockout-transformations/knockout-transformations.d.ts index b599c7d69..3048e7a0f 100644 --- a/knockout-transformations/knockout-transformations.d.ts +++ b/knockout-transformations/knockout-transformations.d.ts @@ -5,8 +5,27 @@ /// +declare module KnockoutTransformations { + interface Mapping { + (value: T): TResult; + } + interface MappingOption { + mapping: Mapping; + disposeItem?: (item: TResult) => void; + } + interface MappingWithDisposeCallbackOption { + mappingWithDisposeCallback: (value: T) => { + mappedValue: TResult; + dispose: () => void; + }; + } +} + interface KnockoutObservableArrayFunctions { - map(mapping: (value: T) => TResult): KnockoutObservableArray; + map(mapping: KnockoutTransformations.Mapping): KnockoutObservableArray; + map(mapping: KnockoutTransformations.MappingOption): KnockoutObservableArray; + map(mapping: KnockoutTransformations.MappingWithDisposeCallbackOption): KnockoutObservableArray; + filter(predicate: (value: T) => boolean): KnockoutObservableArray; sortBy(sorter: (value: T, descending: (sorter: any) => any) => any): KnockoutObservableArray; indexBy(indexer: (value: T) => string): KnockoutObservable<{ [index: string]: T[] }>; From 68ae7bb60d3c1ef6dc1c458ffa0bcfda8d50240c Mon Sep 17 00:00:00 2001 From: Adi Dahiya Date: Wed, 4 Mar 2015 20:56:23 -0500 Subject: [PATCH 165/185] Add tether typings --- tether/tether-tests.ts | 53 ++++++++++++++++++++++++++++++++++++++++++ tether/tether.d.ts | 50 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 103 insertions(+) create mode 100644 tether/tether-tests.ts create mode 100644 tether/tether.d.ts diff --git a/tether/tether-tests.ts b/tether/tether-tests.ts new file mode 100644 index 000000000..4d3295b50 --- /dev/null +++ b/tether/tether-tests.ts @@ -0,0 +1,53 @@ +/// +/// + +var yellowBox = document.querySelector(".yellow"); +var greenBox = document.querySelector(".green"); + +new Tether({ + attachment: "bottom middle", + targetAttachment: "top middle", + targetModifier: "visible", + offset: "-15px 0", + targetOffset: "0 0" +}); + +new Tether({ + element: yellowBox, + target: greenBox, + attachment: "top left", + optimizations: { + gpu: false + } +}); + +new Tether({ + element: yellowBox, + target: greenBox, + attachment: "top left", + targetAttachment: "bottom left", + constraints: [ + { + to: "scrollParent", + pin: true + }, + { + to: "window", + attachment: "together" + } + ] +}); + +new Tether({ + element: yellowBox, + target: greenBox, + attachment: "middle left", + targetAttachment: "middle left", + constraints: [ + { + to: "scrollParent", + pin: ["top"] + } + ] +}); + diff --git a/tether/tether.d.ts b/tether/tether.d.ts new file mode 100644 index 000000000..be1200f28 --- /dev/null +++ b/tether/tether.d.ts @@ -0,0 +1,50 @@ +// Type definitions for Tether v0.6 +// Project: http://github.hubspot.com/tether/ +// Definitions by: Adi Dahiya +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module tether { + + interface TetherStatic { + new(options: ITetherOptions): Tether; + } + + interface ITetherOptions { + attachment?: string; + classes?: {[className: string]: boolean}; + classPrefix?: string; + constraints?: ITetherConstraint[]; + element?: Element | string | any /* JQuery */; + enabled?: boolean; + offset?: string; + optimizations?: any; + target?: Element | string | any /* JQuery */; + targetAttachment?: string; + targetOffset?: string; + targetModifier?: string; + } + + interface ITetherConstraint { + attachment?: string; + outOfBoundsClass?: string; + pin?: boolean | string[]; + pinnedClass?: string; + to?: string | Element | number[]; + } + + interface Tether { + setOptions(options: ITetherOptions): void; + disable(): void; + enable(): void; + destroy(): void; + position(): void; + } + +} + +declare module "tether" { + export = tether; +} + +declare var Tether: tether.TetherStatic; + From d8ea3e37f7ab9263a5cae5ac693658052aca5cdc Mon Sep 17 00:00:00 2001 From: Adi Dahiya Date: Wed, 4 Mar 2015 21:00:31 -0500 Subject: [PATCH 166/185] Add drop typings --- drop/drop-tests.ts | 28 +++++++++++++++++++++++++++ drop/drop.d.ts | 48 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 drop/drop-tests.ts create mode 100644 drop/drop.d.ts diff --git a/drop/drop-tests.ts b/drop/drop-tests.ts new file mode 100644 index 000000000..b5ae47456 --- /dev/null +++ b/drop/drop-tests.ts @@ -0,0 +1,28 @@ +/// +/// + +var yellowBox = document.querySelector(".yellow"); +var greenBox = document.querySelector(".green"); + +var d = new Drop({ + position: "bottom left", + openOn: "click", + constrainToWindow: true, + constrainToScrollParent: true, + classes: "", + tetherOptions: {} +}); + +d.open(); +d.close(); +d.remove(); +d.toggle(); +d.position(); +d.destroy(); + +d.on("open", () => null); +d.on("close", () => null); +d.once("close", () => null); +d.off("close", () => null); +d.off("open"); + diff --git a/drop/drop.d.ts b/drop/drop.d.ts new file mode 100644 index 000000000..18568afdd --- /dev/null +++ b/drop/drop.d.ts @@ -0,0 +1,48 @@ +// Type definitions for Drop v0.5 +// Project: http://github.hubspot.com/drop/ +// Definitions by: Adi Dahiya +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module drop { + + interface DropStatic { + new(options: IDropOptions): Drop; + } + + interface IDropOptions { + target?: Element; + content?: Element | string | (() => string); + position?: string; + openOn?: string; + constrainToWindow?: boolean; + constrainToScrollParent?: boolean; + remove?: boolean; + tetherOptions?: tether.ITetherOptions; + } + + interface Drop { + content: HTMLElement; + open(): void; + close(): void; + remove(): void; + toggle(): void; + position(): void; + destroy(): void; + /* + * Drop instances fire "open" and "close" events. + */ + on(event: string, handler: Function, context?: any): void; + once(event: string, handler: Function, context?: any): void; + off(event: string, handler?: Function): void; + } + +} + +declare module "drop" { + export = drop; +} + +declare var Drop: drop.DropStatic; + From a6cbfba663b3ec69923b7cf85cef84ad27e640b0 Mon Sep 17 00:00:00 2001 From: reppners Date: Thu, 5 Mar 2015 08:42:15 +0100 Subject: [PATCH 167/185] + changed promise declaration to own custom since it is not possible to reuse ES6 polyfill promise class declaration --- js-data-http/js-data-http.d.ts | 10 +++++----- js-data/js-data-tests.ts | 4 +++- js-data/js-data.d.ts | 14 ++++++-------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/js-data-http/js-data-http.d.ts b/js-data-http/js-data-http.d.ts index 626f55648..416aa3c8c 100644 --- a/js-data-http/js-data-http.d.ts +++ b/js-data-http/js-data-http.d.ts @@ -35,11 +35,11 @@ declare module JSData { new(options?:DSHttpAdapterOptions):DSHttpAdapter; // DSHttpAdapter uses axios so options are axios config objects. - HTTP(options?:Object):Promise; - DEL(url:string, data?:Object, options?:Object):Promise; - GET(url:string, data?:Object, options?:Object):Promise; - POST(url:string, data?:Object, options?:Object):Promise; - PUT(url:string, data?:Object, options?:Object):Promise; + HTTP(options?:Object):JSDataPromise; + DEL(url:string, data?:Object, options?:Object):JSDataPromise; + GET(url:string, data?:Object, options?:Object):JSDataPromise; + POST(url:string, data?:Object, options?:Object):JSDataPromise; + PUT(url:string, data?:Object, options?:Object):JSDataPromise; } } diff --git a/js-data/js-data-tests.ts b/js-data/js-data-tests.ts index 35fdbf00f..c6fe6d13b 100644 --- a/js-data/js-data-tests.ts +++ b/js-data/js-data-tests.ts @@ -387,7 +387,9 @@ OtherOtherComment.find(5, {params: {postId: 4}}); // GET /post/4/comment/5 // vs -OtherOtherComment.find(5); // GET /comment/5 +var promise = OtherOtherComment.find(5); // GET /comment/5 + +promise.then().catch().finally(); OtherOtherComment.inject({id: 1, postId: 2}); diff --git a/js-data/js-data.d.ts b/js-data/js-data.d.ts index cf74b6b79..7017481ee 100644 --- a/js-data/js-data.d.ts +++ b/js-data/js-data.d.ts @@ -3,12 +3,6 @@ // Definitions by: Stefan Steinhart // Definitions: https://github.com/borisyankov/DefinitelyTyped -/////////////////////////////////////////////////////////////////////////////// -// Promises in js-data are ES6 polyfill promises -/////////////////////////////////////////////////////////////////////////////// - -/// - /////////////////////////////////////////////////////////////////////////////// // js-data module (js-data.js) /////////////////////////////////////////////////////////////////////////////// @@ -16,10 +10,14 @@ // defining what exists in JSData and how it looks declare module JSData { - interface JSDataPromise extends Promise { + interface JSDataPromise { + + then(onFulfilled?: (value: R) => U | JSDataPromise, onRejected?: (error: any) => U | JSDataPromise): JSDataPromise; + + catch(onRejected?: (error: any) => U | JSDataPromise): JSDataPromise; // enhanced with finally - finally(finallyCb?:() => U):Promise; + finally(finallyCb?:() => U):JSDataPromise; } //TODO switch to class again when typescript supports open ended class declaration From ae81e340a9e897167cfef3122a5a3aed04293814 Mon Sep 17 00:00:00 2001 From: reppners Date: Thu, 5 Mar 2015 08:50:54 +0100 Subject: [PATCH 168/185] + chokidar type defs including tests --- chokidar/chokidar-tests.ts | 41 +++++++++++++++++++++++++++++++++++++ chokidar/chokidar.d.ts | 42 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+) create mode 100644 chokidar/chokidar-tests.ts create mode 100644 chokidar/chokidar.d.ts diff --git a/chokidar/chokidar-tests.ts b/chokidar/chokidar-tests.ts new file mode 100644 index 000000000..b89dd81a0 --- /dev/null +++ b/chokidar/chokidar-tests.ts @@ -0,0 +1,41 @@ +/// + +import fs = require('fs'); +import chokidar = require('chokidar'); + +var watcher = chokidar.watch('file, dir, or glob', { + ignored: /[\/\\]\./, persistent: true +}); + +var log = console.log.bind(console); + +watcher + .on('add', function(path:string) { log('File', path, 'has been added'); }) + .on('addDir', function(path:string) { log('Directory', path, 'has been added'); }) + .on('change', function(path:string) { log('File', path, 'has been changed'); }) + .on('unlink', function(path:string) { log('File', path, 'has been removed'); }) + .on('unlinkDir', function(path:string) { log('Directory', path, 'has been removed'); }) + .on('error', function(error:any) { log('Error happened', error); }) + .on('ready', function() { log('Initial scan complete. Ready for changes.'); }) + .on('raw', function(event:Event, path:string, details:any) { log('Raw event info:', event, path, details); }) + +// 'add', 'addDir' and 'change' events also receive stat() results as second +// argument when available: http://nodejs.org/api/fs.html#fs_class_fs_stats +watcher.on('change', function(path:string, stats:fs.Stats) { + if (stats) console.log('File', path, 'changed size to', stats.size); +}); + +// Watch new files. +watcher.add('new-file'); +watcher.add(['new-file-2', 'new-file-3', '**/other-file*']); + +// Un-watch some files. +watcher.unwatch('new-file*'); + +// Only needed if watching is `persistent: true`. +watcher.close(); + +// One-liner +require('chokidar').watch('.', {ignored: /[\/\\]\./}).on('all', function(event:string, path:string) { + console.log(event, path); +}); \ No newline at end of file diff --git a/chokidar/chokidar.d.ts b/chokidar/chokidar.d.ts new file mode 100644 index 000000000..6a417ca72 --- /dev/null +++ b/chokidar/chokidar.d.ts @@ -0,0 +1,42 @@ +// Type definitions for chokidar 1.0.0 +// Project: https://github.com/paulmillr/chokidar +// Definitions by: Stefan Steinhart +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module "fs" +{ + interface FSWatcher + { + add(fileDirOrGlob:string):void; + add(filesDirsOrGlobs:Array):void; + unwatch(fileDirOrGlob:string):void; + unwatch(filesDirsOrGlobs:Array):void; + } +} + +declare module "chokidar" +{ + interface WatchOptions + { + persistent?:boolean; + ignored?:any; + ignoreInitial?:boolean; + followSymlinks?:boolean; + cwd?:string; + usePolling?:boolean; + useFsEvents?:boolean; + alwaysStat?:boolean; + depth?:number; + interval?:number; + binaryInterval?:number; + ignorePermissionErrors?:boolean; + atomic?:boolean; + } + + import fs = require("fs"); + + function watch( fileDirOrGlob:string, options?:WatchOptions ):fs.FSWatcher; + function watch( filesDirsOrGlobs:Array, options?:WatchOptions ):fs.FSWatcher; +} From c6b6779a46f0246df0f0a9660583c36e4e6e4ac2 Mon Sep 17 00:00:00 2001 From: Gildor Date: Thu, 5 Mar 2015 16:23:51 +0800 Subject: [PATCH 169/185] Fix return type of Selection.classed(string) to boolean --- d3/d3.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/d3/d3.d.ts b/d3/d3.d.ts index 6cc372f7f..a12009bba 100644 --- a/d3/d3.d.ts +++ b/d3/d3.d.ts @@ -728,7 +728,7 @@ declare module D3 { }; classed: { - (name: string): string; + (name: string): boolean; (name: string, value: any): Selection; (name: string, valueFunction: (data: any, index: number) => any): Selection; (classValueMap: Object): Selection; From 6bfdd921c1199e3e2e557d68e036bbe00d1c5523 Mon Sep 17 00:00:00 2001 From: reppners Date: Thu, 5 Mar 2015 11:19:07 +0100 Subject: [PATCH 170/185] + added missing typings to node path module including tests --- node/node-tests.ts | 140 +++++++++++++++++++++++++++++++++++++++++++++ node/node.d.ts | 13 +++++ 2 files changed, 153 insertions(+) diff --git a/node/node-tests.ts b/node/node-tests.ts index f2702ec4a..0ac9a9e8b 100644 --- a/node/node-tests.ts +++ b/node/node-tests.ts @@ -11,6 +11,7 @@ import http = require("http"); import net = require("net"); import dgram = require("dgram"); import querystring = require('querystring'); +import path = require("path"); assert(1 + 1 - 2 === 0, "The universe isn't how it should."); @@ -177,3 +178,142 @@ console.log(escaped); var unescaped: string = querystring.unescape(escaped); console.log(unescaped); // http://example.com/product/abcde.html + +//////////////////////////////////////////////////// +/// path tests : http://nodejs.org/api/path.html +//////////////////////////////////////////////////// + +module path_tests { + + path.normalize('/foo/bar//baz/asdf/quux/..'); + + path.join('/foo', 'bar', 'baz/asdf', 'quux', '..'); + // returns + //'/foo/bar/baz/asdf' + + try { + path.join('foo', {}, 'bar'); + } + catch(error) { + + } + + path.resolve('foo/bar', '/tmp/file/', '..', 'a/../subfile'); + //Is similar to: + // + //cd foo/bar + //cd /tmp/file/ + //cd .. + // cd a/../subfile + //pwd + + path.resolve('/foo/bar', './baz') + // returns + // '/foo/bar/baz' + + path.resolve('/foo/bar', '/tmp/file/') + // returns + // '/tmp/file' + + path.resolve('wwwroot', 'static_files/png/', '../gif/image.gif') + // if currently in /home/myself/node, it returns + // '/home/myself/node/wwwroot/static_files/gif/image.gif' + + path.isAbsolute('/foo/bar') // true + path.isAbsolute('/baz/..') // true + path.isAbsolute('qux/') // false + path.isAbsolute('.') // false + + path.isAbsolute('//server') // true + path.isAbsolute('C:/foo/..') // true + path.isAbsolute('bar\\baz') // false + path.isAbsolute('.') // false + + path.relative('C:\\orandea\\test\\aaa', 'C:\\orandea\\impl\\bbb') +// returns +// '..\\..\\impl\\bbb' + + path.relative('/data/orandea/test/aaa', '/data/orandea/impl/bbb') +// returns +// '../../impl/bbb' + + path.dirname('/foo/bar/baz/asdf/quux') +// returns +// '/foo/bar/baz/asdf' + + path.basename('/foo/bar/baz/asdf/quux.html') +// returns +// 'quux.html' + + path.basename('/foo/bar/baz/asdf/quux.html', '.html') +// returns +// 'quux' + + path.extname('index.html') +// returns +// '.html' + + path.extname('index.coffee.md') +// returns +// '.md' + + path.extname('index.') +// returns +// '.' + + path.extname('index') +// returns +// '' + + 'foo/bar/baz'.split(path.sep) +// returns +// ['foo', 'bar', 'baz'] + + 'foo\\bar\\baz'.split(path.sep) +// returns +// ['foo', 'bar', 'baz'] + + console.log(process.env.PATH) +// '/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin' + + process.env.PATH.split(path.delimiter) +// returns +// ['/usr/bin', '/bin', '/usr/sbin', '/sbin', '/usr/local/bin'] + + console.log(process.env.PATH) +// 'C:\Windows\system32;C:\Windows;C:\Program Files\nodejs\' + + process.env.PATH.split(path.delimiter) +// returns +// ['C:\Windows\system32', 'C:\Windows', 'C:\Program Files\nodejs\'] + + path.parse('/home/user/dir/file.txt') +// returns +// { +// root : "/", +// dir : "/home/user/dir", +// base : "file.txt", +// ext : ".txt", +// name : "file" +// } + + path.parse('C:\\path\\dir\\index.html') +// returns +// { +// root : "C:\", +// dir : "C:\path\dir", +// base : "index.html", +// ext : ".html", +// name : "index" +// } + + path.format({ + root : "/", + dir : "/home/user/dir", + base : "file.txt", + ext : ".txt", + name : "file" + }); +// returns +// '/home/user/dir/file.txt' +} diff --git a/node/node.d.ts b/node/node.d.ts index b1e849535..22fb332e8 100644 --- a/node/node.d.ts +++ b/node/node.d.ts @@ -953,14 +953,27 @@ declare module "fs" { } declare module "path" { + + export interface ParsedPath { + root: string; + dir: string; + base: string; + ext: string; + name: string; + } + export function normalize(p: string): string; export function join(...paths: any[]): string; export function resolve(...pathSegments: any[]): string; + export function isAbsolute(p: string): boolean; export function relative(from: string, to: string): string; export function dirname(p: string): string; export function basename(p: string, ext?: string): string; export function extname(p: string): string; export var sep: string; + export var delimiter: string; + export function parse(p: string): ParsedPath; + export function format(pP: ParsedPath): string; } declare module "string_decoder" { From 235f7734ece03d8b499928e8f367fa9e3726f3e4 Mon Sep 17 00:00:00 2001 From: Schnell Henrik Date: Thu, 5 Mar 2015 11:22:09 +0100 Subject: [PATCH 171/185] Fixed link definition on IDirective with union type IDirectiveLinkFn | IDirectivePrePost. --- angularjs/angular.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts index 2f88253f0..639f0b1e8 100755 --- a/angularjs/angular.d.ts +++ b/angularjs/angular.d.ts @@ -1448,7 +1448,7 @@ declare module ng { controller?: any; controllerAs?: string; bindToController?: boolean; - link?: IDirectiveLinkFn; + link?: IDirectiveLinkFn | IDirectivePrePost; name?: string; priority?: number; replace?: boolean; From 69bdfb0884020e41f17a1dd80ad4c77de2636874 Mon Sep 17 00:00:00 2001 From: vvakame Date: Thu, 5 Mar 2015 23:21:03 +0900 Subject: [PATCH 172/185] update CONTRIBUTORS.md --- CONTRIBUTORS.md | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index eb11f9f2a..88905c88a 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -86,6 +86,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](buffer-equal/buffer-equal.d.ts) [buffer-equal](https://github.com/substack/node-buffer-equal) by [Bart van der Schoor](https://github.com/Bartvds) * [:link:](bl/bl.d.ts) [BufferList](https://github.com/rvagg/bl) by [Bart van der Schoor](https://github.com/Bartvds) * [:link:](bufferstream/bufferstream.d.ts) [bufferstream](https://github.com/dodo/node-bufferstream) by [Bart van der Schoor](https://github.com/Bartvds) +* [:link:](bunyan-prettystream/bunyan-prettystream.d.ts) [bunyan-prettystream](https://www.npmjs.com/package/bunyan-prettystream) by [Jason Swearingen](https://github.com/jasonswearingen) * [:link:](business-rules-engine/business-rules-engine.d.ts) [business-rules-engine](https://github.com/rsamec/form) by [Roman Samec](https://github.com/rsamec) * [:link:](byline/byline.d.ts) [byline](https://github.com/jahewson/node-byline) by [Stefan Steinhart](https://github.com/reppners) * [:link:](camljs/camljs.d.ts) [camljs](http://camljs.codeplex.com) by [Andrey Markeev](http://markeev.com) @@ -103,6 +104,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](chartjs/chart.d.ts) [Chart.js](https://github.com/nnnick/Chart.js) by [Steve Fenton](https://github.com/Steve-Fenton) * [:link:](checksum/checksum.d.ts) [checksum](https://github.com/dshaw/checksum) by [Rogier Schouten](https://github.com/rogierschouten) * [:link:](cheerio/cheerio.d.ts) [Cheerio](https://github.com/cheeriojs/cheerio) by [Bret Little](https://github.com/blittle), [VILIC VANE](http://vilic.info), [Wayne Maurer](https://github.com/wmaurer) +* [:link:](chokidar/chokidar.d.ts) [chokidar](https://github.com/paulmillr/chokidar) by [Stefan Steinhart](https://github.com/reppners) * [:link:](chosen/chosen.jquery.d.ts) [Chosen.JQuery](http://harvesthq.github.com/chosen) by [Boris Yankov](https://github.com/borisyankov) * [:link:](chroma-js/chroma-js.d.ts) [Chroma.js](https://github.com/gka/chroma.js) by [Sebastian Brückner](https://github.com/invliD) * [:link:](chrome/chrome.d.ts) [Chrome extension development](http://developer.chrome.com/extensions) by [Matthew Kimber](https://github.com/matthewkimber), [otiai10](https://github.com/otiai10) @@ -159,6 +161,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](dot/dot.d.ts) [doT](https://github.com/olado/doT) by [ZombieHunter](https://github.com/ZombieHunter) * [:link:](dotdotdot/dotdotdot.d.ts) [dotdotdot](http://dotdotdot.frebsite.nl) by [Milan Jaros](https://github.com/milanjaros) * [:link:](doublearray/doublearray.d.ts) [doublearray](https://github.com/takuyaa/doublearray) by [MIZUSHIMA Junki](https://github.com/mzsm) +* [:link:](drop/drop.d.ts) [Drop](http://github.hubspot.com/drop) by [Adi Dahiya](https://github.com/adidahiya) * [:link:](dropboxjs/dropboxjs.d.ts) [dropbox-js](https://github.com/dropbox/dropbox-js) by [Steve Fenton](https://github.com/Steve-Fenton), [Pedro Casaubon](https://github.com/xperiments) * [:link:](dropzone/dropzone.d.ts) [Dropzone](http://www.dropzonejs.com) by [Natan Vivo](https://github.com/nvivo) * [:link:](dts-bundle/dts-bundle.d.ts) [dts-bundle](https://github.com/TypeStrong/dts-bundle) by [Asana](https://asana.com) @@ -254,19 +257,25 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](greensock/greensock.d.ts) [GreenSock Animation Platform](http://www.greensock.com/get-started-js) by [Robert S](https://github.com/codebelt) * [:link:](gridfs-stream/gridfs-stream.d.ts) [gridfs-stream](https://github.com/aheckmann/gridfs-stream) by [Lior Mualem](https://github.com/liorm) * [:link:](gruntjs/gruntjs.d.ts) [Grunt 0.4.x](http://gruntjs.com) by [Jeff May](https://github.com/jeffmay), [Basarat Ali Syed](https://github.com/basarat) -* [:link:](gsap/TweenLite.d.ts) [GSAP](http://greensock.com) by [VILIC VANE](https://vilic.github.io) -* [:link:](gsap/Core.d.ts) [GSAP](http://greensock.com) by [VILIC VANE](https://vilic.github.io) * [:link:](gsap/Ease.d.ts) [GSAP](http://greensock.com) by [VILIC VANE](https://vilic.github.io) +* [:link:](gsap/Core.d.ts) [GSAP](http://greensock.com) by [VILIC VANE](https://vilic.github.io) +* [:link:](gsap/TweenLite.d.ts) [GSAP](http://greensock.com) by [VILIC VANE](https://vilic.github.io) * [:link:](gulp/gulp.d.ts) [Gulp v3.8.x](http://gulpjs.com) by [Drew Noakes](https://drewnoakes.com) * [:link:](gulp-autoprefixer/gulp-autoprefixer.d.ts) [gulp-autoprefixer](https://github.com/sindresorhus/gulp-autoprefixer) by [Asana](https://asana.com) +* [:link:](gulp-concat/gulp-concat.d.ts) [gulp-concat](http://github.com/wearefractal/gulp-concat) by [Keita Kagurazaka](https://github.com/k-kagurazaka) +* [:link:](gulp-flatten/gulp-flatten.d.ts) [gulp-flatten](https://github.com/armed/gulp-flatten) by [Keita Kagurazaka](https://github.com/k-kagurazaka) * [:link:](gulp-gh-pages/gulp-gh-pages.d.ts) [gulp-gh-pages](https://github.com/rowoot/gulp-gh-pages) by [Asana](https://asana.com) * [:link:](gulp-if/gulp-if.d.ts) [gulp-if](https://github.com/robrich/gulp-if) by [Asana](https://asana.com) +* [:link:](gulp-inject/gulp-inject.d.ts) [gulp-inject](https://github.com/klei/gulp-inject) by [Keita Kagurazaka](https://github.com/k-kagurazaka) * [:link:](gulp-istanbul/gulp-istanbul.d.ts) [gulp-istanbul](https://github.com/SBoudrias/gulp-istanbul) by [Asana](https://asana.com) +* [:link:](gulp-less/gulp-less.d.ts) [gulp-less](https://github.com/plus3network/gulp-less) by [Keita Kagurazaka](https://github.com/k-kagurazaka) +* [:link:](gulp-minify-css/gulp-minify-css.d.ts) [gulp-minify-css](https://github.com/jonathanepollack/gulp-minify-css) by [Keita Kagurazaka](https://github.com/k-kagurazaka) * [:link:](gulp-mocha/gulp-mocha.d.ts) [gulp-mocha](https://github.com/sindresorhus/gulp-mocha) by [Asana](https://asana.com) * [:link:](gulp-rename/gulp-rename.d.ts) [gulp-rename](https://github.com/hparra/gulp-rename) by [Asana](https://asana.com) * [:link:](gulp-replace/gulp-replace.d.ts) [gulp-replace](https://github.com/lazd/gulp-replace) by [Asana](https://asana.com) * [:link:](gulp-sass/gulp-sass.d.ts) [gulp-sass](https://github.com/dlmanning/gulp-sass) by [Asana](https://asana.com) * [:link:](gulp-sourcemaps/gulp-sourcemaps.d.ts) [gulp-sourcemaps](https://github.com/floridoo/gulp-sourcemaps) by [Asana](https://asana.com) +* [:link:](gulp-tsd/gulp-tsd.d.ts) [gulp-tsd](https://github.com/moznion/gulp-tsd) by [Keita Kagurazaka](https://github.com/k-kagurazaka) * [:link:](gulp-tslint/gulp-tslint.d.ts) [gulp-tslint](https://github.com/panuhorsmalahti/gulp-tslint) by [Asana](https://asana.com) * [:link:](gulp-typedoc/gulp-typedoc.d.ts) [gulp-typedoc](https://github.com/rogierschouten/gulp-typedoc) by [Asana](https://asana.com) * [:link:](gulp-typescript/gulp-typescript.d.ts) [gulp-typescript](https://github.com/ivogabe/gulp-typescript) by [Asana](https://asana.com) @@ -321,7 +330,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](jjv/jjv.d.ts) [JJV](https://github.com/acornejo/jjv) by [Wim Looman](https://github.com/Nemo157) * [:link:](jjve/jjve.d.ts) [JJVE](https://github.com/silas/jjve) by [Wim Looman](https://github.com/Nemo157) * [:link:](joi/joi.d.ts) [joi](https://github.com/spumko/joi) by [Bart van der Schoor](https://github.com/Bartvds) -* [:link:](jointjs/jointjs.d.ts) [Joint JS](http://www.jointjs.com) by [Aidan Reel](http://github.com/areel), [David Durman](http://github.com/DavidDurman) +* [:link:](jointjs/jointjs.d.ts) [Joint JS](http://www.jointjs.com) by [Aidan Reel](http://github.com/areel), [David Durman](http://github.com/DavidDurman), [Ewout Van Gossum](https://github.com/DenEwout) * [:link:](jqrangeslider/jqrangeslider.d.ts) [jQRangeSlider](http://ghusse.github.com/jQRangeSlider) by [Dániel Tar](https://github.com/qcz) * [:link:](jquery/jquery.d.ts) [jQuery 1.10.x / 2.0.x](http://jquery.com) by [Boris Yankov](https://github.com/borisyankov), [Christian Hoffmeister](https://github.com/choffmeister), [Steve Fenton](https://github.com/Steve-Fenton), [Diullei Gomes](https://github.com/Diullei), [Tass Iliopoulos](https://github.com/tasoili), [Jason Swearingen](https://github.com/jasons-novaleaf), [Sean Hill](https://github.com/seanski), [Guus Goossens](https://github.com/Guuz), [Kelly Summerlin](https://github.com/ksummerlin), [Basarat Ali Syed](https://github.com/basarat), [Nicholas Wolverson](https://github.com/nwolverson), [Derek Cicerone](https://github.com/derekcicerone), [Andrew Gaspar](https://github.com/AndrewGaspar), [James Harrison Fisher](https://github.com/jameshfisher), [Seikichi Kondo](https://github.com/seikichi), [Benjamin Jackman](https://github.com/benjaminjackman), [Poul Sorensen](https://github.com/s093294), [Josh Strobl](https://github.com/JoshStrobl), [John Reilly](https://github.com/johnnyreilly), [Dick van den Brink](https://github.com/DickvdBrink) * [:link:](jquery.blockUI/jquery.blockUI.d.ts) [jQuery BlockUI Plugin](http://malsup.com/jquery/block) by [Jeffrey Lee](http://blog.darkthread.net) @@ -393,6 +402,9 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](js-yaml/js-yaml.d.ts) [js-yaml](https://github.com/nodeca/js-yaml) by [Bart van der Schoor](https://github.com/Bartvds) * [:link:](jsbn/jsbn.d.ts) [jsbn](http://www-cs-students.stanford.edu/%7Etjw/jsbn) by [Eugene Chernyshov](https://github.com/Evgenus) * [:link:](jscrollpane/jscrollpane.d.ts) [jScrollPane](http://jscrollpane.kelvinluck.com) by [Dániel Tar](https://github.com/qcz) +* [:link:](js-data/js-data.d.ts) [JSData](https://github.com/js-data/js-data) by [Stefan Steinhart](https://github.com/reppners) +* [:link:](js-data-http/js-data-http.d.ts) [JSData Http Adapter](https://github.com/js-data/js-data-http) by [Stefan Steinhart](https://github.com/reppners) +* [:link:](js-data-angular/js-data-angular.d.ts) [JSDataAngular](https://github.com/js-data/js-data-angular) by [Stefan Steinhart](https://github.com/reppners) * [:link:](jsdeferred/jsdeferred.d.ts) [JSDeferred](https://github.com/cho45/jsdeferred) by [Daisuke Mino](https://github.com/minodisk) * [:link:](jsdom/jsdom.d.ts) [jsdom](https://github.com/tmpvar/jsdom) by [Asana](https://asana.com) * [:link:](jsesc/jsesc.d.ts) [jsesc](https://github.com/mathiasbynens/jsesc) by [Bart van der Schoor](https://github.com/Bartvds) @@ -462,6 +474,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](lscache/lscache.d.ts) [lscache](https://github.com/pamelafox/lscache) by [Chris Martinez](https://github.com/Chris-Martinezz) * [:link:](lunr/lunr.d.ts) [lunr.js](https://github.com/olivernn/lunr.js) by [Sebastian Lenz](https://github.com/sebastian-lenz) * [:link:](lz-string/lz-string.d.ts) [lz-string](https://github.com/pieroxy/lz-string) by [Roman Nikitin](https://github.com/M0ns1gn0r) +* [:link:](main-bower-files/main-bower-files.d.ts) [main-bower-files](https://github.com/ck86/main-bower-files) by [Keita Kagurazaka](https://github.com/k-kagurazaka) * [:link:](mapbox/mapbox.d.ts) [Mapbox](https://www.mapbox.com/mapbox.js) by [Maxime Fabre](https://github.com/anahkiasen) * [:link:](mapsjs/mapsjs.d.ts) [Mapsjs](https://github.com/mapsjs) by [Matthew James Davis](https://github.com/davismj) * [:link:](marionette/marionette.d.ts) [Marionette](https://github.com/marionettejs) by [Zeeshan Hamid](https://github.com/zhamid), [Natan Vivo](https://github.com/nvivo), [Sven Tschui](https://github.com/sventschui) @@ -470,6 +483,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](mathjax/mathjax.d.ts) [MathJax](https://github.com/mathjax/MathJax) by [Roland Zwaga](https://github.com/rolandzwaga) * [:link:](mCustomScrollbar/mCustomScrollbar.d.ts) [mCustomScrollbar](https://github.com/malihu/malihu-custom-scrollbar-plugin) by [Sarah Williams](https://github.com/flurg) * [:link:](memory-cache/memory-cache.d.ts) [memory-cache](http://github.com/ptarjan/node-cache) by [Jeff Goddard](https://github.com/jedigo) +* [:link:](merge-stream/merge-stream.d.ts) [merge-stream](https://github.com/grncdr/merge-stream) by [Keita Kagurazaka](https://github.com/k-kagurazaka) * [:link:](mess/mess.d.ts) [mess](https://github.com/bobrik/node-mess) by [Wim Looman](https://github.com/Nemo157) * [:link:](messenger/messenger.d.ts) [Messenger.js](https://github.com/HubSpot/messenger) by [Derek Cicerone](https://github.com/derekcicerone) * [:link:](meteor/meteor.d.ts) [Meteor](http://www.meteor.com) by [Dave Allen](https://github.com/fullflavedave) @@ -521,6 +535,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](needle/needle.d.ts) [needle](https://github.com/tomas/needle) by [San Chen](https://github.com/bigsan) * [:link:](nexpect/nexpect.d.ts) [nexpect](https://github.com/nodejitsu/nexpect) by [vvakame](http://github.com/vvakame) * [:link:](ng-grid/ng-grid.d.ts) [ng-grid](http://angular-ui.github.io/ng-grid) by [Ken Smith](https://github.com/smithkl42), [Roland Zwaga](https://github.com/rolandzwaga), [Kent Cooper](https://github.com/kentcooper) +* [:link:](angular-idle/angular-idle.d.ts) [ng-idle](http://hackedbychinese.github.io/ng-idle) by [mthamil](https://github.com/mthamil) * [:link:](ngprogress/ngprogress.d.ts) [ngProgress](http://victorbjelkholm.github.io/ngProgress) by [Martin McWhorter](https://github.com/martinmcwhorter) * [:link:](ngprogress-lite/ngprogress-lite.d.ts) [ngprogress-lite](https://github.com/voronianski/ngprogress-lite) by [Luke Forder](https://github.com/LukeForder) * [:link:](nightmare/nightmare.d.ts) [Nightmare](https://github.com/segmentio/nightmare) by [horiuchi](https://github.com/horiuchi) @@ -538,6 +553,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](multiparty/multiparty.d.ts) [node-multiparty](https://github.com/andrewrk/node-multiparty) by [Ken Fukuyama](https://github.com/kenfdev) * [:link:](mysql/mysql.d.ts) [node-mysql](https://github.com/felixge/node-mysql) by [William Johnston](https://github.com/wjohnsto) * [:link:](node-persist/node-persist.d.ts) [node-persist](https://github.com/simonlast/node-persist) by [Spencer Williams](http://spencerwi.com) +* [:link:](node-polyglot/node-polyglot.d.ts) [node-polyglot](https://github.com/airbnb/polyglot.js) by [Tim Jackson-Kiely](https://github.com/timjk) * [:link:](promptly/promptly.d.ts) [node-promptly](https://github.com/IndigoUnited/node-promptly) by [Dan Spencer](https://github.com/danrspencer) * [:link:](radius/radius.d.ts) [node-radius](https://github.com/retailnext/node-radius) by [Peter Harris](https://github.com/codeanimal) * [:link:](node-uuid/node-uuid.d.ts) [node-uuid.js](https://github.com/broofa/node-uuid) by [Jeff May](https://github.com/jeffmay) @@ -613,6 +629,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](rabbit.js/rabbit.js.d.ts) [rabbit.js](https://github.com/squaremo/rabbit.js) by [Wonshik Kim](https://github.com/wokim) * [:link:](ractive/ractive.d.ts) [Ractive 0.7.0 edge f22ab8ad0a640591b1c263f57e21d1565cb26bf5](http://ractivejs.org) by [Han Lin Yap](http://yap.nu) * [:link:](raphael/raphael.d.ts) [Raphael](http://raphaeljs.com) by [CheCoxshall](https://github.com/CheCoxshall) +* [:link:](rappid/rappid.d.ts) [Rappid](http://jointjs.com/about-rappid) by [Ewout Van Gossum](https://github.com/DenEwout) * [:link:](ravenjs/ravenjs.d.ts) [Raven.js](https://github.com/getsentry/raven-js) by [Santi Albo](https://github.com/santialbo) * [:link:](react/react.d.ts) [React](http://facebook.github.io/react) by [Asana](https://asana.com) * [:link:](react-router/react-router.d.ts) [React Router](https://github.com/rackt/react-router) by [Yuichi Murata](https://github.com/mrk21) @@ -633,6 +650,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](riotjs/riotjs.d.ts) [riot.js](https://github.com/moot/riotjs) by [vvakame](https://github.com/vvakame) * [:link:](routie/routie.d.ts) [routie](https://github.com/jgallen23/routie) by [Adilson](https://github.com/Adilson) * [:link:](rtree/rtree.d.ts) [rtree](https://github.com/leaflet-extras/RTree) by [Omede Firouz](https://github.com/oefirouz) +* [:link:](run-sequence/run-sequence.d.ts) [run-sequence](https://github.com/OverZealous/run-sequence) by [Keita Kagurazaka](https://github.com/k-kagurazaka) * [:link:](rx/rx.d.ts) [RxJS](http://rx.codeplex.com) by [gsino](http://www.codeplex.com/site/users/view/gsino), [Igor Oleinikov](https://github.com/Igorbek) * [:link:](rx/rx.aggregates.d.ts) [RxJS-Aggregates](http://rx.codeplex.com) by [Carl de Billy](http://carl.debilly.net), [Igor Oleinikov](https://github.com/Igorbek) * [:link:](rx/rx.all.d.ts) [RxJS-All](http://rx.codeplex.com) by [Carl de Billy](http://carl.debilly.net), [Igor Oleinikov](https://github.com/Igorbek) @@ -696,6 +714,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](stats/stats.d.ts) [Stats.js r12](http://github.com/mrdoob/stats.js) by [Gregory Dalton](https://github.com/gregolai) * [:link:](status-bar/status-bar.d.ts) [status-bar](https://github.com/atom/status-bar) by [vvakame](https://github.com/vvakame) * [:link:](storejs/storejs.d.ts) [store.js](https://github.com/marcuswestin/store.js) by [Vincent Bortone](https://github.com/vbortone) +* [:link:](stream-series/stream-series.d.ts) [stream-series](https://github.com/rschmukler/stream-series) by [Keita Kagurazaka](https://github.com/k-kagurazaka) * [:link:](stream-to-array/stream-to-array.d.ts) [stream-to-array](https://github.com/stream-utils/stream-to-array) by [Bart van der Schoor](https://github.com/Bartvds) * [:link:](stripe/stripe.d.ts) [stripe](https://stripe.com) by [Eric J. Smith](https://github.com/ejsmith) * [:link:](stylus/stylus.d.ts) [stylus](https://github.com/LearnBoost/stylus) by [Maxime LUCE](https://github.com/SomaticIT) @@ -718,6 +737,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](tedious/tedious.d.ts) [tedious](https://pekim.github.io/tedious) by [Rogier Schouten](https://github.com/rogierschouten) * [:link:](tedious-connection-pool/tedious-connection-pool.d.ts) [tedious-connection-pool](https://github.com/pekim/tedious-connection-pool) by [Cyprien Autexier](https://github.com/sandorfr) * [:link:](teechart/teechart.d.ts) [TeeChart](http://www.steema.com) by [Steema Software](https://steema.com) +* [:link:](tether/tether.d.ts) [Tether](http://github.hubspot.com/tether) by [Adi Dahiya](https://github.com/adidahiya) * [:link:](text-buffer/text-buffer.d.ts) [text-buffer](https://github.com/atom/text-buffer) by [vvakame](https://github.com/vvakame) * [:link:](text-encoding/text-encoding.d.ts) [text-encoding](https://github.com/inexorabletash/text-encoding) by [MIZUNE Pine](https://github.com/pine613) * [:link:](threejs/three-canvasrenderer.d.ts) [three.js (CanvasRenderer.js)](https://github.com/mrdoob/three.js/blob/master/examples/js/renderers/CanvasRenderer.js) by [Satoru Kimura](https://github.com/gyohk) From 587449f4084a352bf0ef91cceda1b2fd57628d96 Mon Sep 17 00:00:00 2001 From: Marcin Porebski Date: Thu, 5 Mar 2015 16:31:17 +0100 Subject: [PATCH 173/185] ini module def. --- ini/ini-tests.ts | 10 ++++++++++ ini/ini.d.ts | 25 +++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 ini/ini-tests.ts create mode 100644 ini/ini.d.ts diff --git a/ini/ini-tests.ts b/ini/ini-tests.ts new file mode 100644 index 000000000..44241625f --- /dev/null +++ b/ini/ini-tests.ts @@ -0,0 +1,10 @@ +/// +/// + +import fs = require("fs"); +import ini = require("ini"); + +var ini_content = fs.readFileSync("path_to_file.ini", "utf-8"); + +var ini_object: any = ini.decode(ini_content); +var ini_rev_string: string = ini.encode(ini_object); \ No newline at end of file diff --git a/ini/ini.d.ts b/ini/ini.d.ts new file mode 100644 index 000000000..6cab73533 --- /dev/null +++ b/ini/ini.d.ts @@ -0,0 +1,25 @@ +// Type definitions for ini v1.3.3 +// Project: https://github.com/isaacs/ini +// Definitions by: Marcin Porębski +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module "ini" +{ + interface EncodeOptions { + section: string + whitespace: boolean + } + + function decode(inistring: string): any; + + function parse(initstring: string): any; + + function encode(object: any, options?: EncodeOptions): string; + + function stringify(object: any, options?: EncodeOptions): string; + + function safe(val: string): string; + + function unsafe(val: string): string; + +} From 8668b9ef4f037870ec83e6bad4c7bb702b43fb7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20M=C3=B6ller?= Date: Thu, 5 Mar 2015 16:54:26 +0100 Subject: [PATCH 174/185] Update chrome.d.ts Port has more properties. https://developer.chrome.com/extensions/runtime#type-Port change postMessage like onMessage was changed in 36f2213157fa535f5c4aef66da98559e9823e25c. add disconnect method. --- chrome/chrome.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/chrome/chrome.d.ts b/chrome/chrome.d.ts index cbabf893a..bc0d52227 100755 --- a/chrome/chrome.d.ts +++ b/chrome/chrome.d.ts @@ -1545,7 +1545,8 @@ declare module chrome.runtime { } interface Port { - postMessage: Function; + postMessage: (message: Object) => void; + disconnect: () => void; sender?: MessageSender; onDisconnect: chrome.events.Event; onMessage: PortMessageEvent; From 8d27cef4b0a2bfefd4d0d960cbf809d76c8d8849 Mon Sep 17 00:00:00 2001 From: falsandtru Date: Fri, 6 Mar 2015 00:49:46 +0900 Subject: [PATCH 175/185] Fix type mismatch --- jquery/jquery.d.ts | 55 ++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 29 deletions(-) diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index b82711120..203180150 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -283,12 +283,12 @@ interface JQueryGenericPromise { * Interface for the JQuery promise/deferred callbacks */ interface JQueryPromiseCallback { - (value?: T, ...args: any[]): void; + (value?: T, ...args: T[]): void; } -interface JQueryPromiseOperator { - (callback: JQueryPromiseCallback, ...callbacks: JQueryPromiseCallback[]): JQueryPromise; - (callback: JQueryPromiseCallback[], ...callbacks: JQueryPromiseCallback[]): JQueryPromise; +interface JQueryPromiseOperator { + (callback1: JQueryPromiseCallback, ...callbackN: JQueryPromiseCallback[]): JQueryPromise; + (callbacks1: JQueryPromiseCallback[], ...callbacksN: JQueryPromiseCallback[][]): JQueryPromise; } /** @@ -301,28 +301,31 @@ interface JQueryPromise { * @param alwaysCallbacks1 A function, or array of functions, that is called when the Deferred is resolved or rejected. * @param alwaysCallbacks2 Optional additional functions, or arrays of functions, that are called when the Deferred is resolved or rejected. */ - always: JQueryPromiseOperator; + always(alwaysCallback1?: JQueryPromiseCallback, ...alwaysCallbackN: JQueryPromiseCallback[]): JQueryPromise; + always(alwaysCallbacks1?: JQueryPromiseCallback[], ...alwaysCallbacksN: JQueryPromiseCallback[][]): JQueryPromise; /** * Add handlers to be called when the Deferred object is resolved. * * @param doneCallbacks1 A function, or array of functions, that are called when the Deferred is resolved. * @param doneCallbacks2 Optional additional functions, or arrays of functions, that are called when the Deferred is resolved. */ - done: JQueryPromiseOperator; + done(doneCallback1?: JQueryPromiseCallback, ...doneCallbackN: JQueryPromiseCallback[]): JQueryPromise; + done(doneCallbacks1?: JQueryPromiseCallback[], ...doneCallbacksN: JQueryPromiseCallback[][]): JQueryPromise; /** * Add handlers to be called when the Deferred object is rejected. * * @param failCallbacks1 A function, or array of functions, that are called when the Deferred is rejected. * @param failCallbacks2 Optional additional functions, or arrays of functions, that are called when the Deferred is rejected. */ - fail: JQueryPromiseOperator; + fail(failCallback1?: JQueryPromiseCallback, ...failCallbackN: JQueryPromiseCallback[]): JQueryPromise; + fail(failCallbacks1?: JQueryPromiseCallback[], ...failCallbacksN: JQueryPromiseCallback[][]): JQueryPromise; /** * Add handlers to be called when the Deferred object generates progress notifications. * * @param progressCallbacks A function, or array of functions, to be called when the Deferred generates progress notifications. */ - progress(progressCallback: JQueryPromiseCallback): JQueryPromise; - progress(progressCallbacks: JQueryPromiseCallback[]): JQueryPromise; + progress(progressCallback1?: JQueryPromiseCallback, ...progressCallbackN: JQueryPromiseCallback[]): JQueryPromise; + progress(progressCallback1s?: JQueryPromiseCallback[], ...progressCallbacksN: JQueryPromiseCallback[][]): JQueryPromise; /** * Determine the current state of a Deferred object. @@ -362,44 +365,38 @@ interface JQueryDeferred extends JQueryPromise { * @param alwaysCallbacks1 A function, or array of functions, that is called when the Deferred is resolved or rejected. * @param alwaysCallbacks2 Optional additional functions, or arrays of functions, that are called when the Deferred is resolved or rejected. */ - always(alwaysCallbacks1?: JQueryPromiseCallback, ...alwaysCallbacks2: JQueryPromiseCallback[]): JQueryDeferred; - always(alwaysCallbacks1?: JQueryPromiseCallback[], ...alwaysCallbacks2: JQueryPromiseCallback[]): JQueryDeferred; - always(alwaysCallbacks1?: JQueryPromiseCallback, ...alwaysCallbacks2: any[]): JQueryDeferred; - always(alwaysCallbacks1?: JQueryPromiseCallback[], ...alwaysCallbacks2: any[]): JQueryDeferred; + always(alwaysCallback1?: JQueryPromiseCallback, ...alwaysCallbackN: JQueryPromiseCallback[]): JQueryDeferred; + always(alwaysCallbacks1?: JQueryPromiseCallback[], ...alwaysCallbacksN: JQueryPromiseCallback[][]): JQueryDeferred; /** * Add handlers to be called when the Deferred object is resolved. * * @param doneCallbacks1 A function, or array of functions, that are called when the Deferred is resolved. * @param doneCallbacks2 Optional additional functions, or arrays of functions, that are called when the Deferred is resolved. */ - done(doneCallbacks1?: JQueryPromiseCallback, ...doneCallbacks2: JQueryPromiseCallback[]): JQueryDeferred; - done(doneCallbacks1?: JQueryPromiseCallback[], ...doneCallbacks2: JQueryPromiseCallback[]): JQueryDeferred; - done(doneCallbacks1?: JQueryPromiseCallback, ...doneCallbacks2: any[]): JQueryDeferred; - done(doneCallbacks1?: JQueryPromiseCallback[], ...doneCallbacks2: any[]): JQueryDeferred; + done(doneCallback1?: JQueryPromiseCallback, ...doneCallbackN: JQueryPromiseCallback[]): JQueryDeferred; + done(doneCallbacks1?: JQueryPromiseCallback[], ...doneCallbacksN: JQueryPromiseCallback[][]): JQueryDeferred; /** * Add handlers to be called when the Deferred object is rejected. * * @param failCallbacks1 A function, or array of functions, that are called when the Deferred is rejected. * @param failCallbacks2 Optional additional functions, or arrays of functions, that are called when the Deferred is rejected. */ - fail(failCallbacks1?: JQueryPromiseCallback, ...failCallbacks2: JQueryPromiseCallback[]): JQueryDeferred; - fail(failCallbacks1?: JQueryPromiseCallback[], ...failCallbacks2: JQueryPromiseCallback[]): JQueryDeferred; - fail(failCallbacks1?: JQueryPromiseCallback, ...failCallbacks2: any[]): JQueryDeferred; - fail(failCallbacks1?: JQueryPromiseCallback[], ...failCallbacks2: any[]): JQueryDeferred; + fail(failCallback1?: JQueryPromiseCallback, ...failCallbackN: JQueryPromiseCallback[]): JQueryDeferred; + fail(failCallbacks1?: JQueryPromiseCallback[], ...failCallbacksN: JQueryPromiseCallback[][]): JQueryDeferred; /** * Add handlers to be called when the Deferred object generates progress notifications. * * @param progressCallbacks A function, or array of functions, to be called when the Deferred generates progress notifications. */ - progress(progressCallback: JQueryPromiseCallback): JQueryDeferred; - progress(progressCallbacks: JQueryPromiseCallback[]): JQueryDeferred; + progress(progressCallback1?: JQueryPromiseCallback, ...progressCallbackN: JQueryPromiseCallback[]): JQueryDeferred; + progress(progressCallbacks1?: JQueryPromiseCallback[], ...progressCallbacksN: JQueryPromiseCallback[][]): JQueryDeferred; /** * Call the progressCallbacks on a Deferred object with the given args. * * @param args Optional arguments that are passed to the progressCallbacks. */ - notify(...args: any[]): JQueryDeferred; + notify(...args: T[]): JQueryDeferred; /** * Call the progressCallbacks on a Deferred object with the given context and args. @@ -407,21 +404,21 @@ interface JQueryDeferred extends JQueryPromise { * @param context Context passed to the progressCallbacks as the this object. * @param args Optional arguments that are passed to the progressCallbacks. */ - notifyWith(context: any, ...args: any[]): JQueryDeferred; + notifyWith(context: any, ...args: T[]): JQueryDeferred; /** * Reject a Deferred object and call any failCallbacks with the given args. * * @param args Optional arguments that are passed to the failCallbacks. */ - reject(...args: any[]): JQueryDeferred; + reject(...args: T[]): JQueryDeferred; /** * Reject a Deferred object and call any failCallbacks with the given context and args. * * @param context Context passed to the failCallbacks as the this object. * @param args An optional array of arguments that are passed to the failCallbacks. */ - rejectWith(context: any, ...args: any[]): JQueryDeferred; + rejectWith(context: any, ...args: T[]): JQueryDeferred; /** * Resolve a Deferred object and call any doneCallbacks with the given args. @@ -429,7 +426,7 @@ interface JQueryDeferred extends JQueryPromise { * @param value First argument passed to doneCallbacks. * @param args Optional subsequent arguments that are passed to the doneCallbacks. */ - resolve(value?: T, ...args: any[]): JQueryDeferred; + resolve(value?: T, ...args: T[]): JQueryDeferred; /** * Resolve a Deferred object and call any doneCallbacks with the given context and args. @@ -437,7 +434,7 @@ interface JQueryDeferred extends JQueryPromise { * @param context Context passed to the doneCallbacks as the this object. * @param args An optional array of arguments that are passed to the doneCallbacks. */ - resolveWith(context: any, ...args: any[]): JQueryDeferred; + resolveWith(context: any, ...args: T[]): JQueryDeferred; /** * Return a Deferred's Promise object. From 2bb37c8f95764cf90c32a2046e86c199fabdbaa3 Mon Sep 17 00:00:00 2001 From: "Michael C. Bazarewsky" Date: Thu, 5 Mar 2015 16:10:25 -0500 Subject: [PATCH 176/185] add missing axis parameter to flot tickFormatter The tickFormatter entry for a flot axis definition now has the optional axis argument available. --- flot/jquery.flot.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flot/jquery.flot.d.ts b/flot/jquery.flot.d.ts index 9ea862c5c..c179d2f03 100644 --- a/flot/jquery.flot.d.ts +++ b/flot/jquery.flot.d.ts @@ -107,7 +107,7 @@ declare module jquery.flot { ticks?: any; // null or number or ticks array or (fn: axis -> ticks array) tickSize?: any; // number or array minTickSize?: any; // number or array - tickFormatter?: (t: number) => string; // (fn: number, object -> string) or string + tickFormatter?: (t: number, a?: axis) => string; // (fn: number, object -> string) or string tickDecimals?: number; labelWidth?: number; From 84d54cedba2eab3581d166c2ae2eaaa871ca8105 Mon Sep 17 00:00:00 2001 From: Niklas Mollenhauer Date: Thu, 5 Mar 2015 23:03:57 +0100 Subject: [PATCH 177/185] Made keepEmptyLines optional If one decides to only use something of `TransformOptions` (e.g. `encoding`), it wouldn't be possible to omit the `keepEmptyLines` option. --- byline/byline.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/byline/byline.d.ts b/byline/byline.d.ts index 6dac6ad50..475386b28 100644 --- a/byline/byline.d.ts +++ b/byline/byline.d.ts @@ -9,7 +9,7 @@ declare module "byline" { import stream = require("stream"); export interface LineStreamOptions extends stream.TransformOptions { - keepEmptyLines: boolean; + keepEmptyLines?: boolean; } export interface LineStream extends stream.Transform { @@ -35,4 +35,4 @@ declare module "byline" { export function createStream(stream:NodeJS.ReadableStream, options?:LineStreamOptions):LineStream; export var LineStream:LineStreamCreatable; -} \ No newline at end of file +} From 55fd327d6bf4876ff711cdfd2fba205e248de4ce Mon Sep 17 00:00:00 2001 From: Brandon Luong Date: Thu, 5 Mar 2015 19:37:54 -0800 Subject: [PATCH 178/185] symbol API takes in accessor --- d3/d3.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/d3/d3.d.ts b/d3/d3.d.ts index a12009bba..3ab8a9b88 100644 --- a/d3/d3.d.ts +++ b/d3/d3.d.ts @@ -1673,8 +1673,8 @@ declare module D3 { } export interface Symbol { - type: (string:string) => Symbol; - size: (number:number) => Symbol; + type: (symbolType: string | ((datum: any, index: number) => string)) => Symbol; + size: (size: number | ((datum: any, index: number) => number)) => Symbol; (datum:any, index:number): string; } From e26a0474bd909b46856721116b7c0c7a4dd4b938 Mon Sep 17 00:00:00 2001 From: reppners Date: Fri, 6 Mar 2015 08:23:21 +0100 Subject: [PATCH 179/185] + update of definitions to make use of union types --- js-data-angular/js-data-angular.d.ts | 6 +- js-data-http/js-data-http.d.ts | 10 +- js-data/js-data.d.ts | 258 +++++++-------------------- 3 files changed, 72 insertions(+), 202 deletions(-) diff --git a/js-data-angular/js-data-angular.d.ts b/js-data-angular/js-data-angular.d.ts index 11a295562..242c6d5ab 100644 --- a/js-data-angular/js-data-angular.d.ts +++ b/js-data-angular/js-data-angular.d.ts @@ -16,15 +16,13 @@ declare module JSData { bindAll(resourceName:string, params:DSFilterParams, scope:ng.IScope, expr:string, cb?:(err:DSError, items:Array)=>void):Function; - bindOne(resourceName:string, id:string, scope:ng.IScope, expr:string, cb?:(err:DSError, item:T)=>void):Function; - bindOne(resourceName:string, id:number, scope:ng.IScope, expr:string, cb?:(err:DSError, item:T)=>void):Function; + bindOne(resourceName:string, id:string | number, scope:ng.IScope, expr:string, cb?:(err:DSError, item:T)=>void):Function; } interface DSResourceDefinition { bindAll(params:DSFilterParams, scope:ng.IScope, expr:string, cb?:(err:DSError, items:Array)=>void):Function; - bindOne(id:string, scope:ng.IScope, expr:string, cb?:(err:DSError, item:T)=>void):Function; - bindOne(id:number, scope:ng.IScope, expr:string, cb?:(err:DSError, item:T)=>void):Function; + bindOne(id:string | number, scope:ng.IScope, expr:string, cb?:(err:DSError, item:T)=>void):Function; } } \ No newline at end of file diff --git a/js-data-http/js-data-http.d.ts b/js-data-http/js-data-http.d.ts index 416aa3c8c..295e7cc6f 100644 --- a/js-data-http/js-data-http.d.ts +++ b/js-data-http/js-data-http.d.ts @@ -13,14 +13,8 @@ declare module JSData { queryTransform?: (resourceName:string, params:DSFilterParams)=>any; httpConfig?: any; forceTrailingSlash?: boolean; - log?: any; - // TODO wait for union types to be supported - // log: (message?: any, ...optionalParams: any[])=> void; - // log: boolean; - error?: any; - // TODO wait for union types to be supported - // error: (message?: any, ...optionalParams: any[])=> void; - // error: boolean; + log?: boolean | ((message?:any, ...optionalParams:any[])=> void); + error?: boolean | ((message?:any, ...optionalParams:any[])=> void); } interface DSHttpAdapterPromiseResolveType { diff --git a/js-data/js-data.d.ts b/js-data/js-data.d.ts index 7017481ee..bec41d331 100644 --- a/js-data/js-data.d.ts +++ b/js-data/js-data.d.ts @@ -1,4 +1,4 @@ -// Type definitions for JSData v1.3.0 +// Type definitions for JSData v1.5.4 // Project: https://github.com/js-data/js-data // Definitions by: Stefan Steinhart // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -34,97 +34,44 @@ declare module JSData { defaults:DSConfiguration; - changeHistory(resourceName:string, id?:string):Array; - changeHistory(resourceName:string, id?:number):Array; - - changes(resourceName:string, id:string):Object; - changes(resourceName:string, id:number):Object; - - compute(resourceName:string, id:number):T; - compute(resourceName:string, id:string):T; - compute(resourceName:string, instance:Object):T; - - create(resourceName:string, attrs:any, options?:DSConfiguration):JSDataPromise; - - createInstance(resourceName:string, attrs?:T, options?:DSAdapterOperationConfiguration):T; - - defineResource(resourceName:string):DSResourceDefinition; - defineResource(definition:DSResourceDefinitionConfiguration):DSResourceDefinition; - - destroy(resourceName:string, id:string, options?:DSAdapterOperationConfiguration):JSDataPromise; - destroy(resourceName:string, id:number, options?:DSAdapterOperationConfiguration):JSDataPromise; - + // async + create(resourceName:string, attrs:Object, options?:DSConfiguration):JSDataPromise; + destroy(resourceName:string, id:string | number, options?:DSAdapterOperationConfiguration):JSDataPromise; destroyAll(resourceName:string, params?:DSFilterParams, options?:DSAdapterOperationConfiguration):JSDataPromise; - - digest():void; - - eject(resourceName:string, id:string, options?:DSConfiguration):T; - eject(resourceName:string, id:number, options?:DSConfiguration):T; - - ejectAll(resourceName:string, params:DSFilterParams, options?:DSConfiguration):Array; - - filter(resourceName:string, params:DSFilterParams, options?:DSConfiguration):Array; - - find(resourceName:string, id:string, options?:DSAdapterOperationConfiguration):JSDataPromise; - find(resourceName:string, id:number, options?:DSAdapterOperationConfiguration):JSDataPromise; - + find(resourceName:string, id:string | number, options?:DSAdapterOperationConfiguration):JSDataPromise; findAll(resourceName:string, params?:DSFilterParams, options?:DSAdapterOperationConfiguration):JSDataPromise>; + loadRelations(resourceName:string, idOrInstance:string | number | Object, relations:string | Array, options?:DSAdapterOperationConfiguration):JSDataPromise; + update(resourceName:string, id:string | number, attrs:Object, options?:DSSaveConfiguration):JSDataPromise; + updateAll(resourceName:string, attrs:Object, params?:DSFilterParams, options?:DSAdapterOperationConfiguration):JSDataPromise>; + reap(resourceName:string, options?:DSConfiguration):JSDataPromise; + refresh(resourceName:string, id:string | number, options?:DSAdapterOperationConfiguration):JSDataPromise; + save(resourceName:string, id:string | number, options?:DSSaveConfiguration):JSDataPromise; - get(resourceName:string, id:string, options?:DSConfiguration):T; - get(resourceName:string, id:number, options?:DSConfiguration):T; - - getAll(resourceName:string, ids?:Array):Array; - getAll(resourceName:string, ids?:Array):Array; - - hasChanges(resourceName:string, id:string):boolean; - hasChanges(resourceName:string, id:number):boolean; - + // sync + changeHistory(resourceName:string, id?:string | number):Array; + changes(resourceName:string, id:string | number):Object; + compute(resourceName:string, idOrInstance:number | string | Object ):T; + createInstance(resourceName:string, attrs?:T, options?:DSAdapterOperationConfiguration):T; + defineResource(resourceNameOrDefinition:string | DSResourceDefinitionConfiguration):DSResourceDefinition; + digest():void; + eject(resourceName:string, id:string | number, options?:DSConfiguration):T; + ejectAll(resourceName:string, params:DSFilterParams, options?:DSConfiguration):Array; + filter(resourceName:string, params:DSFilterParams, options?:DSConfiguration):Array; + get(resourceName:string, id:string | number, options?:DSConfiguration):T; + getAll(resourceName:string, ids?:Array):Array; + hasChanges(resourceName:string, id:string | number):boolean; inject(resourceName:string, attrs:T, options?:DSConfiguration):T; inject(resourceName:string, items:Array, options?:DSConfiguration):Array; - is(resourceName:string, object:Object): boolean; - - lastModified(resourceName:string, id?:string):number; // timestamp - lastModified(resourceName:string, id?:number):number; // timestamp - - lastSaved(resourceName:string, id?:string):number; // timestamp - lastSaved(resourceName:string, id?:number):number; // timestamp - - link(resourceName:string, id:string, relations?:Array):T; - link(resourceName:string, id:number, relations?:Array):T; - + lastModified(resourceName:string, id?:string | number):number; // timestamp + lastSaved(resourceName:string, id?:string | number):number; // timestamp + link(resourceName:string, id:string | number, relations?:Array):T; linkAll(resourceName:string, params:DSFilterParams, relations?:Array):T; - - linkInverse(resourceName:string, id:string, relations?:Array):T; - linkInverse(resourceName:string, id:number, relations?:Array):T; - - loadRelations(resourceName:string, id:string, relations:string, options?:DSAdapterOperationConfiguration):JSDataPromise; - loadRelations(resourceName:string, id:number, relations:string, options?:DSAdapterOperationConfiguration):JSDataPromise; - loadRelations(resourceName:string, instance:Object, relations:string, options?:DSAdapterOperationConfiguration):JSDataPromise; - loadRelations(resourceName:string, id:string, relations:Array, options?:DSAdapterOperationConfiguration):JSDataPromise; - loadRelations(resourceName:string, id:number, relations:Array, options?:DSAdapterOperationConfiguration):JSDataPromise; - loadRelations(resourceName:string, instance:Object, relations:Array, options?:DSAdapterOperationConfiguration):JSDataPromise; - - previous(resourceName:string, id:string):T; - previous(resourceName:string, id:number):T; - - reap(resourceName:string, options?:DSConfiguration):JSDataPromise; - - refresh(resourceName:string, id:string, options?:DSAdapterOperationConfiguration):JSDataPromise; - refresh(resourceName:string, id:number, options?:DSAdapterOperationConfiguration):JSDataPromise; + linkInverse(resourceName:string, id:string | number, relations?:Array):T; + previous(resourceName:string, id:string | number):T; + unlinkInverse(resourceName:string, id:string | number, relations?:Array):T; registerAdapter(adapterId:string, adapter:IDSAdapter, options?:{default: boolean}):void; - - save(resourceName:string, id:string, options?:DSSaveConfiguration):JSDataPromise; - save(resourceName:string, id:number, options?:DSSaveConfiguration):JSDataPromise; - - unlinkInverse(resourceName:string, id:string, relations?:Array):T; - unlinkInverse(resourceName:string, id:number, relations?:Array):T; - - update(resourceName:string, id:string, attrs:any, options?:DSSaveConfiguration):JSDataPromise; - update(resourceName:string, id:number, attrs:any, options?:DSSaveConfiguration):JSDataPromise; - - updateAll(resourceName:string, attrs:any, params?:DSFilterParams, options?:DSAdapterOperationConfiguration):JSDataPromise>; } interface DSConfiguration extends IDSResourceLifecycleEventHandlers { @@ -139,7 +86,7 @@ declare module JSData { // TODO enable when eagerInject in DS#create is implemented //eagerInject?: boolean; endpoint?: string; - error?: (message?:any, ...optionalParams:any[])=> void; + error?: boolean | ((message?:any, ...optionalParams:any[])=> void); fallbackAdapters?: Array; findAllFallbackAdapters?: Array; findAllStrategy?: string; @@ -150,15 +97,12 @@ declare module JSData { findInverseLinks?: boolean; findStrategy?: string idAttribute?: string; - ignoredChanges?: Array; + ignoredChanges?: Array; // TODO ignoreMissing is undocumented //ignoreMissing: boolean; keepChangeHistory?: boolean; loadFromServer?: boolean; - log?: any; - // TODO wait for union types to be supported - // log: (message?: any, ...optionalParams: any[])=> void; - // log: boolean; + log?: boolean | ((message?: any, ...optionalParams: any[])=> void); maxAge?: number; notify?: boolean; reapAction?: string; @@ -191,95 +135,41 @@ declare module JSData { interface DSResourceDefinition extends DSResourceDefinitionConfiguration { - changeHistory(id?:string):Array; - changeHistory(id?:number):Array; - - changes(id:string):Object; - changes(id:number):Object; - - compute(id:number):T; - compute(id:string):T; - compute(instance:Object):T; - - create(attrs:any, options?:DSConfiguration):JSDataPromise; - - createInstance(attrs?:T, options?:DSAdapterOperationConfiguration):T; - - defineResource(resourceName:string):DSResourceDefinition; - defineResource(definition:DSResourceDefinitionConfiguration):DSResourceDefinition; - - destroy(id:string, options?:DSAdapterOperationConfiguration):JSDataPromise; - destroy(id:number, options?:DSAdapterOperationConfiguration):JSDataPromise; - + //async + create(attrs:Object, options?:DSConfiguration):JSDataPromise; + destroy(id:string | number, options?:DSAdapterOperationConfiguration):JSDataPromise; destroyAll(params?:DSFilterParams, options?:DSAdapterOperationConfiguration):JSDataPromise; - - digest():void; - - eject(id:string, options?:DSConfiguration):T; - eject(id:number, options?:DSConfiguration):T; - - ejectAll(params:DSFilterParams, options?:DSConfiguration):Array; - - filter(params:DSFilterParams, options?:DSConfiguration):Array; - - find(id:string, options?:DSAdapterOperationConfiguration):JSDataPromise; - find(id:number, options?:DSAdapterOperationConfiguration):JSDataPromise; - + find(id:string | number, options?:DSAdapterOperationConfiguration):JSDataPromise; findAll(params?:DSFilterParams, options?:DSAdapterOperationConfiguration):JSDataPromise>; + loadRelations(idOrInstance:string | number | Object, relations:string | Array, options?:DSAdapterOperationConfiguration):JSDataPromise; + update(id:string | number, attrs:Object, options?:DSSaveConfiguration):JSDataPromise; + updateAll(attrs:Object, params?:DSFilterParams, options?:DSAdapterOperationConfiguration):JSDataPromise>; + reap(resourceNametions?:DSConfiguration):JSDataPromise; + refresh(id:string | number, options?:DSAdapterOperationConfiguration):JSDataPromise; + save(id:string | number, options?:DSSaveConfiguration):JSDataPromise; - get(id:string, options?:DSConfiguration):T; - get(id:number, options?:DSConfiguration):T; - - getAll(ids?:Array):Array; - getAll(ids?:Array):Array; - - hasChanges(id:string):boolean; - hasChanges(id:number):boolean; - + // sync + changeHistory(id?:string | number):Array; + changes(id:string | number):Object; + compute(idOrInstance:number | string | Object ):T; + createInstance(attrs?:T, options?:DSAdapterOperationConfiguration):T; + digest():void; + eject(id:string | number, options?:DSConfiguration):T; + ejectAll(params:DSFilterParams, options?:DSConfiguration):Array; + filter(params:DSFilterParams, options?:DSConfiguration):Array; + get(id:string | number, options?:DSConfiguration):T; + getAll(ids?:Array):Array; + hasChanges(id:string | number):boolean; inject(attrs:T, options?:DSConfiguration):T; inject(items:Array, options?:DSConfiguration):Array; - is(object:Object): boolean; - - lastModified(id?:string):number; // timestamp - lastModified(id?:number):number; // timestamp - - lastSaved(id?:string):number; // timestamp - lastSaved(id?:number):number; // timestamp - - link(id:string, relations?:Array):T; - link(id:number, relations?:Array):T; - + lastModified(id?:string | number):number; // timestamp + lastSaved(id?:string | number):number; // timestamp + link(id:string | number, relations?:Array):T; linkAll(params:DSFilterParams, relations?:Array):T; - - linkInverse(id:string, relations?:Array):T; - linkInverse(id:number, relations?:Array):T; - - loadRelations(id:string, relations:string, options?:DSAdapterOperationConfiguration):JSDataPromise; - loadRelations(id:number, relations:string, options?:DSAdapterOperationConfiguration):JSDataPromise; - loadRelations(instance:T, relations:string, options?:DSAdapterOperationConfiguration):JSDataPromise; - loadRelations(id:string, relations:Array, options?:DSAdapterOperationConfiguration):JSDataPromise; - loadRelations(id:number, relations:Array, options?:DSAdapterOperationConfiguration):JSDataPromise; - loadRelations(instance:T, relations:Array, options?:DSAdapterOperationConfiguration):JSDataPromise; - - previous(id:string):T; - previous(id:number):T; - - reap(options?:DSConfiguration):JSDataPromise; - - refresh(id:string, options?:DSAdapterOperationConfiguration):JSDataPromise; - refresh(id:number, options?:DSAdapterOperationConfiguration):JSDataPromise; - - save(id:string, options?:DSSaveConfiguration):JSDataPromise; - save(id:number, options?:DSSaveConfiguration):JSDataPromise; - - unlinkInverse(id:string, relations?:Array):T; - unlinkInverse(id:number, relations?:Array):T; - - update(id:string, attrs:any, options?:DSSaveConfiguration):JSDataPromise; - update(id:number, attrs:any, options?:DSSaveConfiguration):JSDataPromise; - - updateAll(attrs:any, params?:DSFilterParams, options?:DSAdapterOperationConfiguration):JSDataPromise>; + linkInverse(id:string | number, relations?:Array):T; + previous(id:string | number):T; + unlinkInverse(id:string | number, relations?:Array):T; } interface DSFilterParams { @@ -290,17 +180,8 @@ declare module JSData { skip?: number; offset?: number; - orderBy?: any; - // TODO wait for union types to be supported - //orderBy?: Array>; - //orderBy?: Array; - //orderBy?: string; - - sort?: any; - // TODO wait for union types to be supported - //sort?: string; - //sort?: Array; - //sort?: Array>; + orderBy?: string | Array | Array>; + sort?: string | Array | Array>; } interface IDSResourceLifecycleValidateEventHandlers { @@ -375,22 +256,19 @@ declare module JSData { // DSAdapter interface interface IDSAdapter { - create(config:DSResourceDefinition, attrs:any, options?:DSConfiguration):JSDataPromise; + create(config:DSResourceDefinition, attrs:Object, options?:DSConfiguration):JSDataPromise; - destroy(config:DSResourceDefinition, id:string, options?:DSConfiguration):JSDataPromise; - destroy(config:DSResourceDefinition, id:number, options?:DSConfiguration):JSDataPromise; + destroy(config:DSResourceDefinition, id:string | number, options?:DSConfiguration):JSDataPromise; destroyAll(config:DSResourceDefinition, params:DSFilterParams, options?:DSConfiguration):JSDataPromise; - find(config:DSResourceDefinition, id:string, options?:DSConfiguration):JSDataPromise; - find(config:DSResourceDefinition, id:number, options?:DSConfiguration):JSDataPromise; + find(config:DSResourceDefinition, id:string | number, options?:DSConfiguration):JSDataPromise; findAll(config:DSResourceDefinition, params?:DSFilterParams, options?:DSConfiguration):JSDataPromise; - update(config:DSResourceDefinition, id:string, attrs:any, options?:DSConfiguration):JSDataPromise; - update(config:DSResourceDefinition, id:number, attrs:any, options?:DSConfiguration):JSDataPromise; + update(config:DSResourceDefinition, id:string | number, attrs:Object, options?:DSConfiguration):JSDataPromise; - updateAll(config:DSResourceDefinition, attrs:any, params?:DSFilterParams, options?:DSConfiguration):JSDataPromise; + updateAll(config:DSResourceDefinition, attrs:Object, params?:DSFilterParams, options?:DSConfiguration):JSDataPromise; } } From a6625f59620cf2a4daf8daf894b494a12d8e4670 Mon Sep 17 00:00:00 2001 From: Raphael Schweizer Date: Fri, 6 Mar 2015 13:01:40 +0100 Subject: [PATCH 180/185] add angular $animate.animate declaration --- angularjs/angular-animate.d.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/angularjs/angular-animate.d.ts b/angularjs/angular-animate.d.ts index a01c93ef5..f649d65f7 100644 --- a/angularjs/angular-animate.d.ts +++ b/angularjs/angular-animate.d.ts @@ -1,6 +1,6 @@ // Type definitions for Angular JS 1.3 (ngAnimate module) // Project: http://angularjs.org -// Definitions by: Michel Salib , Adi Dahiya +// Definitions by: Michel Salib , Adi Dahiya , Raphael Schweizer // Definitions: https://github.com/borisyankov/DefinitelyTyped /// @@ -25,6 +25,17 @@ declare module ng.animate { */ enabled(value?: boolean, element?: JQuery): boolean; + /** + * Performs an inline animation on the element. + * + * @param element the element that will be the focus of the animation + * @param from a collection of CSS styles that will be applied to the element at the start of the animation + * @param to a collection of CSS styles that the element will animate towards + * @param className an optional CSS class that will be added to the element for the duration of the animation (the default class is 'ng-inline-animate') + * @returns the animation callback promise + */ + animate(element: JQuery, from: any, to: any, className?: string): ng.IPromise; + /** * Appends the element to the parentElement element that resides in the document and then runs the enter animation. * From ebcec4e3d950fd87a222317e6ad4a80766f4e3e1 Mon Sep 17 00:00:00 2001 From: falsandtru Date: Fri, 6 Mar 2015 22:24:22 +0900 Subject: [PATCH 181/185] Fix error --- jquery/jquery.d.ts | 41 ++++++++++++++++------------------------- 1 file changed, 16 insertions(+), 25 deletions(-) diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index 203180150..b2ae6a755 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -283,12 +283,11 @@ interface JQueryGenericPromise { * Interface for the JQuery promise/deferred callbacks */ interface JQueryPromiseCallback { - (value?: T, ...args: T[]): void; + (value?: T, ...args: any[]): void; } interface JQueryPromiseOperator { - (callback1: JQueryPromiseCallback, ...callbackN: JQueryPromiseCallback[]): JQueryPromise; - (callbacks1: JQueryPromiseCallback[], ...callbacksN: JQueryPromiseCallback[][]): JQueryPromise; + (callback1: JQueryPromiseCallback|JQueryPromiseCallback[], ...callbacksN: Array|JQueryPromiseCallback[]>): JQueryPromise; } /** @@ -301,31 +300,27 @@ interface JQueryPromise { * @param alwaysCallbacks1 A function, or array of functions, that is called when the Deferred is resolved or rejected. * @param alwaysCallbacks2 Optional additional functions, or arrays of functions, that are called when the Deferred is resolved or rejected. */ - always(alwaysCallback1?: JQueryPromiseCallback, ...alwaysCallbackN: JQueryPromiseCallback[]): JQueryPromise; - always(alwaysCallbacks1?: JQueryPromiseCallback[], ...alwaysCallbacksN: JQueryPromiseCallback[][]): JQueryPromise; + always(alwaysCallback1?: JQueryPromiseCallback|JQueryPromiseCallback[], ...alwaysCallbacksN: Array|JQueryPromiseCallback[]>): JQueryPromise; /** * Add handlers to be called when the Deferred object is resolved. * * @param doneCallbacks1 A function, or array of functions, that are called when the Deferred is resolved. * @param doneCallbacks2 Optional additional functions, or arrays of functions, that are called when the Deferred is resolved. */ - done(doneCallback1?: JQueryPromiseCallback, ...doneCallbackN: JQueryPromiseCallback[]): JQueryPromise; - done(doneCallbacks1?: JQueryPromiseCallback[], ...doneCallbacksN: JQueryPromiseCallback[][]): JQueryPromise; + done(doneCallback1?: JQueryPromiseCallback|JQueryPromiseCallback[], ...doneCallbackN: Array|JQueryPromiseCallback[]>): JQueryPromise; /** * Add handlers to be called when the Deferred object is rejected. * * @param failCallbacks1 A function, or array of functions, that are called when the Deferred is rejected. * @param failCallbacks2 Optional additional functions, or arrays of functions, that are called when the Deferred is rejected. */ - fail(failCallback1?: JQueryPromiseCallback, ...failCallbackN: JQueryPromiseCallback[]): JQueryPromise; - fail(failCallbacks1?: JQueryPromiseCallback[], ...failCallbacksN: JQueryPromiseCallback[][]): JQueryPromise; + fail(failCallback1?: JQueryPromiseCallback|JQueryPromiseCallback[], ...failCallbacksN: Array|JQueryPromiseCallback[]>): JQueryPromise; /** * Add handlers to be called when the Deferred object generates progress notifications. * * @param progressCallbacks A function, or array of functions, to be called when the Deferred generates progress notifications. */ - progress(progressCallback1?: JQueryPromiseCallback, ...progressCallbackN: JQueryPromiseCallback[]): JQueryPromise; - progress(progressCallback1s?: JQueryPromiseCallback[], ...progressCallbacksN: JQueryPromiseCallback[][]): JQueryPromise; + progress(progressCallback1?: JQueryPromiseCallback|JQueryPromiseCallback[], ...progressCallbackN: Array|JQueryPromiseCallback[]>): JQueryPromise; /** * Determine the current state of a Deferred object. @@ -365,38 +360,34 @@ interface JQueryDeferred extends JQueryPromise { * @param alwaysCallbacks1 A function, or array of functions, that is called when the Deferred is resolved or rejected. * @param alwaysCallbacks2 Optional additional functions, or arrays of functions, that are called when the Deferred is resolved or rejected. */ - always(alwaysCallback1?: JQueryPromiseCallback, ...alwaysCallbackN: JQueryPromiseCallback[]): JQueryDeferred; - always(alwaysCallbacks1?: JQueryPromiseCallback[], ...alwaysCallbacksN: JQueryPromiseCallback[][]): JQueryDeferred; + always(alwaysCallback1?: JQueryPromiseCallback|JQueryPromiseCallback[], ...alwaysCallbacksN: Array|JQueryPromiseCallback[]>): JQueryPromise; /** * Add handlers to be called when the Deferred object is resolved. * * @param doneCallbacks1 A function, or array of functions, that are called when the Deferred is resolved. * @param doneCallbacks2 Optional additional functions, or arrays of functions, that are called when the Deferred is resolved. */ - done(doneCallback1?: JQueryPromiseCallback, ...doneCallbackN: JQueryPromiseCallback[]): JQueryDeferred; - done(doneCallbacks1?: JQueryPromiseCallback[], ...doneCallbacksN: JQueryPromiseCallback[][]): JQueryDeferred; + done(doneCallback1?: JQueryPromiseCallback|JQueryPromiseCallback[], ...doneCallbackN: Array|JQueryPromiseCallback[]>): JQueryPromise; /** * Add handlers to be called when the Deferred object is rejected. * * @param failCallbacks1 A function, or array of functions, that are called when the Deferred is rejected. * @param failCallbacks2 Optional additional functions, or arrays of functions, that are called when the Deferred is rejected. */ - fail(failCallback1?: JQueryPromiseCallback, ...failCallbackN: JQueryPromiseCallback[]): JQueryDeferred; - fail(failCallbacks1?: JQueryPromiseCallback[], ...failCallbacksN: JQueryPromiseCallback[][]): JQueryDeferred; + fail(failCallback1?: JQueryPromiseCallback|JQueryPromiseCallback[], ...failCallbacksN: Array|JQueryPromiseCallback[]>): JQueryPromise; /** * Add handlers to be called when the Deferred object generates progress notifications. * * @param progressCallbacks A function, or array of functions, to be called when the Deferred generates progress notifications. */ - progress(progressCallback1?: JQueryPromiseCallback, ...progressCallbackN: JQueryPromiseCallback[]): JQueryDeferred; - progress(progressCallbacks1?: JQueryPromiseCallback[], ...progressCallbacksN: JQueryPromiseCallback[][]): JQueryDeferred; + progress(progressCallback1?: JQueryPromiseCallback|JQueryPromiseCallback[], ...progressCallbackN: Array|JQueryPromiseCallback[]>): JQueryPromise; /** * Call the progressCallbacks on a Deferred object with the given args. * * @param args Optional arguments that are passed to the progressCallbacks. */ - notify(...args: T[]): JQueryDeferred; + notify(value?: any, ...args: any[]): JQueryDeferred; /** * Call the progressCallbacks on a Deferred object with the given context and args. @@ -404,21 +395,21 @@ interface JQueryDeferred extends JQueryPromise { * @param context Context passed to the progressCallbacks as the this object. * @param args Optional arguments that are passed to the progressCallbacks. */ - notifyWith(context: any, ...args: T[]): JQueryDeferred; + notifyWith(context: any, value?: any, ...args: any[]): JQueryDeferred; /** * Reject a Deferred object and call any failCallbacks with the given args. * * @param args Optional arguments that are passed to the failCallbacks. */ - reject(...args: T[]): JQueryDeferred; + reject(value?: any, ...args: any[]): JQueryDeferred; /** * Reject a Deferred object and call any failCallbacks with the given context and args. * * @param context Context passed to the failCallbacks as the this object. * @param args An optional array of arguments that are passed to the failCallbacks. */ - rejectWith(context: any, ...args: T[]): JQueryDeferred; + rejectWith(context: any, value?: any, ...args: any[]): JQueryDeferred; /** * Resolve a Deferred object and call any doneCallbacks with the given args. @@ -426,7 +417,7 @@ interface JQueryDeferred extends JQueryPromise { * @param value First argument passed to doneCallbacks. * @param args Optional subsequent arguments that are passed to the doneCallbacks. */ - resolve(value?: T, ...args: T[]): JQueryDeferred; + resolve(value?: T, ...args: any[]): JQueryDeferred; /** * Resolve a Deferred object and call any doneCallbacks with the given context and args. @@ -434,7 +425,7 @@ interface JQueryDeferred extends JQueryPromise { * @param context Context passed to the doneCallbacks as the this object. * @param args An optional array of arguments that are passed to the doneCallbacks. */ - resolveWith(context: any, ...args: T[]): JQueryDeferred; + resolveWith(context: any, value?: T, ...args: any[]): JQueryDeferred; /** * Return a Deferred's Promise object. From 4d201887009584cd1a7c27c47dd2d6058d5d786e Mon Sep 17 00:00:00 2001 From: falsandtru Date: Fri, 6 Mar 2015 22:29:38 +0900 Subject: [PATCH 182/185] Fix return type --- jquery/jquery.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index b2ae6a755..fd7ba70c9 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -360,27 +360,27 @@ interface JQueryDeferred extends JQueryPromise { * @param alwaysCallbacks1 A function, or array of functions, that is called when the Deferred is resolved or rejected. * @param alwaysCallbacks2 Optional additional functions, or arrays of functions, that are called when the Deferred is resolved or rejected. */ - always(alwaysCallback1?: JQueryPromiseCallback|JQueryPromiseCallback[], ...alwaysCallbacksN: Array|JQueryPromiseCallback[]>): JQueryPromise; + always(alwaysCallback1?: JQueryPromiseCallback|JQueryPromiseCallback[], ...alwaysCallbacksN: Array|JQueryPromiseCallback[]>): JQueryDeferred; /** * Add handlers to be called when the Deferred object is resolved. * * @param doneCallbacks1 A function, or array of functions, that are called when the Deferred is resolved. * @param doneCallbacks2 Optional additional functions, or arrays of functions, that are called when the Deferred is resolved. */ - done(doneCallback1?: JQueryPromiseCallback|JQueryPromiseCallback[], ...doneCallbackN: Array|JQueryPromiseCallback[]>): JQueryPromise; + done(doneCallback1?: JQueryPromiseCallback|JQueryPromiseCallback[], ...doneCallbackN: Array|JQueryPromiseCallback[]>): JQueryDeferred; /** * Add handlers to be called when the Deferred object is rejected. * * @param failCallbacks1 A function, or array of functions, that are called when the Deferred is rejected. * @param failCallbacks2 Optional additional functions, or arrays of functions, that are called when the Deferred is rejected. */ - fail(failCallback1?: JQueryPromiseCallback|JQueryPromiseCallback[], ...failCallbacksN: Array|JQueryPromiseCallback[]>): JQueryPromise; + fail(failCallback1?: JQueryPromiseCallback|JQueryPromiseCallback[], ...failCallbacksN: Array|JQueryPromiseCallback[]>): JQueryDeferred; /** * Add handlers to be called when the Deferred object generates progress notifications. * * @param progressCallbacks A function, or array of functions, to be called when the Deferred generates progress notifications. */ - progress(progressCallback1?: JQueryPromiseCallback|JQueryPromiseCallback[], ...progressCallbackN: Array|JQueryPromiseCallback[]>): JQueryPromise; + progress(progressCallback1?: JQueryPromiseCallback|JQueryPromiseCallback[], ...progressCallbackN: Array|JQueryPromiseCallback[]>): JQueryDeferred; /** * Call the progressCallbacks on a Deferred object with the given args. From d7dcca44c67070f4e6f699d4d555a7ae51715417 Mon Sep 17 00:00:00 2001 From: falsandtru Date: Fri, 6 Mar 2015 22:37:21 +0900 Subject: [PATCH 183/185] Fix generic type --- jquery/jquery.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index fd7ba70c9..e29b1046f 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -287,7 +287,7 @@ interface JQueryPromiseCallback { } interface JQueryPromiseOperator { - (callback1: JQueryPromiseCallback|JQueryPromiseCallback[], ...callbacksN: Array|JQueryPromiseCallback[]>): JQueryPromise; + (callback1: JQueryPromiseCallback|JQueryPromiseCallback[], ...callbacksN: Array|JQueryPromiseCallback[]>): JQueryPromise; } /** From eba07e99412c054cca903a159817bc932bc60989 Mon Sep 17 00:00:00 2001 From: falsandtru Date: Fri, 6 Mar 2015 23:49:30 +0900 Subject: [PATCH 184/185] Fix definition --- jquery/jquery.d.ts | 36 ++++-------------------------------- 1 file changed, 4 insertions(+), 32 deletions(-) diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index e29b1046f..8ddc072b0 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -300,27 +300,27 @@ interface JQueryPromise { * @param alwaysCallbacks1 A function, or array of functions, that is called when the Deferred is resolved or rejected. * @param alwaysCallbacks2 Optional additional functions, or arrays of functions, that are called when the Deferred is resolved or rejected. */ - always(alwaysCallback1?: JQueryPromiseCallback|JQueryPromiseCallback[], ...alwaysCallbacksN: Array|JQueryPromiseCallback[]>): JQueryPromise; + always(alwaysCallback1?: JQueryPromiseCallback|JQueryPromiseCallback[], ...alwaysCallbacksN: Array|JQueryPromiseCallback[]>): JQueryDeferred; /** * Add handlers to be called when the Deferred object is resolved. * * @param doneCallbacks1 A function, or array of functions, that are called when the Deferred is resolved. * @param doneCallbacks2 Optional additional functions, or arrays of functions, that are called when the Deferred is resolved. */ - done(doneCallback1?: JQueryPromiseCallback|JQueryPromiseCallback[], ...doneCallbackN: Array|JQueryPromiseCallback[]>): JQueryPromise; + done(doneCallback1?: JQueryPromiseCallback|JQueryPromiseCallback[], ...doneCallbackN: Array|JQueryPromiseCallback[]>): JQueryDeferred; /** * Add handlers to be called when the Deferred object is rejected. * * @param failCallbacks1 A function, or array of functions, that are called when the Deferred is rejected. * @param failCallbacks2 Optional additional functions, or arrays of functions, that are called when the Deferred is rejected. */ - fail(failCallback1?: JQueryPromiseCallback|JQueryPromiseCallback[], ...failCallbacksN: Array|JQueryPromiseCallback[]>): JQueryPromise; + fail(failCallback1?: JQueryPromiseCallback|JQueryPromiseCallback[], ...failCallbacksN: Array|JQueryPromiseCallback[]>): JQueryDeferred; /** * Add handlers to be called when the Deferred object generates progress notifications. * * @param progressCallbacks A function, or array of functions, to be called when the Deferred generates progress notifications. */ - progress(progressCallback1?: JQueryPromiseCallback|JQueryPromiseCallback[], ...progressCallbackN: Array|JQueryPromiseCallback[]>): JQueryPromise; + progress(progressCallback1?: JQueryPromiseCallback|JQueryPromiseCallback[], ...progressCallbackN: Array|JQueryPromiseCallback[]>): JQueryDeferred; /** * Determine the current state of a Deferred object. @@ -354,34 +354,6 @@ interface JQueryPromise { * Interface for the JQuery deferred, part of callbacks */ interface JQueryDeferred extends JQueryPromise { - /** - * Add handlers to be called when the Deferred object is either resolved or rejected. - * - * @param alwaysCallbacks1 A function, or array of functions, that is called when the Deferred is resolved or rejected. - * @param alwaysCallbacks2 Optional additional functions, or arrays of functions, that are called when the Deferred is resolved or rejected. - */ - always(alwaysCallback1?: JQueryPromiseCallback|JQueryPromiseCallback[], ...alwaysCallbacksN: Array|JQueryPromiseCallback[]>): JQueryDeferred; - /** - * Add handlers to be called when the Deferred object is resolved. - * - * @param doneCallbacks1 A function, or array of functions, that are called when the Deferred is resolved. - * @param doneCallbacks2 Optional additional functions, or arrays of functions, that are called when the Deferred is resolved. - */ - done(doneCallback1?: JQueryPromiseCallback|JQueryPromiseCallback[], ...doneCallbackN: Array|JQueryPromiseCallback[]>): JQueryDeferred; - /** - * Add handlers to be called when the Deferred object is rejected. - * - * @param failCallbacks1 A function, or array of functions, that are called when the Deferred is rejected. - * @param failCallbacks2 Optional additional functions, or arrays of functions, that are called when the Deferred is rejected. - */ - fail(failCallback1?: JQueryPromiseCallback|JQueryPromiseCallback[], ...failCallbacksN: Array|JQueryPromiseCallback[]>): JQueryDeferred; - /** - * Add handlers to be called when the Deferred object generates progress notifications. - * - * @param progressCallbacks A function, or array of functions, to be called when the Deferred generates progress notifications. - */ - progress(progressCallback1?: JQueryPromiseCallback|JQueryPromiseCallback[], ...progressCallbackN: Array|JQueryPromiseCallback[]>): JQueryDeferred; - /** * Call the progressCallbacks on a Deferred object with the given args. * From 402f9a04111b198203277334cc693aa7ba5e72fd Mon Sep 17 00:00:00 2001 From: Adam Robins Date: Fri, 6 Mar 2015 14:54:03 +0000 Subject: [PATCH 185/185] Updating the TODO on the chartResetButton Ran into this issue today, not having a strongly defined theme for the reset zoom button. Didn't go any further than the first level as the states are branches of HTML elements which are not highcharts specific. --- highcharts/highcharts.d.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/highcharts/highcharts.d.ts b/highcharts/highcharts.d.ts index 98e96e2ef..3b0801651 100644 --- a/highcharts/highcharts.d.ts +++ b/highcharts/highcharts.d.ts @@ -191,7 +191,15 @@ interface HighchartsBoolOrShadow { interface HighchartsChartResetZoomButton { position: HighchartsPosition; relativeTo?: string; - theme?: any; //TO DO + theme?: HighchartsChartResetZoomButtonTheme; //TO DO +} + +interface HighchartsChartResetZoomButtonTheme { + fill?:string; //css HEX colours. + stroke?: string;//css HEX colours. + r?: number; // Radius % + states?: any; // HTML element states eg: hover, with css attributes in object. + display?:string; // css attr eg: 'none' } interface HighchartsChartOptions {