From 6062a2c9d8d90abf67dd93c201d63d63bbc55e13 Mon Sep 17 00:00:00 2001 From: Stephen Lautier Date: Mon, 14 Sep 2015 03:06:47 +0200 Subject: [PATCH 01/43] updated localforage to use es6 promises definitions + enabled es6 imports + fixed up generics also updated angular-localForage due to a breaking change in the interface --- angular-localForage/angular-localForage.d.ts | 2 +- localForage/localForage-tests.ts | 39 +++++++++----------- localForage/localForage.d.ts | 33 +++++++++-------- 3 files changed, 37 insertions(+), 37 deletions(-) diff --git a/angular-localForage/angular-localForage.d.ts b/angular-localForage/angular-localForage.d.ts index 6186d79d3..a43a44945 100644 --- a/angular-localForage/angular-localForage.d.ts +++ b/angular-localForage/angular-localForage.d.ts @@ -23,7 +23,7 @@ declare module angular.localForage { interface ILocalForageService { setDriver(driver:string):angular.IPromise; - driver():lf.ILocalForage; + driver():lf.ILocalForage; setItem(key:string, value:any):angular.IPromise; setItem(keys:Array, values:Array):angular.IPromise; diff --git a/localForage/localForage-tests.ts b/localForage/localForage-tests.ts index 15638c1cb..a3cc0eb38 100644 --- a/localForage/localForage-tests.ts +++ b/localForage/localForage-tests.ts @@ -1,13 +1,6 @@ /// -declare var localForage: lf.ILocalForage; -declare var callback: lf.ICallback; -declare var iterateCallback: lf.IIterateCallback; -declare var errorCallback: lf.IErrorCallback; -declare var keyCallback: lf.IKeyCallback; -declare var keysCallback: lf.IKeysCallback; -declare var numberCallback: lf.INumberCallback; -declare var promise: lf.IPromise; +import * as localForage from "localforage"; () => { localForage.clear((err: any) => { @@ -40,9 +33,12 @@ declare var promise: lf.IPromise; var newStr: string = str }); - localForage.getItem("key").then((err: any, str: string) => { - var newError: any = err; - var newStr: string = str + localForage.getItem("key").then((value) => { + var newStr: string = value + }); + + localForage.getItem("keyNumber").then((value) => { + var newValue: number = value }); localForage.setItem("key", "value",(err: any, str: string) => { @@ -50,19 +46,20 @@ declare var promise: lf.IPromise; var newStr: string = str }); - localForage.setItem("key", "value").then((err: any, str: string) => { - var newError: any = err; - var newStr: string = str; + localForage.setItem("key", "value").then((value) => { + var v: string = value; + }); + + localForage.setItem("keyNumber", 1337).then((value) => { + var v: number = value; }); localForage.removeItem("key",(err: any) => { var newError: any = err; }); - - localForage.removeItem("key").then((err: any, str: string) => { - var newError: any = err; - var newStr: string = str - }); - - promise.then(callback); + + localForage.removeItem("key") + .then( () => { + + }); } diff --git a/localForage/localForage.d.ts b/localForage/localForage.d.ts index b5c40dd61..9800cec2f 100644 --- a/localForage/localForage.d.ts +++ b/localForage/localForage.d.ts @@ -3,20 +3,22 @@ // Definitions by: yuichi david pichsenmeister // Definitions: https://github.com/borisyankov/DefinitelyTyped +/// + declare module lf { - interface ILocalForage { + interface ILocalForage { /** * Removes every key from the database, returning it to a blank slate. */ - clear(callback: IErrorCallback): void + clear(callback: IErrorCallback): void; /** * Iterate over all value/key pairs in datastore. */ - iterate(iterateCallback: IIterateCallback): void + iterate(iterateCallback: IIterateCallback): void; /** * Get the name of a key based on its ID. */ - key(keyIndex: number, callback: IKeyCallback): void + key(keyIndex: number, callback: IKeyCallback): void; /** * Get the list of all keys in the datastore. */ @@ -24,23 +26,23 @@ declare module lf { /** * Gets the number of keys in the offline store (i.e. its “length”). */ - length(callback: INumberCallback): void + length(callback: INumberCallback): void; /** * Gets an item from the storage library and supplies the result to a callback. * If the key does not exist, getItem() will return null. */ - getItem(key: string, callback: ICallback): void - getItem(key: string): IPromise + getItem(key: string, callback: ICallback): void; + getItem(key: string): Promise; /** * Saves data to an offline store. */ - setItem(key: string, value: T, callback: ICallback): void - setItem(key: string, value: T): IPromise + setItem(key: string, value: T, callback: ICallback): void; + setItem(key: string, value: T): Promise; /** * Removes the value of a key from the offline store. */ - removeItem(key: string, callback: IErrorCallback): void - removeItem(key: string): IPromise + removeItem(key: string, callback: IErrorCallback): void; + removeItem(key: string): Promise; } interface ICallback { @@ -65,9 +67,10 @@ declare module lf { interface INumberCallback { (err: any, numberOfKeys: number): void - } + } +} - interface IPromise { - then(callback: ICallback): void - } +declare module 'localforage' { + var tmp: lf.ILocalForage; + export = tmp; } \ No newline at end of file From efa4f9d53222369df7eb2827dd6d63527bea05cd Mon Sep 17 00:00:00 2001 From: Stephen Lautier Date: Tue, 15 Sep 2015 00:42:46 +0200 Subject: [PATCH 02/43] included more definitions --- localForage/localForage-tests.ts | 22 ++++++++++++++++------ localForage/localForage.d.ts | 31 +++++++++++++++++++++++++++---- 2 files changed, 43 insertions(+), 10 deletions(-) diff --git a/localForage/localForage-tests.ts b/localForage/localForage-tests.ts index a3cc0eb38..ae1f03419 100644 --- a/localForage/localForage-tests.ts +++ b/localForage/localForage-tests.ts @@ -25,7 +25,7 @@ import * as localForage from "localforage"; localForage.keys((err: any, keys: Array) => { var newError: any = err; - var newArray: Array = keys; + var newArray: Array = keys; }); localForage.getItem("key",(err: any, str: string) => { @@ -35,7 +35,7 @@ import * as localForage from "localforage"; localForage.getItem("key").then((value) => { var newStr: string = value - }); + }); localForage.getItem("keyNumber").then((value) => { var newValue: number = value @@ -44,8 +44,8 @@ import * as localForage from "localforage"; localForage.setItem("key", "value",(err: any, str: string) => { var newError: any = err; var newStr: string = str - }); - + }); + localForage.setItem("key", "value").then((value) => { var v: string = value; }); @@ -54,12 +54,22 @@ import * as localForage from "localforage"; var v: number = value; }); - localForage.removeItem("key",(err: any) => { - var newError: any = err; + localForage.removeItem("key",(err: any) => { + var newError: any = err; }); localForage.removeItem("key") .then( () => { }); + + var config = localForage.default.config({ + name: "testyo", + driver: localForage.default.LOCALSTORAGE + }); + + var store = localForage.default.createInstance({ + name: "da instance", + driver: localForage.default.LOCALSTORAGE + }); } diff --git a/localForage/localForage.d.ts b/localForage/localForage.d.ts index 9800cec2f..cd1ee1d33 100644 --- a/localForage/localForage.d.ts +++ b/localForage/localForage.d.ts @@ -6,7 +6,9 @@ /// declare module lf { + interface ILocalForage { + default: ILocalForageStatic; /** * Removes every key from the database, returning it to a blank slate. */ @@ -45,6 +47,27 @@ declare module lf { removeItem(key: string): Promise; } + interface ILocalForageStatic { + INDEXEDDB: string; + LOCALSTORAGE: string; + WEBSQL: string; + + config(options?: ILocalForageConfig): boolean; + createInstance(options?: ILocalForageConfig): ILocalForage; + defineDriver(driverObject?: any): void; + setDriver(driver: string): void; + supports(driverName: string): boolean; + } + + interface ILocalForageConfig { + description?: string; + driver?: string; + name?: string; + size?: number; + storeName?: string; + version?: number; + } + interface ICallback { (err: any, value: T): void } @@ -67,10 +90,10 @@ declare module lf { interface INumberCallback { (err: any, numberOfKeys: number): void - } + } } -declare module 'localforage' { - var tmp: lf.ILocalForage; - export = tmp; +declare module "localforage" { + var tmp: lf.ILocalForage; + export = tmp; } \ No newline at end of file From 1f88c485c472c7addcf5d24f69b19a2c0ae6a54a Mon Sep 17 00:00:00 2001 From: Stephen Lautier Date: Tue, 15 Sep 2015 23:23:06 +0200 Subject: [PATCH 03/43] improved localforage to use default exports (the way it usually should be imported) --- localForage/localForage-tests.ts | 10 +++++----- localForage/localForage.d.ts | 16 ++++++++++++---- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/localForage/localForage-tests.ts b/localForage/localForage-tests.ts index ae1f03419..1ba6611d3 100644 --- a/localForage/localForage-tests.ts +++ b/localForage/localForage-tests.ts @@ -1,6 +1,6 @@ /// -import * as localForage from "localforage"; +import {default as localForage} from "localforage"; () => { localForage.clear((err: any) => { @@ -63,13 +63,13 @@ import * as localForage from "localforage"; }); - var config = localForage.default.config({ + var config = localForage.config({ name: "testyo", - driver: localForage.default.LOCALSTORAGE + driver: localForage.LOCALSTORAGE }); - var store = localForage.default.createInstance({ + var store = localForage.createInstance({ name: "da instance", - driver: localForage.default.LOCALSTORAGE + driver: localForage.LOCALSTORAGE }); } diff --git a/localForage/localForage.d.ts b/localForage/localForage.d.ts index cd1ee1d33..9adb9ca1d 100644 --- a/localForage/localForage.d.ts +++ b/localForage/localForage.d.ts @@ -7,8 +7,7 @@ declare module lf { - interface ILocalForage { - default: ILocalForageStatic; + interface ILocalForage extends ILocalForageStatic { /** * Removes every key from the database, returning it to a blank slate. */ @@ -52,9 +51,18 @@ declare module lf { LOCALSTORAGE: string; WEBSQL: string; + /** + * Set and persist localForage options. This must be called before any other calls to localForage are made, but can be called after localForage is loaded. + * If you set any config values with this method they will persist after driver changes, so you can call config() then setDriver() + * @param {ILocalForageConfig} options? + */ config(options?: ILocalForageConfig): boolean; createInstance(options?: ILocalForageConfig): ILocalForage; defineDriver(driverObject?: any): void; + /** + * Force usage of a particular driver or drivers, if available. + * @param {string} driver + */ setDriver(driver: string): void; supports(driverName: string): boolean; } @@ -94,6 +102,6 @@ declare module lf { } declare module "localforage" { - var tmp: lf.ILocalForage; - export = tmp; + var localforage: lf.ILocalForage; + export default localforage; } \ No newline at end of file From f0fee739c30aafa4a8cdfdd9ddf982d4ec72ba35 Mon Sep 17 00:00:00 2001 From: Stephen Lautier Date: Thu, 17 Sep 2015 00:23:45 +0200 Subject: [PATCH 04/43] merged conflicts taking theirs --- localForage/localForage-tests.ts | 46 +++----------------------------- 1 file changed, 4 insertions(+), 42 deletions(-) diff --git a/localForage/localForage-tests.ts b/localForage/localForage-tests.ts index ae6d49ae8..bb824b731 100644 --- a/localForage/localForage-tests.ts +++ b/localForage/localForage-tests.ts @@ -1,10 +1,6 @@ /// -<<<<<<< HEAD -import {default as localForage} from "localforage"; -======= declare var localForage: LocalForage; ->>>>>>> 5f480287834a2615274eea31574b713e64decf17 () => { localForage.clear((err: any) => { @@ -29,7 +25,7 @@ declare var localForage: LocalForage; localForage.keys((err: any, keys: Array) => { var newError: any = err; - var newArray: Array = keys; + var newArray: Array = keys; }); localForage.getItem("key",(err: any, str: string) => { @@ -37,57 +33,23 @@ declare var localForage: LocalForage; var newStr: string = str }); -<<<<<<< HEAD - localForage.getItem("key").then((value) => { - var newStr: string = value - }); - - localForage.getItem("keyNumber").then((value) => { - var newValue: number = value -======= localForage.getItem("key").then((str: string) => { var newStr: string = str; ->>>>>>> 5f480287834a2615274eea31574b713e64decf17 }); localForage.setItem("key", "value",(err: any, str: string) => { var newError: any = err; var newStr: string = str - }); - - localForage.setItem("key", "value").then((value) => { - var v: string = value; }); -<<<<<<< HEAD - localForage.setItem("keyNumber", 1337).then((value) => { - var v: number = value; -======= localForage.setItem("key", "value").then((str: string) => { var newStr: string = str; ->>>>>>> 5f480287834a2615274eea31574b713e64decf17 }); - localForage.removeItem("key",(err: any) => { - var newError: any = err; + localForage.removeItem("key",(err: any) => { + var newError: any = err; }); - - localForage.removeItem("key") - .then( () => { - - }); -<<<<<<< HEAD - var config = localForage.config({ - name: "testyo", - driver: localForage.LOCALSTORAGE - }); - - var store = localForage.createInstance({ - name: "da instance", - driver: localForage.LOCALSTORAGE -======= localForage.removeItem("key").then(() => { ->>>>>>> 5f480287834a2615274eea31574b713e64decf17 }); -} +} \ No newline at end of file From c192586e9e3c5180e271dbd21e7295aaf1dcdbb6 Mon Sep 17 00:00:00 2001 From: Stephen Lautier Date: Thu, 17 Sep 2015 00:43:21 +0200 Subject: [PATCH 05/43] changes: - added default export for localforage module (for style es6 imports) - added createInstance method - some minor doc - changed driver to accept also a string (to use their property e.g. localforage.LOCALSTORAGE - added some minor tests --- localForage/localForage-tests.ts | 10 ++++++++++ localForage/localForage.d.ts | 19 +++++++++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/localForage/localForage-tests.ts b/localForage/localForage-tests.ts index bb824b731..6f162e8c4 100644 --- a/localForage/localForage-tests.ts +++ b/localForage/localForage-tests.ts @@ -52,4 +52,14 @@ declare var localForage: LocalForage; localForage.removeItem("key").then(() => { }); + + var config = localForage.config({ + name: "testyo", + driver: localForage.LOCALSTORAGE + }); + + var store = localForage.createInstance({ + name: "da instance", + driver: localForage.LOCALSTORAGE + }); } \ No newline at end of file diff --git a/localForage/localForage.d.ts b/localForage/localForage.d.ts index d169d01e3..cd12bb4f3 100644 --- a/localForage/localForage.d.ts +++ b/localForage/localForage.d.ts @@ -6,7 +6,7 @@ /// interface LocalForageOptions { - driver?: LocalForageDriver | LocalForageDriver[]; + driver?: string | LocalForageDriver | LocalForageDriver[]; name?: string; @@ -46,9 +46,19 @@ interface LocalForage { WEBSQL: string; INDEXEDDB: string; - config(options: LocalForageOptions): void; + /** + * Set and persist localForage options. This must be called before any other calls to localForage are made, but can be called after localForage is loaded. + * If you set any config values with this method they will persist after driver changes, so you can call config() then setDriver() + * @param {ILocalForageConfig} options? + */ + config(options: LocalForageOptions): boolean; + createInstance(options: LocalForageOptions): LocalForage; driver(): LocalForageDriver; + /** + * Force usage of a particular driver or drivers, if available. + * @param {string} driver + */ setDriver(driver: string | string[]): Promise; setDriver(driver: string | string[], callback: () => void, errorCallback: (error: any) => void): void; defineDriver(driver: LocalForageDriver): Promise; @@ -79,3 +89,8 @@ interface LocalForage { iterate(iteratee: (value: any, key: string, iterationNumber: number) => any, callback: (err: any, result: any) => void): void; } + +declare module "localforage" { + var localforage: LocalForage; + export default localforage; +} \ No newline at end of file From f58b6750a6ff8809bb3ebd0db065d32080679520 Mon Sep 17 00:00:00 2001 From: Stephanie Yu Date: Tue, 6 Oct 2015 11:48:07 -0400 Subject: [PATCH 06/43] Sigma.JS: Added labels definition to svg edges --- sigmajs/sigmajs-tests.ts | 4 ++++ sigmajs/sigmajs.d.ts | 9 ++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/sigmajs/sigmajs-tests.ts b/sigmajs/sigmajs-tests.ts index f28a9395b..1fdcdb27e 100644 --- a/sigmajs/sigmajs-tests.ts +++ b/sigmajs/sigmajs-tests.ts @@ -26,6 +26,10 @@ module SigmaJsTests { sigma.canvas.edges['def'] = function() {}; sigma.svg.nodes['def'] = {create: (obj: SigmaJs.Node) => { return new Element(); }, update: (obj: SigmaJs.Node) => { return; }}; + sigma.svg.edges['def'] = {create: (obj: SigmaJs.Edge) => { return new Element(); }, + update: (obj: SigmaJs.Edge) => { return; }}; + sigma.svg.edges.labels['def'] = {create: (obj: SigmaJs.Edge) => { return new Element(); }, + update: (obj: SigmaJs.Edge) => { return; }}; var N = 100; var E = 500; diff --git a/sigmajs/sigmajs.d.ts b/sigmajs/sigmajs.d.ts index d1c19730c..70bd2ff86 100644 --- a/sigmajs/sigmajs.d.ts +++ b/sigmajs/sigmajs.d.ts @@ -287,11 +287,18 @@ declare module SigmaJs{ } interface SVG { - edges: {[renderType: string]: SVGObject}; + edges: { + labels: SVGEdgeLabels; + [renderType: string]: SVGObject | SVGEdgeLabels; + }; labels: {[renderType: string]: SVGObject}; nodes: {[renderType: string]: SVGObject}; } + interface SVGEdgeLabels { + [renderType: string]: SVGObject; + } + interface SVGObject { create: (object: T, ...a:any[]) => Element; update: (object: T, ...a:any[]) => void; From b7d666b974838819501f9e84e67b652955b477c5 Mon Sep 17 00:00:00 2001 From: Eugene Galaktionov Date: Wed, 7 Oct 2015 11:25:49 -0600 Subject: [PATCH 07/43] Adding browser support --- long/long.d.ts | 125 +++++++++++++++++++++++++------------------------ 1 file changed, 64 insertions(+), 61 deletions(-) diff --git a/long/long.d.ts b/long/long.d.ts index 5c3704a81..32d773b9d 100644 --- a/long/long.d.ts +++ b/long/long.d.ts @@ -3,70 +3,73 @@ // Definitions by: Peter Kooijmans // Definitions: https://github.com/borisyankov/DefinitelyTyped -declare module "long" { +declare module dcodeIO { + interface LongStatic { + new (low: number, high?: number, unsigned?: boolean): Long; - module Long { - export var MAX_UNSIGNED_VALUE: Long; - export var MAX_VALUE: Long; - export var MIN_VALUE: Long; - export var NEG_ONE: Long; - export var ONE: Long; - export var UONE: Long; - export var UZERO: Long; - export var ZERO: Long; + MAX_UNSIGNED_VALUE: Long; + MAX_VALUE: Long; + MIN_VALUE: Long; + NEG_ONE: Long; + ONE: Long; + UONE: Long; + UZERO: Long; + ZERO: Long; - export function fromBits(lowBits: number, highBits: number, unsigned?: boolean): Long; - export function fromInt(value: number, unsigned?: boolean): Long; - export function fromNumber(value: number, unsigned?: boolean): Long; - export function fromString(str: string, unsigned?: boolean | number, radix?: number): Long; - export function fromValue(val: Long | number | string): Long; + fromBits(lowBits: number, highBits: number, unsigned?: boolean): Long; + fromInt(value: number, unsigned?: boolean): Long; + fromNumber(value: number, unsigned?: boolean): Long; + fromString(str: string, unsigned?: boolean | number, radix?: number): Long; + fromValue(val: Long | number | string): Long; + isLong(obj: any): boolean; + } - export function isLong(obj: any): boolean; - } + interface Long { + high: number; + low: number; + unsigned: boolean; - class Long { - high: number; - low: number; - unsigned :boolean; + add(other: Long | number | string): Long; + and(other: Long | number | string): Long; + compare(other: Long | number | string): number; + div(divisor: Long | number | string): Long; + equals(other: Long | number | string): boolean; + getHighBits(): number; + getHighBitsUnsigned(): number; + getLowBits(): number; + getLowBitsUnsigned(): number; + getNumBitsAbs(): number; + greaterThan(other: Long | number | string): boolean; + greaterThanOrEqual(other: Long | number | string): boolean; + isEven(): boolean; + isNegative(): boolean; + isOdd(): boolean; + isPositive(): boolean; + isZero(): boolean; + lessThan(other: Long | number | string): boolean; + lessThanOrEqual(other: Long | number | string): boolean; + modulo(divisor: Long | number | string): Long; + multiply(multiplier: Long | number | string): Long; + negate(): Long; + not(): Long; + notEquals(other: Long | number | string): boolean; + or(other: Long | number | string): Long; + shiftLeft(numBits: number | Long): Long; + shiftRight(numBits: number | Long): Long; + shiftRightUnsigned(numBits: number | Long): Long; + subtract(other: Long | number | string): Long; + toInt(): number; + toNumber(): number; + toSigned(): Long; + toString(radix?: number): string; + toUnsigned(): Long; + xor(other: Long | number | string): Long; + } - constructor(low: number, high?: number, unsigned?:boolean); - - add(other: Long | number | string): Long; - and(other: Long | number | string): Long; - compare(other: Long | number | string): number; - div(divisor: Long | number | string): Long; - equals(other: Long | number | string): boolean; - getHighBits(): number; - getHighBitsUnsigned(): number; - getLowBits(): number; - getLowBitsUnsigned(): number; - getNumBitsAbs(): number; - greaterThan(other: Long | number | string): boolean; - greaterThanOrEqual(other: Long | number | string): boolean; - isEven(): boolean; - isNegative(): boolean; - isOdd(): boolean; - isPositive(): boolean; - isZero(): boolean; - lessThan(other: Long | number | string): boolean; - lessThanOrEqual(other: Long | number | string): boolean; - modulo(divisor: Long | number | string): Long; - multiply(multiplier: Long | number | string): Long; - negate(): Long; - not(): Long; - notEquals(other: Long | number | string): boolean; - or(other: Long | number | string): Long; - shiftLeft(numBits: number | Long): Long; - shiftRight(numBits: number | Long): Long; - shiftRightUnsigned(numBits: number | Long): Long; - subtract(other: Long | number | string): Long; - toInt(): number; - toNumber(): number; - toSigned(): Long; - toString(radix?: number): string; - toUnsigned(): Long; - xor(other: Long | number | string): Long; - } - - export = Long; + export var Long: LongStatic; } + +declare module "long" { + var Long: dcodeIO.LongStatic; + export = Long; +} \ No newline at end of file From 043ebddf44fffb68c4315b77a1a116a69e8dd556 Mon Sep 17 00:00:00 2001 From: Eugene Galaktionov Date: Wed, 7 Oct 2015 11:59:56 -0600 Subject: [PATCH 08/43] Adding browser support --- long/long-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/long/long-tests.ts b/long/long-tests.ts index 928cc9453..f70835f66 100644 --- a/long/long-tests.ts +++ b/long/long-tests.ts @@ -2,7 +2,7 @@ import Long = require("long"); -var val: Long; +var val: dcodeIO.Long; var n: number = 42; var b: boolean = true; var s: string = "1337"; From 4d7118424756fb8b9cee847b6afb7efab4357857 Mon Sep 17 00:00:00 2001 From: Ashwin Date: Wed, 7 Oct 2015 11:01:20 -0700 Subject: [PATCH 09/43] Added missing options for infinite scroll infiniteScrollRowsFromEnd, infiniteScrollUp and infiniteScrollDown were missing in IGridOptions. These were added. --- ui-grid/ui-grid.d.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/ui-grid/ui-grid.d.ts b/ui-grid/ui-grid.d.ts index ece964280..fde4ee86a 100644 --- a/ui-grid/ui-grid.d.ts +++ b/ui-grid/ui-grid.d.ts @@ -2087,6 +2087,25 @@ declare module uiGrid { * @default true */ enableInfiniteScroll?: boolean; + /** + * Number of rows from the end of the dataset + * at which infinite scroll will trigger a request + * for more data + * @default 20 + */ + infiniteScrollRowsFromEnd?: number; + /** + * Inform the grid of whether there are rows + * to load when scrolling up + * @default false + */ + infiniteScrollUp?: boolean, + /** + * Inform the grid of whether there are rows + * to load scrolling down + * @default true + */ + infiniteScrollDown?: boolean, } /** From f5cb4a0e06cd2c621648dcd948ba792d13abd355 Mon Sep 17 00:00:00 2001 From: ashwin027 Date: Wed, 7 Oct 2015 19:01:21 -0700 Subject: [PATCH 10/43] Added missing options Added option columns to IGridInstance --- ui-grid/ui-grid.d.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ui-grid/ui-grid.d.ts b/ui-grid/ui-grid.d.ts index 481326b13..870a6f03d 100644 --- a/ui-grid/ui-grid.d.ts +++ b/ui-grid/ui-grid.d.ts @@ -483,6 +483,10 @@ declare module uiGrid { * use gridOptions.appScopeProvider to override the default assignment of $scope.$parent with any reference */ appScope?: ng.IScope; + /** + * returns an array of columns in the grid + */ + columns: Array; /** * returns the total column footer height */ From ded3d2beacbe1fd5e47e58d5c51c66093235d11d Mon Sep 17 00:00:00 2001 From: Niklas Mollenhauer Date: Fri, 9 Oct 2015 07:23:10 +0200 Subject: [PATCH 11/43] Move 0.2.0 to own definition files --- easy-table/easy-table-0.2.0-tests.ts | 15 ++++++++++ easy-table/easy-table-0.2.0.d.ts | 41 ++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 easy-table/easy-table-0.2.0-tests.ts create mode 100644 easy-table/easy-table-0.2.0.d.ts diff --git a/easy-table/easy-table-0.2.0-tests.ts b/easy-table/easy-table-0.2.0-tests.ts new file mode 100644 index 000000000..732426064 --- /dev/null +++ b/easy-table/easy-table-0.2.0-tests.ts @@ -0,0 +1,15 @@ +/// + +import EasyTable = require('easy-table'); + +var table = new EasyTable(); + +table.cell('aa', 1); +table.cell('bb',1); +table.newRow(); + +table.cell('aa', 1); +table.cell('bb',1); + +table.print(); + diff --git a/easy-table/easy-table-0.2.0.d.ts b/easy-table/easy-table-0.2.0.d.ts new file mode 100644 index 000000000..912b089ce --- /dev/null +++ b/easy-table/easy-table-0.2.0.d.ts @@ -0,0 +1,41 @@ +// Type definitions for easy-table 0.2.0 +// Project: https://github.com/eldargab/easy-table +// Definitions by: Bart van der Schoor +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module "easy-table" { + class EasyTable { + constructor(); + + cell(label: string, value: any, printer?: EasyTable.CellPrinter, width?: number):void; + newRow(): void; + toString(): string; + printTransposed(): string; + print(): string; + sort(fields: string): void; + sort(comparer: (a: any, b: any) => number): void; + total(label: string, accumulator: EasyTable.Accumulator, totalPrinter: EasyTable.CellPrinter): void; + } + + module EasyTable { + function printArray(array: any[], cellPrinter?: CellPrinter, tablePrinter?: Printer): string; + function printObject(object: any, cellPrinter?: CellPrinter, tablePrinter?: Printer): string; + + //printer helpers + function Number(length: number): CellPrinter; + function RightPadder(char: string): CellPrinter; + function LeftPadder(char: string): CellPrinter; + + interface CellPrinter extends Function { + (obj: any, cell: (label: string, value: any, width?: number) => void):string; + } + interface Printer extends Function { + (table: EasyTable):string; + } + interface Accumulator extends Function { + (sum: number, val: number, index: number, length: number):number; + } + } + + export = EasyTable; +} From de3902042aee528c2c711e78d798e8664b5d26b5 Mon Sep 17 00:00:00 2001 From: Niklas Mollenhauer Date: Fri, 9 Oct 2015 07:23:46 +0200 Subject: [PATCH 12/43] Add rewritten definitions for 1.0.0 --- easy-table/easy-table-tests.ts | 108 +++++++++++++-- easy-table/easy-table.d.ts | 238 +++++++++++++++++++++++++++++---- 2 files changed, 309 insertions(+), 37 deletions(-) diff --git a/easy-table/easy-table-tests.ts b/easy-table/easy-table-tests.ts index 732426064..56fdb7e3b 100644 --- a/easy-table/easy-table-tests.ts +++ b/easy-table/easy-table-tests.ts @@ -1,15 +1,105 @@ -/// +/// -import EasyTable = require('easy-table'); +//import * as Table from "easy-table"; +//import * as Table from "easy-table"; -var table = new EasyTable(); +import Table = require("easy-table"); +let data = [ + { id: 123123, desc: 'Something awesome', price: 1000.00 }, + { id: 245452, desc: 'Very interesting book', price: 11.45 }, + { id: 232323, desc: 'Yet another product', price: 555.55 } +]; -table.cell('aa', 1); -table.cell('bb',1); -table.newRow(); +interface IData { + id: number; + desc: string; + price: number; +} -table.cell('aa', 1); -table.cell('bb',1); +function sample_test() { + let t = new Table(); + data.forEach(function(product) { + t.cell('Product Id', product.id); + t.cell('Description', product.desc); + t.cell('Price, USD', product.price, Table.number(2)); + t.newRow(); + }); + console.log(t.toString()); +} -table.print(); +function static_print() { + console.log(Table.print(data)); +} +function currency(val: number, width?: number) { + var str = val.toFixed(2); + return width ? str : Table.padLeft(str, width); +} + +function sample_2() { + Table.print(data, { + desc: { name: 'description' }, + price: { printer: Table.number(2) } + }); +} + +function sample_3() { + Table.print(data, function(item, cell) { + cell('Product id', item.id) + cell('Price, USD', item.price) + }, function(table) { + return table.print() + }) +} + +function sample_4() { + Table.print(data[0]); +} + +function sort_strings() { + let t = new Table(); + t.sort(['Price, USD|des']) // will sort in descending order + t.sort(['Price, USD|asc']) // will sort in ascending order + t.sort(['Price, USD']) // sorts in ascending order by default +} + +function totalling() { + let t = new Table(); + t.total('Price, USD'); + t.total('Price, USD', { + printer: Table.aggr.printer('Avg: ', currency), + reduce: Table.aggr.avg, + init: 0 + }) + + // or alternatively + t.total('Price, USD', { + printer: (val, width) => { + return Table.padLeft('Avg: ' + currency(val), width); + }, + reduce: (acc: number, val: number, idx: number, len: number) => { + acc = acc + val; + return idx + 1 == len ? acc / len : acc; + } + }); +} + +function other_samples() { + var t = new Table(); + + data.forEach(product => { + t.cell('Product Id', product.id) + t.cell('Description', product.desc) + t.cell('Price, USD', product.price, Table.number(2)) + t.newRow() + }) + + t.sort(['Price, USD']) + t.total('Price, USD', { + printer: Table.number(2) + }) + + t.log() + Table.log(data, { price: { printer: Table.number(2) } }) + Table.log(data[0]) +} diff --git a/easy-table/easy-table.d.ts b/easy-table/easy-table.d.ts index 912b089ce..9995585fe 100644 --- a/easy-table/easy-table.d.ts +++ b/easy-table/easy-table.d.ts @@ -1,40 +1,222 @@ -// Type definitions for easy-table 0.2.0 +// Type definitions for easy-table // Project: https://github.com/eldargab/easy-table -// Definitions by: Bart van der Schoor +// Definitions by: Niklas Mollenhauer // Definitions: https://github.com/borisyankov/DefinitelyTyped -declare module "easy-table" { +declare module "easy-table" +{ class EasyTable { - constructor(); - cell(label: string, value: any, printer?: EasyTable.CellPrinter, width?: number):void; - newRow(): void; - toString(): string; - printTransposed(): string; - print(): string; - sort(fields: string): void; - sort(comparer: (a: any, b: any) => number): void; - total(label: string, accumulator: EasyTable.Accumulator, totalPrinter: EasyTable.CellPrinter): void; + /** + * String to separate columns + */ + public separator: string; + + /** + * Default printer + */ + public static string(value: any): string; + + /** + * Create a printer which right aligns the content by padding with `ch` on the left + * + * @param {String} ch + * @returns {Function} + */ + public static leftPadder(ch: number): CellPrinter; + + public static padLeft: CellPrinter; + + /** + * Create a printer which pads with `ch` on the right + * + * @param {String} ch + * @returns {Function} + */ + public static rightPadder(ch: number): CellPrinter; + + public static padRight: CellPrinter; + + /** + * Create a printer for numbers + * + * Will do right alignment and optionally fix the number of digits after decimal point + * + * @param {Number} [digits] - Number of digits for fixpoint notation + * @returns {Function} + */ + public static number(digits?: number): CellPrinter; + + public constructor(); + + /** + * Push the current row to the table and start a new one + * + * @returns {Table} `this` + */ + public newRow(): EasyTable; + + /** + * Write cell in the current row + * + * @param {String} col - Column name + * @param {Any} val - Cell value + * @param {Function} [printer] - Printer function to format the value + * @returns {Table} `this` + */ + public cell(col: string, val: T, printer?: CellPrinter): EasyTable; + + /** + * Get list of columns in printing order + * + * @returns {string[]} + */ + public columns(): string[]; + + /** + * Format just rows, i.e. print the table without headers and totals + * + * @returns {String} String representaion of the table + */ + public print(): string; + + /** + * Format the table + * + * @returns {String} + */ + public toString(): string; + + /** + * Push delimeter row to the table (with each cell filled with dashs during printing) + * + * @param {String[]} [cols] + * @returns {Table} `this` + */ + public pushDelimeter(cols?: string[]): EasyTable; + + /** + * Compute all totals and yield the results to `cb` + * + * @param {Function} cb - Callback function with signature `(column, value, printer)` + */ + public forEachTotal(cb: (column: string, value: T, printer: CellPrinter) => void): void; + + /** + * Format the table so that each row represents column and each column represents row + * + * @param {IPrintColumnOptions} [opts] + * @returns {String} + */ + public printTransposed(opts?: IPrintColumnOptions): string; + + /** + * Sort the table + * + * @param {Function|string[]} [cmp] - Either compare function or a list of columns to sort on + * @returns {Table} `this` + */ + public sort(cmp?: string[]): EasyTable; + /** + * Sort the table + * + * @param {Function|string[]} [cmp] - Either compare function or a list of columns to sort on + * @returns {Table} `this` + */ + public sort(cmp?: CompareFunction): EasyTable; + + /** + * Add a total for the column + * + * @param {String} col - column name + * @param {Object} [opts] + * @returns {Table} `this` + */ + public total(col: string, opts?: ITotalOptions): EasyTable; + /** + * Predefined helpers for totals + */ + public static aggr: IAggregators; + + /** + * Print the array or object + * + * @param {Array|Object} obj - Object to print + * @param {Function|Object} [format] - Format options + * @param {Function} [cb] - Table post processing and formating + * @returns {String} + */ + public static print(obj: T | T[], format?: FormatFunction | IFormatObject, cb?: TablePostProcessing): string; + + /** + * Same as `Table.print()` but yields the result to `console.log()` + */ + public static log(obj: T | T[], format?: FormatFunction | IFormatObject, cb?: TablePostProcessing): void; + /** + * Same as `.toString()` but yields the result to `console.log()` + */ + public log(): void; } - module EasyTable { - function printArray(array: any[], cellPrinter?: CellPrinter, tablePrinter?: Printer): string; - function printObject(object: any, cellPrinter?: CellPrinter, tablePrinter?: Printer): string; + type CellPrinter = (val: T, width: number) => string; + type CompareFunction = (a: T, b: T) => number; + type ReduceFunction = (acc: T, val: T, idx: number, length: number) => T; + type FormatFunction = (obj: T, cell: (name: string, val: any) => void) => void; + type TablePostProcessing = (result: EasyTable) => string; - //printer helpers - function Number(length: number): CellPrinter; - function RightPadder(char: string): CellPrinter; - function LeftPadder(char: string): CellPrinter; + interface IPrintColumnOptions { + /** + * Column separation string + */ + separator?: string; + /** + * Printer to format column names + */ + namePrinter?: CellPrinter; + } - interface CellPrinter extends Function { - (obj: any, cell: (label: string, value: any, width?: number) => void):string; - } - interface Printer extends Function { - (table: EasyTable):string; - } - interface Accumulator extends Function { - (sum: number, val: number, index: number, length: number):number; - } + interface IAggregators { + /** + * Create a printer which formats the value with `printer`, + * adds the `prefix` to it and right aligns the whole thing + * + * @param {String} prefix + * @param {Function} printer + * @returns {printer} + */ + printer(prefix: string, printer: CellPrinter): CellPrinter; + /** + * Sum reduction + */ + sum: any; + /** + * Average reduction + */ + avg: any; + } + + interface ITotalOptions { + /** + * reduce(acc, val, idx, length) function to compute the total value + */ + reduce?: ReduceFunction; + /** + * Printer to format the total cell + */ + printer?: CellPrinter; + /** + * Initial value for reduction + */ + init?: T; + } + + interface IFormatObject { + [key: string]: IColumnFormat; + } + + interface IColumnFormat { + name?: string; + printer?: CellPrinter } export = EasyTable; From 7148685570bd72ea373c7b7f6ec75d67509fa4af Mon Sep 17 00:00:00 2001 From: Niklas Mollenhauer Date: Fri, 9 Oct 2015 07:32:32 +0200 Subject: [PATCH 13/43] Remove comments an new line --- easy-table/easy-table-0.2.0-tests.ts | 1 - easy-table/easy-table-tests.ts | 4 +--- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/easy-table/easy-table-0.2.0-tests.ts b/easy-table/easy-table-0.2.0-tests.ts index 732426064..93a4516bf 100644 --- a/easy-table/easy-table-0.2.0-tests.ts +++ b/easy-table/easy-table-0.2.0-tests.ts @@ -12,4 +12,3 @@ table.cell('aa', 1); table.cell('bb',1); table.print(); - diff --git a/easy-table/easy-table-tests.ts b/easy-table/easy-table-tests.ts index 56fdb7e3b..62bd78008 100644 --- a/easy-table/easy-table-tests.ts +++ b/easy-table/easy-table-tests.ts @@ -1,9 +1,7 @@ /// -//import * as Table from "easy-table"; -//import * as Table from "easy-table"; - import Table = require("easy-table"); + let data = [ { id: 123123, desc: 'Something awesome', price: 1000.00 }, { id: 245452, desc: 'Very interesting book', price: 11.45 }, From dc377a32e24c06f409516e8f2da3e3f54020689f Mon Sep 17 00:00:00 2001 From: Stefan Profanter Date: Fri, 9 Oct 2015 18:10:26 +0200 Subject: [PATCH 14/43] Added roslibjs definition --- roslibjs/roslibjs-tests.ts | 13 +++++++++++++ roslibjs/roslibjs.d.ts | 24 ++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 roslibjs/roslibjs-tests.ts create mode 100644 roslibjs/roslibjs.d.ts diff --git a/roslibjs/roslibjs-tests.ts b/roslibjs/roslibjs-tests.ts new file mode 100644 index 000000000..607973443 --- /dev/null +++ b/roslibjs/roslibjs-tests.ts @@ -0,0 +1,13 @@ +/// + +var ros = new ROSLIB.Ros({url: "http://localhost:9090"}); + +ros.on('error', function(event) { + //do nothing +}); + +var service = new ROSLIB.Service({ + ros: ros, + name: '/service_name', + serviceType: 'service_type' +}); \ No newline at end of file diff --git a/roslibjs/roslibjs.d.ts b/roslibjs/roslibjs.d.ts new file mode 100644 index 000000000..4614deb92 --- /dev/null +++ b/roslibjs/roslibjs.d.ts @@ -0,0 +1,24 @@ +// Type definitions for roslib.js +// Project: http://wiki.ros.org/roslibjs +// Definitions by: Stefan Profanter +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module ROSLIB { + export class Ros { + constructor(data: { + url: string + }); + + on(eventName: string, callback: (event: any) => void); + connect(url: string); + } + + + export class Service { + constructor(data: { + ros: Ros, + name: string, + serviceType: string + }); + } +} \ No newline at end of file From 4863cc74e8cf6b1e758c922106cb5dbec9417927 Mon Sep 17 00:00:00 2001 From: Stefan Profanter Date: Fri, 9 Oct 2015 18:13:50 +0200 Subject: [PATCH 15/43] Fixed error --- roslibjs/roslibjs.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/roslibjs/roslibjs.d.ts b/roslibjs/roslibjs.d.ts index 4614deb92..667a37983 100644 --- a/roslibjs/roslibjs.d.ts +++ b/roslibjs/roslibjs.d.ts @@ -9,8 +9,8 @@ declare module ROSLIB { url: string }); - on(eventName: string, callback: (event: any) => void); - connect(url: string); + on(eventName: string, callback: (event: any) => void) : void; + connect(url: string) : void; } @@ -21,4 +21,4 @@ declare module ROSLIB { serviceType: string }); } -} \ No newline at end of file +} From 3c54589359fb6ae743b8f2362aec44660f89d755 Mon Sep 17 00:00:00 2001 From: Stefan Profanter Date: Mon, 12 Oct 2015 18:24:58 +0200 Subject: [PATCH 16/43] Renamed to roslib --- roslibjs/roslibjs-tests.ts => roslib/roslib-tests.ts | 0 roslibjs/roslibjs.d.ts => roslib/roslib.d.ts | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename roslibjs/roslibjs-tests.ts => roslib/roslib-tests.ts (100%) rename roslibjs/roslibjs.d.ts => roslib/roslib.d.ts (100%) diff --git a/roslibjs/roslibjs-tests.ts b/roslib/roslib-tests.ts similarity index 100% rename from roslibjs/roslibjs-tests.ts rename to roslib/roslib-tests.ts diff --git a/roslibjs/roslibjs.d.ts b/roslib/roslib.d.ts similarity index 100% rename from roslibjs/roslibjs.d.ts rename to roslib/roslib.d.ts From a5496bc364b7fed8879dca625127cdab631d70c1 Mon Sep 17 00:00:00 2001 From: Niklas Mollenhauer Date: Mon, 12 Oct 2015 20:21:22 +0200 Subject: [PATCH 17/43] Remove I prefix from interface names --- easy-table/easy-table-tests.ts | 4 ++-- easy-table/easy-table.d.ts | 22 +++++++++++----------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/easy-table/easy-table-tests.ts b/easy-table/easy-table-tests.ts index 62bd78008..911031d90 100644 --- a/easy-table/easy-table-tests.ts +++ b/easy-table/easy-table-tests.ts @@ -8,7 +8,7 @@ let data = [ { id: 232323, desc: 'Yet another product', price: 555.55 } ]; -interface IData { +interface Data { id: number; desc: string; price: number; @@ -35,7 +35,7 @@ function currency(val: number, width?: number) { } function sample_2() { - Table.print(data, { + Table.print(data, { desc: { name: 'description' }, price: { printer: Table.number(2) } }); diff --git a/easy-table/easy-table.d.ts b/easy-table/easy-table.d.ts index 9995585fe..e06cfdd27 100644 --- a/easy-table/easy-table.d.ts +++ b/easy-table/easy-table.d.ts @@ -108,7 +108,7 @@ declare module "easy-table" * @param {IPrintColumnOptions} [opts] * @returns {String} */ - public printTransposed(opts?: IPrintColumnOptions): string; + public printTransposed(opts?: PrintColumnOptions): string; /** * Sort the table @@ -132,11 +132,11 @@ declare module "easy-table" * @param {Object} [opts] * @returns {Table} `this` */ - public total(col: string, opts?: ITotalOptions): EasyTable; + public total(col: string, opts?: TotalOptions): EasyTable; /** * Predefined helpers for totals */ - public static aggr: IAggregators; + public static aggr: Aggregators; /** * Print the array or object @@ -146,12 +146,12 @@ declare module "easy-table" * @param {Function} [cb] - Table post processing and formating * @returns {String} */ - public static print(obj: T | T[], format?: FormatFunction | IFormatObject, cb?: TablePostProcessing): string; + public static print(obj: T | T[], format?: FormatFunction | FormatObject, cb?: TablePostProcessing): string; /** * Same as `Table.print()` but yields the result to `console.log()` */ - public static log(obj: T | T[], format?: FormatFunction | IFormatObject, cb?: TablePostProcessing): void; + public static log(obj: T | T[], format?: FormatFunction | FormatObject, cb?: TablePostProcessing): void; /** * Same as `.toString()` but yields the result to `console.log()` */ @@ -164,7 +164,7 @@ declare module "easy-table" type FormatFunction = (obj: T, cell: (name: string, val: any) => void) => void; type TablePostProcessing = (result: EasyTable) => string; - interface IPrintColumnOptions { + interface PrintColumnOptions { /** * Column separation string */ @@ -175,7 +175,7 @@ declare module "easy-table" namePrinter?: CellPrinter; } - interface IAggregators { + interface Aggregators { /** * Create a printer which formats the value with `printer`, * adds the `prefix` to it and right aligns the whole thing @@ -195,7 +195,7 @@ declare module "easy-table" avg: any; } - interface ITotalOptions { + interface TotalOptions { /** * reduce(acc, val, idx, length) function to compute the total value */ @@ -210,11 +210,11 @@ declare module "easy-table" init?: T; } - interface IFormatObject { - [key: string]: IColumnFormat; + interface FormatObject { + [key: string]: ColumnFormat; } - interface IColumnFormat { + interface ColumnFormat { name?: string; printer?: CellPrinter } From cbdd8de63d75319258e67c017776505322e26d34 Mon Sep 17 00:00:00 2001 From: Stefan Profanter Date: Mon, 12 Oct 2015 22:04:21 +0200 Subject: [PATCH 18/43] Fixed travis build --- roslib/roslib-tests.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/roslib/roslib-tests.ts b/roslib/roslib-tests.ts index 607973443..c209b4a0c 100644 --- a/roslib/roslib-tests.ts +++ b/roslib/roslib-tests.ts @@ -1,4 +1,4 @@ -/// +/// var ros = new ROSLIB.Ros({url: "http://localhost:9090"}); @@ -10,4 +10,4 @@ var service = new ROSLIB.Service({ ros: ros, name: '/service_name', serviceType: 'service_type' -}); \ No newline at end of file +}); From 1ece0d3a3e882bd269b4339ffda445e76528831a Mon Sep 17 00:00:00 2001 From: Ashwin Date: Mon, 12 Oct 2015 13:51:51 -0700 Subject: [PATCH 19/43] Moved options to global IGridoptions Moved options infiniteScrollRowsFromEnd, infiniteScrollUp and infiniteScrollDown into the global Igridoptions. --- ui-grid/ui-grid.d.ts | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/ui-grid/ui-grid.d.ts b/ui-grid/ui-grid.d.ts index fde4ee86a..bf7f1f009 100644 --- a/ui-grid/ui-grid.d.ts +++ b/ui-grid/ui-grid.d.ts @@ -713,6 +713,25 @@ declare module uiGrid { * @default 4 */ horizontalScrollThreshold?: number; + /** + * Number of rows from the end of the dataset + * at which infinite scroll will trigger a request + * for more data + * @default 20 + */ + infiniteScrollRowsFromEnd?: number; + /** + * Inform the grid of whether there are rows + * to load when scrolling up + * @default false + */ + infiniteScrollUp?: boolean, + /** + * Inform the grid of whether there are rows + * to load scrolling down + * @default true + */ + infiniteScrollDown?: boolean, /** * Defaults to 200 * @default 200 @@ -2087,25 +2106,6 @@ declare module uiGrid { * @default true */ enableInfiniteScroll?: boolean; - /** - * Number of rows from the end of the dataset - * at which infinite scroll will trigger a request - * for more data - * @default 20 - */ - infiniteScrollRowsFromEnd?: number; - /** - * Inform the grid of whether there are rows - * to load when scrolling up - * @default false - */ - infiniteScrollUp?: boolean, - /** - * Inform the grid of whether there are rows - * to load scrolling down - * @default true - */ - infiniteScrollDown?: boolean, } /** From fcfb2291629c0405074626b69e9066a3202327b9 Mon Sep 17 00:00:00 2001 From: Noah Chen Date: Mon, 12 Oct 2015 17:16:09 -0400 Subject: [PATCH 20/43] d3.geom.quadtree(..) should accept 4 arguments --- d3/d3-tests.ts | 4 ++-- d3/d3.d.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/d3/d3-tests.ts b/d3/d3-tests.ts index 98888dde7..f4efa75d4 100644 --- a/d3/d3-tests.ts +++ b/d3/d3-tests.ts @@ -1450,7 +1450,7 @@ function quadtree() { // Collapse the quadtree into an array of rectangles. function nodes(quadtree: d3.geom.quadtree.Quadtree<[number, number]>) { var nodes: Array<{x: number; y: number; width: number; height: number}> = []; - quadtree.visit(function (node, x1, y1, x2, y2) { + quadtree.visit(function (node: d3.geom.quadtree.Node<[number, number]>, x1: number, y1: number, x2:number, y2: number) { nodes.push({ x: x1, y: y1, width: x2 - x1, height: y2 - y1 }); } ); return nodes; @@ -1458,7 +1458,7 @@ function quadtree() { // Find the nodes within the specified rectangle. function search(quadtree: d3.geom.quadtree.Quadtree<{ scanned?: boolean; selected?: boolean; 0: number; 1: number }>, x0: number, y0: number, x3: number, y3: number) { - quadtree.visit(function (node, x1, y1, x2, y2) { + quadtree.visit(function (node: d3.geom.quadtree.Node<{ scanned?: boolean; selected?: boolean; 0: number; 1: number }>, x1: number, y1: number, x2:number, y2: number) { var p = node.point; if (p) { p.scanned = true; diff --git a/d3/d3.d.ts b/d3/d3.d.ts index fbeca365e..87e6ef0e0 100644 --- a/d3/d3.d.ts +++ b/d3/d3.d.ts @@ -3251,7 +3251,7 @@ declare module d3 { export function delaunay(vertices: Array<[number, number]>): Array<[[number, number], [number, number], [number, number]]>; export function quadtree(): Quadtree<[number, number]>; - export function quadtree(): Quadtree; + export function quadtree(nodes: T[], x1?: number, y1?: number, x2?: number, y2?: number): quadtree.Quadtree; module quadtree { interface Node { From 082f33f3d02c735b50441a99be2b9bc952281587 Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Tue, 13 Oct 2015 03:03:01 +0500 Subject: [PATCH 21/43] lodash: signatures of the method _.max have been changed --- lodash/lodash-tests.ts | 55 +++++++++-- lodash/lodash.d.ts | 215 ++++++++++++++++++++--------------------- 2 files changed, 152 insertions(+), 118 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 7dd2249c9..fbaded098 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -1633,13 +1633,6 @@ result = _(0.046).floor(2); result = _(4060).floor(-2); // → 4000 -result = _.max([4, 2, 8, 6]); -result = _.max(stoogesAges, function (stooge) { return stooge.age; }); -result = _.max(stoogesAges, 'age'); -result = <_.LoDashWrapper>_([4, 2, 8, 6]).max(); -result = <_.LoDashWrapper>_(stoogesAges).max(function (stooge) { return stooge.age; }); -result = <_.LoDashWrapper>_(stoogesAges).max('age'); - result = _.min([4, 2, 8, 6]); result = _.min(stoogesAges, function (stooge) { return stooge.age; }); result = _.min(stoogesAges, 'age'); @@ -2424,6 +2417,54 @@ result = _({}).toPlainObject(); result = _.add(1, 1); result = _(1).add(1); +// _.max +module TestMax { + let array: number[]; + let list: _.List; + let dictionary: _.Dictionary; + + let listIterator: (value: number, index: number, collection: _.List) => number; + let dictionaryIterator: (value: number, key: string, collection: _.Dictionary) => number; + + let result: number; + + result = _.max(array); + result = _.max(array, listIterator); + result = _.max(array, listIterator, any); + result = _.max(array, ''); + result = _.max<{a: number}, number>(array, {a: 42}); + + result = _.max(list); + result = _.max(list, listIterator); + result = _.max(list, listIterator, any); + result = _.max(list, ''); + result = _.max<{a: number}, number>(list, {a: 42}); + + result = _.max(dictionary); + result = _.max(dictionary, dictionaryIterator); + result = _.max(dictionary, dictionaryIterator, any); + result = _.max(dictionary, ''); + result = _.max<{a: number}, number>(dictionary, {a: 42}); + + result = _(array).max(); + result = _(array).max(listIterator); + result = _(array).max(listIterator, any); + result = _(array).max(''); + result = _(array).max<{a: number}>({a: 42}); + + result = _(list).max(); + result = _(list).max(listIterator); + result = _(list).max(listIterator, any); + result = _(list).max(''); + result = _(list).max<{a: number}, number>({a: 42}); + + result = _(dictionary).max(); + result = _(dictionary).max(dictionaryIterator); + result = _(dictionary).max(dictionaryIterator, any); + result = _(dictionary).max(''); + result = _(dictionary).max<{a: number}, number>({a: 42}); +} + /********** * Number * **********/ diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 60aaf60b7..b2fc4d6ea 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -4375,117 +4375,6 @@ declare module _ { floor(precision?: number): number; } - //_.max - interface LoDashStatic { - /** - * Retrieves the maximum value of a collection. If the collection is empty or falsey -Infinity is - * returned. If a callback is provided it will be executed for each value in the collection to - * generate the criterion by which the value is ranked. The callback is bound to thisArg and invoked - * with three arguments; (value, index, collection). - * - * If a property name is provided for callback the created "_.pluck" style callback will return the - * property value of the given element. - * - * If an object is provided for callback the created "_.where" style callback will return true for - * elements that have the properties of the given object, else false. - * @param collection The collection to iterate over. - * @param callback The function called per iteration. - * @param thisArg The this binding of callback. - * @return Returns the maximum value. - **/ - max( - collection: Array, - callback?: ListIterator, - thisArg?: any): T; - - /** - * @see _.max - **/ - max( - collection: List, - callback?: ListIterator, - thisArg?: any): T; - - /** - * @see _.max - **/ - max( - collection: Dictionary, - callback?: DictionaryIterator, - thisArg?: any): T; - - /** - * @see _.max - * @param pluckValue _.pluck style callback - **/ - max( - collection: Array, - pluckValue: string): T; - - /** - * @see _.max - * @param pluckValue _.pluck style callback - **/ - max( - collection: List, - pluckValue: string): T; - - /** - * @see _.max - * @param pluckValue _.pluck style callback - **/ - max( - collection: Dictionary, - pluckValue: string): T; - - /** - * @see _.max - * @param whereValue _.where style callback - **/ - max( - collection: Array, - whereValue: W): T; - - /** - * @see _.max - * @param whereValue _.where style callback - **/ - max( - collection: List, - whereValue: W): T; - - /** - * @see _.max - * @param whereValue _.where style callback - **/ - max( - collection: Dictionary, - whereValue: W): T; - } - - interface LoDashArrayWrapper { - /** - * @see _.max - **/ - max( - callback?: ListIterator, - thisArg?: any): LoDashWrapper; - - /** - * @see _.max - * @param pluckValue _.pluck style callback - **/ - max( - pluckValue: string): LoDashWrapper; - - /** - * @see _.max - * @param whereValue _.where style callback - **/ - max( - whereValue: W): LoDashWrapper; - } - //_.min interface LoDashStatic { /** @@ -7208,6 +7097,110 @@ declare module _ { add(addend: number): number; } + //_.max + interface LoDashStatic { + /** + * Gets the maximum value of collection. If collection is empty or falsey -Infinity is returned. If an iteratee + * function is provided it’s invoked for each value in collection to generate the criterion by which the value + * is ranked. The iteratee is bound to thisArg and invoked with three arguments: (value, index, collection). + * + * If a property name is provided for iteratee the created _.property style callback returns the property value + * of the given element. + * + * If a value is also provided for thisArg the created _.matchesProperty style callback returns true for + * elements that have a matching property value, else false. + * + * If an object is provided for iteratee the created _.matches style callback returns true for elements that + * have the properties of the given object, else false. + * + * @param collection The collection to iterate over. + * @param iteratee The function invoked per iteration. + * @param thisArg The this binding of iteratee. + * @return Returns the maximum value. + */ + max( + collection: List, + iteratee?: ListIterator, + thisArg?: any + ): T; + + /** + * @see _.max + */ + max( + collection: Dictionary, + iteratee?: DictionaryIterator, + thisArg?: any + ): T; + + /** + * @see _.max + */ + max( + collection: List|Dictionary, + iteratee?: string, + thisArg?: any + ): T; + + /** + * @see _.max + */ + max( + collection: List|Dictionary, + whereValue?: TObject + ): T; + } + + interface LoDashArrayWrapper { + /** + * @see _.max + */ + max( + iteratee?: ListIterator, + thisArg?: any + ): T; + + /** + * @see _.max + */ + max( + iteratee?: string, + thisArg?: any + ): T; + + /** + * @see _.max + */ + max( + whereValue?: TObject + ): T; + } + + interface LoDashObjectWrapper { + /** + * @see _.max + */ + max( + iteratee?: ListIterator|DictionaryIterator, + thisArg?: any + ): T; + + /** + * @see _.max + */ + max( + iteratee?: string, + thisArg?: any + ): T; + + /** + * @see _.max + */ + max( + whereValue?: TObject + ): T; + } + /********** * Number * **********/ From 13f6202aefd382cddee9dae9caa7185abcb0e579 Mon Sep 17 00:00:00 2001 From: Maw-Fox Date: Mon, 12 Oct 2015 17:39:20 -0600 Subject: [PATCH 22/43] Added initial definition and test file for the Sortable library. --- sortable/sortable-tests.ts | 311 +++++++++++++++++++++++++++++++++++++ sortable/sortable.d.ts | 208 +++++++++++++++++++++++++ 2 files changed, 519 insertions(+) create mode 100755 sortable/sortable-tests.ts create mode 100755 sortable/sortable.d.ts diff --git a/sortable/sortable-tests.ts b/sortable/sortable-tests.ts new file mode 100755 index 000000000..cc2b2cdcd --- /dev/null +++ b/sortable/sortable-tests.ts @@ -0,0 +1,311 @@ +// Examples from project repo used for tests. + +/// + +var simpleList = document.getElementById('list'); +var list = simpleList; +var el = document.getElementById('el'); +var sortable = new Sortable(simpleList, {}); +var order = sortable.toArray(); +var angular: any; +var Ply: any; + +sortable.sort(order.reverse()); + +Sortable.create(list, { + delay: 500, + chosenClass: "chosen" +}); + +Sortable.create(el, { + handle: ".my-handle" +}); + +Sortable.create(list, { + filter: ".js-remove, .js-edit", + onFilter: function(event) { + var item = event.item, + control = event.target; + + if (Sortable.utils.is(control, ".js-remove")) { + item.parentNode.removeChild(item); + } + else if (Sortable.utils.is(control, ".js-edit")) { + // .. + } + } +}); + +Sortable.create(el, { + group: "localStorage-example", + store: { + get: function(sortable) { + var order = localStorage.getItem(sortable.options.group); + + return order ? order.split('|') : []; + }, + set: function(sortable) { + var order = sortable.toArray(); + + localStorage.setItem(sortable.options.group, order.join('|')); + } + } +}); + +Sortable.create(simpleList, { + forceFallback: true +}); + +Sortable.create(simpleList, { + ghostClass: 'ghost' +}); + +simpleList.innerHTML = Array.apply(null, new Array(100)).map(function(value, iterator) { + return `
item ${iterator + 1}
`; +}).join(''); + +Sortable.create(simpleList, { + delay: 500, + chosenClass: 'chosen' +}); + +simpleList.innerHTML = Array.apply(null, new Array(10)).map(function(v, i) { + return '
item ' + + (i + 1) + + '
'; +}).join(''); + +Sortable.create(simpleList, {}); + +simpleList.innerHTML = Array.apply(null, new Array(100)).map(function(v, i) { + return '
item ' + + (i + 1) + + '
'; +}).join(''); + +(function() { + 'use strict'; + + var byId = function(id) { return document.getElementById(id); }, + + loadScripts = function(desc, callback) { + var deps = [], key, idx = 0; + + for (key in desc) { + deps.push(key); + } + + (function _next() { + var pid, + name = deps[idx], + script = document.createElement('script'); + + script.type = 'text/javascript'; + script.src = desc[deps[idx]]; + + pid = setInterval(function() { + if (window[name]) { + clearTimeout(pid); + + deps[idx++] = window[name]; + + if (deps[idx]) { + _next(); + } else { + callback.apply(null, deps); + } + } + }, 30); + + document.getElementsByTagName('head')[0].appendChild(script); + })() + }, + + console = window.console; + + + if (!console.log) { + console.log = function() { + alert([].join.apply(arguments, ' ')); + }; + } + + + Sortable.create(byId('foo'), { + group: "words", + animation: 150, + store: { + get: function(sortable) { + var order = localStorage.getItem(sortable.options.group); + return order ? order.split('|') : []; + }, + set: function(sortable) { + var order = sortable.toArray(); + localStorage.setItem(sortable.options.group, order.join('|')); + } + }, + onAdd: function(evt) { console.log('onAdd.foo:', [evt.item, evt.from]); }, + onUpdate: function(evt) { console.log('onUpdate.foo:', [evt.item, evt.from]); }, + onRemove: function(evt) { console.log('onRemove.foo:', [evt.item, evt.from]); }, + onStart: function(evt) { console.log('onStart.foo:', [evt.item, evt.from]); }, + onSort: function(evt) { console.log('onStart.foo:', [evt.item, evt.from]); }, + onEnd: function(evt) { console.log('onEnd.foo:', [evt.item, evt.from]); } + }); + + + Sortable.create(byId('bar'), { + group: "words", + animation: 150, + onAdd: function(evt) { console.log('onAdd.bar:', evt.item); }, + onUpdate: function(evt) { console.log('onUpdate.bar:', evt.item); }, + onRemove: function(evt) { console.log('onRemove.bar:', evt.item); }, + onStart: function(evt) { console.log('onStart.foo:', evt.item); }, + onEnd: function(evt) { console.log('onEnd.foo:', evt.item); } + }); + + + // Multi groups + Sortable.create(byId('multi'), { + animation: 150, + draggable: '.tile', + handle: '.tile__name' + }); + + [].forEach.call(byId('multi').getElementsByClassName('tile__list'), function(el) { + Sortable.create(el, { + group: 'photo', + animation: 150 + }); + }); + + + // Editable list + var editableList = Sortable.create(byId('editable'), { + animation: 150, + filter: '.js-remove', + onFilter: function(evt) { + evt.item.parentNode.removeChild(evt.item); + } + }); + + + byId('addUser').onclick = function() { + Ply.dialog('prompt', { + title: 'Add', + form: { name: 'name' } + }).done(function(ui) { + var el = document.createElement('li'); + el.innerHTML = ui.data.name + ''; + editableList.el.appendChild(el); + }); + }; + + + // Advanced groups + [{ + name: 'advanced', + pull: true, + put: true + }, + { + name: 'advanced', + pull: 'clone', + put: false + }, { + name: 'advanced', + pull: false, + put: true + }].forEach(function(groupOpts, i) { + Sortable.create(byId('advanced-' + (i + 1)), { + sort: (i != 1), + group: groupOpts, + animation: 150 + }); + }); + + + // 'handle' option + Sortable.create(byId('handle-1'), { + handle: '.drag-handle', + animation: 150 + }); + + + // Angular example + angular.module('todoApp', ['ng-sortable']) + .constant('ngSortableConfig', { + onEnd: function() { + console.log('default onEnd()'); + } + }) + .controller('TodoController', ['$scope', function($scope) { + $scope.todos = [ + { text: 'learn angular', done: true }, + { text: 'build an angular app', done: false } + ]; + + $scope.addTodo = function() { + $scope.todos.push({ text: $scope.todoText, done: false }); + $scope.todoText = ''; + }; + + $scope.remaining = function() { + var count = 0; + angular.forEach($scope.todos, function(todo) { + count += todo.done ? 0 : 1; + }); + return count; + }; + + $scope.archive = function() { + var oldTodos = $scope.todos; + $scope.todos = []; + angular.forEach(oldTodos, function(todo) { + if (!todo.done) $scope.todos.push(todo); + }); + }; + }]) + .controller('TodoControllerNext', ['$scope', function($scope) { + $scope.todos = [ + { text: 'learn Sortable', done: true }, + { text: 'use ng-sortable', done: false }, + { text: 'Enjoy', done: false } + ]; + + $scope.remaining = function() { + var count = 0; + angular.forEach($scope.todos, function(todo) { + count += todo.done ? 0 : 1; + }); + return count; + }; + + $scope.sortableConfig = { group: 'todo', animation: 150 }; + 'Start End Add Update Remove Sort'.split(' ').forEach(function(name) { + $scope.sortableConfig['on' + name] = console.log.bind(console, name); + }); + }]); +})(); + +// Background +document.addEventListener("DOMContentLoaded", function() { + function setNoiseBackground(el, width, height, opacity) { + var canvas = document.createElement("canvas"); + var context = canvas.getContext("2d"); + + canvas.width = width; + canvas.height = height; + + for (var i = 0; i < width; i++) { + for (var j = 0; j < height; j++) { + var val = Math.floor(Math.random() * 255); + context.fillStyle = "rgba(" + val + "," + val + "," + val + "," + opacity + ")"; + context.fillRect(i, j, 1, 1); + } + } + + el.style.background = "url(" + canvas.toDataURL("image/png") + ")"; + } + + setNoiseBackground(document.getElementsByTagName('body')[0], 50, 50, 0.02); +}, false); diff --git a/sortable/sortable.d.ts b/sortable/sortable.d.ts new file mode 100755 index 000000000..f52272659 --- /dev/null +++ b/sortable/sortable.d.ts @@ -0,0 +1,208 @@ +// Type definitions for Sortable.js v1.3.0-rc1 +// Project: https://github.com/RubaXa/Sortable +// Definitions by: Maw-Fox +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module Sortablejs { + interface SortableOptions { + group?: any; + sort?: boolean; + delay?: number; + disabled?: boolean; + store?: { + get: (sortable: Sortable) => any[]; + set: (sortable: Sortable) => any; + }; + animation?: number; + handle?: string; + filter?: any; + draggable?: string; + ghostClass?: string; + chosenClass?: string; + dataIdAttr?: string; + forceFallback?: boolean; + fallbackClass?: string; + fallbackOnBody?: boolean; + scroll?: boolean; + scrollSensitivity?: number; + scrollSpeed?: number; + setData?: (dataTransfer: any, draggedElement: any) => any; + onStart?: (event: any) => any; + onEnd?: (event: any) => any; + onAdd?: (event: any) => any; + onUpdate?: (event: any) => any; + onSort?: (event: any) => any; + onRemove?: (event: any) => any; + onFilter?: (event: any) => any; + onMove?: (event: any) => boolean; + } + + interface SortableableUtils { + /** + * Attach an event handler function + * @param {HTMLElement} element an HTMLElement. + * @param {string} event an Event context. + * @param {Function} fn + */ + on(element: any, event: string, fn: (event: any) => any): void; + + /** + * Remove an event handler function + * @param {HTMLElement} element an HTMLElement. + * @param {string} event an Event context. + * @param {Function} fn a callback. + */ + off(element: any, event: string, fn: (event: any) => any): void; + + /** + * Get the values of all the CSS properties. + * @param {HTMLElement} element an HTMLElement. + * @returns {Object} + */ + css(element: any): any; + + /** + * Get the value of style properties. + * @param {HTMLElement} element an HTMLElement. + * @param {string} prop a property key. + * @returns {*} + */ + css(element: any, prop: string): any; + + /** + * Set one CSS property. + * @param {HTMLElement} element an HTMLElement. + * @param {string} prop a property key. + * @param {string} value a property value. + */ + css(element: any, prop: string, value: string): void; + + /** + * Set CSS properties. + * @param {HTMLElement} element an HTMLElement. + * @param {Object} props a properties object. + */ + css(element: any, props: any): void; + + /** + * Get elements by tag name. + * @param {HTMLElement} context an HTMLElement. + * @param {string} tagName A tag name. + * @param {function} [iterator] An iterator. + * @returns {HTMLElement[]} + */ + find(context: any, tagName: string, iterator?: (value: any) => any): any[]; + + /** + * Takes a function and returns a new one that will always have a particular context. + * @param {*} context an HTMLElement. + * @param {function} fn a function. + * @returns {function} + */ + bind(context: any, fn: () => any): () => any; + + /** + * Check the current matched set of elements against a selector. + * @param {HTMLElement} element an HTMLElement. + * @param {string} selector an element selector. + * @returns {boolean} + */ + is(element: any, selector: string): boolean; + + /** + * For each element in the set, get the first element that matches the selector by testing the element itself and traversing up through its ancestors in the DOM tree. + * @param {HTMLElement} element an HTMLElement. + * @param {string} selector an element seletor. + * @param {HTMLElement} [context] a specific element's context. + * @returns {HTMLElement} + */ + closest(element: any, selector: string, context?: any): any; + + /** + * Add or remove one classes from each element + * @param {HTMLElement} element an HTMLElement. + * @param {string} name a class name. + * @param {boolean} state a class's state. + */ + toggleClass(element: any, name: string, state: boolean): void; + } + + class DOMRect { + public bottom: number; + public height: number; + public left: number; + public right: number; + public top: number; + public width: number; + public x: number; + public y: number; + } + + class Sortable { + public options: SortableOptions; + public el: any; + + /** + * Sortable's main constructor. + * @param {HTMLElement} element Any variety of HTMLElement. + * @param {SortableOptions} options Sortable options object. + */ + constructor(element: any, options: SortableOptions); + + static active: Sortable; + static utils: SortableableUtils; + + /** + * Creation of new instances. + * @param {HTMLElement} element Any variety of HTMLElement. + * @param {SortableOptions} options Sortable options object. + * @returns {Sortable} + */ + static create(element: any, options: SortableOptions): Sortable; + + /** + * Options getter/setter + * @param {string} name a SortableOptions property. + * @param {*} [value] a Value. + * @returns {*} + */ + option(name: string, value: any): any; + option(name: string): any; + + /** + * For each element in the set, get the first element that matches the selector by testing the element itself and traversing up through its ancestors in the DOM tree. + * @param {string|HTMLElement} element an HTMLElement or selector string. + * @returns {HTMLElement} + */ + closest(element: any): any; + + /** + * Sorts the elements according to the array. + * @param {string[]} order an array of strings to sort. + */ + sort(order: string[]): void; + + /** + * Saving and restoring of the sort. + */ + save(): void; + + /** + * Removes the sortable functionality completely. + */ + destroy(): void; + + /** + * Serializes the sortable's item data-id's (dataIdAttr option) into an array of string. + * @returns {string[]} + */ + toArray(): string[]; + } +} + +import Sortable = Sortablejs.Sortable; + +declare module 'Sortable' { + import Sortable = Sortablejs.Sortable; + export = Sortable; +} From ef82dff3d45f204e52eaa603be9b0ceadb218cf0 Mon Sep 17 00:00:00 2001 From: Maw-Fox Date: Mon, 12 Oct 2015 17:52:27 -0600 Subject: [PATCH 23/43] Added any declarations in the tests examples so that it can pass with the compiler flag '--noImplicitAny'. --- sortable/sortable-tests.ts | 52 +++++++++++++++----------------------- 1 file changed, 20 insertions(+), 32 deletions(-) diff --git a/sortable/sortable-tests.ts b/sortable/sortable-tests.ts index cc2b2cdcd..1a7fcc378 100755 --- a/sortable/sortable-tests.ts +++ b/sortable/sortable-tests.ts @@ -60,7 +60,7 @@ Sortable.create(simpleList, { ghostClass: 'ghost' }); -simpleList.innerHTML = Array.apply(null, new Array(100)).map(function(value, iterator) { +simpleList.innerHTML = Array.apply(null, new Array(100)).map(function(value: any, iterator: number) { return `
item ${iterator + 1}
`; }).join(''); @@ -69,54 +69,42 @@ Sortable.create(simpleList, { chosenClass: 'chosen' }); -simpleList.innerHTML = Array.apply(null, new Array(10)).map(function(v, i) { +simpleList.innerHTML = Array.apply(null, new Array(10)).map(function(value: any, iterator: number) { return '
item ' + - (i + 1) + + (iterator + 1) + '
'; }).join(''); Sortable.create(simpleList, {}); -simpleList.innerHTML = Array.apply(null, new Array(100)).map(function(v, i) { +simpleList.innerHTML = Array.apply(null, new Array(100)).map(function(value: any, iterator: number) { return '
item ' + - (i + 1) + + (iterator + 1) + '
'; }).join(''); (function() { 'use strict'; - var byId = function(id) { return document.getElementById(id); }, + var byId = function(id: string) { return document.getElementById(id); }, - loadScripts = function(desc, callback) { - var deps = [], key, idx = 0; + loadScripts = function(desc: any, callback: any) { + var deps: string[] = []; + var key: string; + var idx = 0; for (key in desc) { deps.push(key); } (function _next() { - var pid, + var pid: number, name = deps[idx], script = document.createElement('script'); script.type = 'text/javascript'; script.src = desc[deps[idx]]; - pid = setInterval(function() { - if (window[name]) { - clearTimeout(pid); - - deps[idx++] = window[name]; - - if (deps[idx]) { - _next(); - } else { - callback.apply(null, deps); - } - } - }, 30); - document.getElementsByTagName('head')[0].appendChild(script); })() }, @@ -171,7 +159,7 @@ simpleList.innerHTML = Array.apply(null, new Array(100)).map(function(v, i) { handle: '.tile__name' }); - [].forEach.call(byId('multi').getElementsByClassName('tile__list'), function(el) { + [].forEach.call(byId('multi').getElementsByClassName('tile__list'), function(el: any) { Sortable.create(el, { group: 'photo', animation: 150 @@ -193,7 +181,7 @@ simpleList.innerHTML = Array.apply(null, new Array(100)).map(function(v, i) { Ply.dialog('prompt', { title: 'Add', form: { name: 'name' } - }).done(function(ui) { + }).done(function(ui: any) { var el = document.createElement('li'); el.innerHTML = ui.data.name + ''; editableList.el.appendChild(el); @@ -238,7 +226,7 @@ simpleList.innerHTML = Array.apply(null, new Array(100)).map(function(v, i) { console.log('default onEnd()'); } }) - .controller('TodoController', ['$scope', function($scope) { + .controller('TodoController', ['$scope', function($scope: any) { $scope.todos = [ { text: 'learn angular', done: true }, { text: 'build an angular app', done: false } @@ -251,7 +239,7 @@ simpleList.innerHTML = Array.apply(null, new Array(100)).map(function(v, i) { $scope.remaining = function() { var count = 0; - angular.forEach($scope.todos, function(todo) { + angular.forEach($scope.todos, function(todo: any) { count += todo.done ? 0 : 1; }); return count; @@ -260,12 +248,12 @@ simpleList.innerHTML = Array.apply(null, new Array(100)).map(function(v, i) { $scope.archive = function() { var oldTodos = $scope.todos; $scope.todos = []; - angular.forEach(oldTodos, function(todo) { + angular.forEach(oldTodos, function(todo: any) { if (!todo.done) $scope.todos.push(todo); }); }; }]) - .controller('TodoControllerNext', ['$scope', function($scope) { + .controller('TodoControllerNext', ['$scope', function($scope: any) { $scope.todos = [ { text: 'learn Sortable', done: true }, { text: 'use ng-sortable', done: false }, @@ -274,14 +262,14 @@ simpleList.innerHTML = Array.apply(null, new Array(100)).map(function(v, i) { $scope.remaining = function() { var count = 0; - angular.forEach($scope.todos, function(todo) { + angular.forEach($scope.todos, function(todo: any) { count += todo.done ? 0 : 1; }); return count; }; $scope.sortableConfig = { group: 'todo', animation: 150 }; - 'Start End Add Update Remove Sort'.split(' ').forEach(function(name) { + 'Start End Add Update Remove Sort'.split(' ').forEach(function(name: string) { $scope.sortableConfig['on' + name] = console.log.bind(console, name); }); }]); @@ -289,7 +277,7 @@ simpleList.innerHTML = Array.apply(null, new Array(100)).map(function(v, i) { // Background document.addEventListener("DOMContentLoaded", function() { - function setNoiseBackground(el, width, height, opacity) { + function setNoiseBackground(el: any, width: number, height: number, opacity: number) { var canvas = document.createElement("canvas"); var context = canvas.getContext("2d"); From cba816a771d0eac3e6b6583ed27597020e6a2990 Mon Sep 17 00:00:00 2001 From: Maw-Fox Date: Mon, 12 Oct 2015 18:16:14 -0600 Subject: [PATCH 24/43] Fix for 'SortableableUtils' => 'SortableUtils'. --- sortable/sortable.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sortable/sortable.d.ts b/sortable/sortable.d.ts index f52272659..a471a4e69 100755 --- a/sortable/sortable.d.ts +++ b/sortable/sortable.d.ts @@ -37,7 +37,7 @@ declare module Sortablejs { onMove?: (event: any) => boolean; } - interface SortableableUtils { + interface SortableUtils { /** * Attach an event handler function * @param {HTMLElement} element an HTMLElement. @@ -150,7 +150,7 @@ declare module Sortablejs { constructor(element: any, options: SortableOptions); static active: Sortable; - static utils: SortableableUtils; + static utils: SortableUtils; /** * Creation of new instances. From 8e1e301cf24da75676b5e65b1cee987f7bf41e93 Mon Sep 17 00:00:00 2001 From: Maw-Fox Date: Mon, 12 Oct 2015 18:30:24 -0600 Subject: [PATCH 25/43] Changed namespace to the correct npm module 'sortablejs'. --- sortable/sortable-tests.ts => sortablejs/sortablejs-tests.ts | 0 sortable/sortable.d.ts => sortablejs/sortablejs.d.ts | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename sortable/sortable-tests.ts => sortablejs/sortablejs-tests.ts (100%) rename sortable/sortable.d.ts => sortablejs/sortablejs.d.ts (100%) diff --git a/sortable/sortable-tests.ts b/sortablejs/sortablejs-tests.ts similarity index 100% rename from sortable/sortable-tests.ts rename to sortablejs/sortablejs-tests.ts diff --git a/sortable/sortable.d.ts b/sortablejs/sortablejs.d.ts similarity index 100% rename from sortable/sortable.d.ts rename to sortablejs/sortablejs.d.ts From d897b331738f7ffd2084f7b29f72e62a9538e9db Mon Sep 17 00:00:00 2001 From: Maw-Fox Date: Mon, 12 Oct 2015 18:32:56 -0600 Subject: [PATCH 26/43] Changed reference path to reflect rename. --- sortablejs/sortablejs-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sortablejs/sortablejs-tests.ts b/sortablejs/sortablejs-tests.ts index 1a7fcc378..56b8b0a32 100755 --- a/sortablejs/sortablejs-tests.ts +++ b/sortablejs/sortablejs-tests.ts @@ -1,6 +1,6 @@ // Examples from project repo used for tests. -/// +/// var simpleList = document.getElementById('list'); var list = simpleList; From 60d9ffa196e8c551c7ebbbdcdcfe4d870cf77f70 Mon Sep 17 00:00:00 2001 From: Niklas Mollenhauer Date: Tue, 13 Oct 2015 07:20:11 +0200 Subject: [PATCH 27/43] Fix parameter types of padders --- easy-table/easy-table.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/easy-table/easy-table.d.ts b/easy-table/easy-table.d.ts index e06cfdd27..60bcb0457 100644 --- a/easy-table/easy-table.d.ts +++ b/easy-table/easy-table.d.ts @@ -23,7 +23,7 @@ declare module "easy-table" * @param {String} ch * @returns {Function} */ - public static leftPadder(ch: number): CellPrinter; + public static leftPadder(ch: string): CellPrinter; public static padLeft: CellPrinter; @@ -33,9 +33,9 @@ declare module "easy-table" * @param {String} ch * @returns {Function} */ - public static rightPadder(ch: number): CellPrinter; + public static rightPadder(ch: string): CellPrinter; - public static padRight: CellPrinter; + // public static padRight: CellPrinter; /** * Create a printer for numbers From c8644a8b63bb6f410bbc111e97ae66e418d1d9a6 Mon Sep 17 00:00:00 2001 From: Carlos Precioso Date: Tue, 13 Oct 2015 12:53:03 +0200 Subject: [PATCH 28/43] [moment] Min and max use rest arguments --- moment/moment-node.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/moment/moment-node.d.ts b/moment/moment-node.d.ts index 93be9f6d4..e0e552e01 100644 --- a/moment/moment-node.d.ts +++ b/moment/moment-node.d.ts @@ -453,8 +453,8 @@ declare module moment { weekdaysMin(format: string): string[]; weekdaysMin(format: string, index: number): string; - min(moments: Moment[]): Moment; - max(moments: Moment[]): Moment; + min(...moments: Moment[]): Moment; + max(...moments: Moment[]): Moment; normalizeUnits(unit: string): string; relativeTimeThreshold(threshold: string): number|boolean; From 734408e70a3f2bb2547998e25e91861e3c5d6c07 Mon Sep 17 00:00:00 2001 From: tkqubo Date: Sun, 11 Oct 2015 16:18:32 +0900 Subject: [PATCH 29/43] Make _.curry and _.curryRight more typed --- lodash/lodash-tests.ts | 58 ++++++++++++++----- lodash/lodash.d.ts | 126 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 167 insertions(+), 17 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 7dd2249c9..6f432f33d 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -1988,23 +1988,53 @@ result = <_.LoDashObjectWrapper<() => boolean>>_(createCallbackObj).createCallba // _.curry var testCurryFn = (a: number, b: number, c: number) => [a, b, c]; -interface TestCurryResultFn { - (...args: number[]): number[] | TestCurryResultFn; -} -result = _.curry(testCurryFn)(1, 2, 3); -result = _.curry(testCurryFn)(1); -result = _(testCurryFn).curry().value()(1, 2, 3); -result = _(testCurryFn).curry().value()(1); +let curryResult0: number[] +let curryResult1: _.CurriedFunction1 +let curryResult2: _.CurriedFunction2 + +curryResult0 = _.curry(testCurryFn)(1, 2, 3); +curryResult1 = _.curry(testCurryFn)(1, 2); +curryResult0 = _.curry(testCurryFn)(1, 2)(3); +curryResult0 = _.curry(testCurryFn)(1)(2)(3); +curryResult2 = _.curry(testCurryFn)(1); +curryResult1 = _.curry(testCurryFn)(1)(2); +curryResult0 = _.curry(testCurryFn)(1)(2)(3); +curryResult0 = _.curry(testCurryFn)(1)(2, 3); +curryResult0 = _(testCurryFn).curry().value()(1, 2, 3); +curryResult2 = _(testCurryFn).curry().value()(1); + +declare function testCurry2(a: string, b: number, c: boolean): [string, number, boolean]; +let curryResult3: [string, number, boolean]; +let curryResult4: _.CurriedFunction1; +let curryResult5: _.CurriedFunction2; +let curryResult6: _.CurriedFunction3; +curryResult3 = _.curry(testCurry2)("1", 2, true); +curryResult3 = _.curry(testCurry2)("1", 2)(true); +curryResult3 = _.curry(testCurry2)("1")(2, true); +curryResult3 = _.curry(testCurry2)("1")(2)(true); +curryResult4 = _.curry(testCurry2)("1", 2); +curryResult4 = _.curry(testCurry2)("1")(2); +curryResult5 = _.curry(testCurry2)("1"); +curryResult6 = _.curry(testCurry2); // _.curryRight var testCurryRightFn = (a: number, b: number, c: number) => [a, b, c]; -interface TestCurryRightResultFn { - (...args: number[]): number[] | TestCurryRightResultFn; -} -result = _.curryRight(testCurryRightFn)(1, 2, 3); -result = _.curryRight(testCurryRightFn)(1); -result = _(testCurryRightFn).curryRight().value()(1, 2, 3); -result = _(testCurryRightFn).curryRight().value()(1); +curryResult0 = _.curryRight(testCurryRightFn)(1, 2, 3); +curryResult2 = _.curryRight(testCurryRightFn)(1); +curryResult0 = _(testCurryRightFn).curryRight().value()(1, 2, 3); +curryResult2 = _(testCurryRightFn).curryRight().value()(1); + +let curryResult7: _.CurriedFunction1; +let curryResult8: _.CurriedFunction2; +let curryResult9: _.CurriedFunction3; +curryResult3 = _.curryRight(testCurry2)(true, 2, "1"); +curryResult3 = _.curryRight(testCurry2)(true, 2)("1"); +curryResult3 = _.curryRight(testCurry2)(true)(2, "1"); +curryResult3 = _.curryRight(testCurry2)(true)(2)("1"); +curryResult7 = _.curryRight(testCurry2)(true, 2); +curryResult7 = _.curryRight(testCurry2)(true)(2); +curryResult8 = _.curryRight(testCurry2)(true); +curryResult9 = _.curryRight(testCurry2); declare var source: any; result = _.debounce(function () { }, 150); diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 60aaf60b7..b7270d0e9 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -3585,7 +3585,7 @@ declare module _ { predicate?: TObject ): TResult; } - + //_.findWhere interface LoDashStatic { /** @@ -6184,7 +6184,87 @@ declare module _ { */ curry( func: Function, - arity?: number): TResult; + arity: number): TResult; + /** + * Creates a function that accepts one or more arguments of func that when called either invokes func returning + * its result, if all func arguments have been provided, or returns a function that accepts one or more of the + * remaining func arguments, and so on. The arity of func may be specified if func.length is not sufficient. + * @param func The function to curry. + * @return Returns the new curried function. + */ + curry(func: (t1: T1) => R): + CurriedFunction1; + /** + * Creates a function that accepts one or more arguments of func that when called either invokes func returning + * its result, if all func arguments have been provided, or returns a function that accepts one or more of the + * remaining func arguments, and so on. The arity of func may be specified if func.length is not sufficient. + * @param func The function to curry. + * @return Returns the new curried function. + */ + curry(func: (t1: T1, t2: T2) => R): + CurriedFunction2; + /** + * Creates a function that accepts one or more arguments of func that when called either invokes func returning + * its result, if all func arguments have been provided, or returns a function that accepts one or more of the + * remaining func arguments, and so on. The arity of func may be specified if func.length is not sufficient. + * @param func The function to curry. + * @return Returns the new curried function. + */ + curry(func: (t1: T1, t2: T2, t3: T3) => R): + CurriedFunction3; + /** + * Creates a function that accepts one or more arguments of func that when called either invokes func returning + * its result, if all func arguments have been provided, or returns a function that accepts one or more of the + * remaining func arguments, and so on. The arity of func may be specified if func.length is not sufficient. + * @param func The function to curry. + * @return Returns the new curried function. + */ + curry(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R): + CurriedFunction4; + /** + * Creates a function that accepts one or more arguments of func that when called either invokes func returning + * its result, if all func arguments have been provided, or returns a function that accepts one or more of the + * remaining func arguments, and so on. The arity of func may be specified if func.length is not sufficient. + * @param func The function to curry. + * @return Returns the new curried function. + */ + curry(func: (t1: T1, t2: T2, t3: T3, t4: T4, t5: T5) => R): + CurriedFunction5; + } + + interface CurriedFunction1 { + (): CurriedFunction1; + (t1: T1): R; + } + + interface CurriedFunction2 { + (): CurriedFunction2; + (t1: T1): CurriedFunction1; + (t1: T1, t2: T2): R; + } + + interface CurriedFunction3 { + (): CurriedFunction3; + (t1: T1): CurriedFunction2; + (t1: T1, t2: T2): CurriedFunction1; + (t1: T1, t2: T2, t3: T3): R; + } + + interface CurriedFunction4 { + (): CurriedFunction4; + (t1: T1): CurriedFunction3; + (t1: T1, t2: T2): CurriedFunction2; + (t1: T1, t2: T2, t3: T3): CurriedFunction1; + (t1: T1, t2: T2, t3: T3, t4: T4): R; + } + + interface CurriedFunction5 { + (): CurriedFunction5; + (t1: T1): CurriedFunction4; + (t1: T1, t2: T2): CurriedFunction3; + (t1: T1, t2: T2, t3: T3): CurriedFunction2; + (t1: T1, t2: T2, t3: T3, t4: T4): CurriedFunction1; + (t1: T1, t2: T2, t3: T3, t4: T4, t5: T5): R; } interface LoDashObjectWrapper { @@ -6205,7 +6285,47 @@ declare module _ { */ curryRight( func: Function, - arity?: number): TResult; + arity: number): TResult; + /** + * This method is like _.curry except that arguments are applied to func in the manner of _.partialRight + * instead of _.partial. + * @param func The function to curry. + * @return Returns the new curried function. + */ + curryRight(func: (t1: T1) => R): + CurriedFunction1; + /** + * This method is like _.curry except that arguments are applied to func in the manner of _.partialRight + * instead of _.partial. + * @param func The function to curry. + * @return Returns the new curried function. + */ + curryRight(func: (t1: T1, t2: T2) => R): + CurriedFunction2; + /** + * This method is like _.curry except that arguments are applied to func in the manner of _.partialRight + * instead of _.partial. + * @param func The function to curry. + * @return Returns the new curried function. + */ + curryRight(func: (t1: T1, t2: T2, t3: T3) => R): + CurriedFunction3; + /** + * This method is like _.curry except that arguments are applied to func in the manner of _.partialRight + * instead of _.partial. + * @param func The function to curry. + * @return Returns the new curried function. + */ + curryRight(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R): + CurriedFunction4; + /** + * This method is like _.curry except that arguments are applied to func in the manner of _.partialRight + * instead of _.partial. + * @param func The function to curry. + * @return Returns the new curried function. + */ + curryRight(func: (t1: T1, t2: T2, t3: T3, t4: T4, t5: T5) => R): + CurriedFunction5; } interface LoDashObjectWrapper { From b337a759c20dde237395befdf51cce5794e7d350 Mon Sep 17 00:00:00 2001 From: tkqubo Date: Sun, 11 Oct 2015 16:22:03 +0900 Subject: [PATCH 30/43] Replace tab with 4 spaces --- lodash/lodash.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index b7270d0e9..97ccc702d 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -3585,7 +3585,7 @@ declare module _ { predicate?: TObject ): TResult; } - + //_.findWhere interface LoDashStatic { /** From 6f095518bed68d08d66d5ffc2d6916ee6de0a658 Mon Sep 17 00:00:00 2001 From: tkqubo Date: Tue, 13 Oct 2015 21:28:24 +0900 Subject: [PATCH 31/43] fix: make arity optional for default curry | curryRight invocation --- lodash/lodash.d.ts | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 97ccc702d..d5b67104b 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -6174,17 +6174,6 @@ declare module _ { //_.curry interface LoDashStatic { - /** - * Creates a function that accepts one or more arguments of func that when called either invokes func returning - * its result, if all func arguments have been provided, or returns a function that accepts one or more of the - * remaining func arguments, and so on. The arity of func may be specified if func.length is not sufficient. - * @param func The function to curry. - * @param arity The arity of func. - * @return Returns the new curried function. - */ - curry( - func: Function, - arity: number): TResult; /** * Creates a function that accepts one or more arguments of func that when called either invokes func returning * its result, if all func arguments have been provided, or returns a function that accepts one or more of the @@ -6230,6 +6219,17 @@ declare module _ { */ curry(func: (t1: T1, t2: T2, t3: T3, t4: T4, t5: T5) => R): CurriedFunction5; + /** + * Creates a function that accepts one or more arguments of func that when called either invokes func returning + * its result, if all func arguments have been provided, or returns a function that accepts one or more of the + * remaining func arguments, and so on. The arity of func may be specified if func.length is not sufficient. + * @param func The function to curry. + * @param arity The arity of func. + * @return Returns the new curried function. + */ + curry( + func: Function, + arity?: number): TResult; } interface CurriedFunction1 { @@ -6276,16 +6276,6 @@ declare module _ { //_.curryRight interface LoDashStatic { - /** - * This method is like _.curry except that arguments are applied to func in the manner of _.partialRight - * instead of _.partial. - * @param func The function to curry. - * @param arity The arity of func. - * @return Returns the new curried function. - */ - curryRight( - func: Function, - arity: number): TResult; /** * This method is like _.curry except that arguments are applied to func in the manner of _.partialRight * instead of _.partial. @@ -6326,6 +6316,16 @@ declare module _ { */ curryRight(func: (t1: T1, t2: T2, t3: T3, t4: T4, t5: T5) => R): CurriedFunction5; + /** + * This method is like _.curry except that arguments are applied to func in the manner of _.partialRight + * instead of _.partial. + * @param func The function to curry. + * @param arity The arity of func. + * @return Returns the new curried function. + */ + curryRight( + func: Function, + arity?: number): TResult; } interface LoDashObjectWrapper { From a63be385490b512004809d2c0d0253a35b2a779f Mon Sep 17 00:00:00 2001 From: Carlos Precioso Date: Tue, 13 Oct 2015 15:19:25 +0200 Subject: [PATCH 32/43] [moment] Accept MomentInput for moment().set() As per http://momentjs.com/docs/#/get-set/set/ --- moment/moment-node.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/moment/moment-node.d.ts b/moment/moment-node.d.ts index 93be9f6d4..18c0eee0f 100644 --- a/moment/moment-node.d.ts +++ b/moment/moment-node.d.ts @@ -303,6 +303,7 @@ declare module moment { get(unit: string): number; set(unit: string, value: number): Moment; + set(objectLiteral: MomentInput): Moment; } type formatFunction = () => string; From 48b2588355fc3bbef058e77c2c56cfa0a493e1d9 Mon Sep 17 00:00:00 2001 From: Joe Herman Date: Tue, 13 Oct 2015 11:48:00 -0400 Subject: [PATCH 33/43] async: Corrected filter and reject definitions. --- async/async.d.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/async/async.d.ts b/async/async.d.ts index a8b38c5fc..78523d9c6 100644 --- a/async/async.d.ts +++ b/async/async.d.ts @@ -1,6 +1,6 @@ // Type definitions for Async 1.4.2 // Project: https://github.com/caolan/async -// Definitions by: Boris Yankov , Arseniy Maximov +// Definitions by: Boris Yankov , Arseniy Maximov , Joe Herman // Definitions: https://github.com/borisyankov/DefinitelyTyped interface Dictionary { [key: string]: T; } @@ -85,15 +85,15 @@ interface Async { 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; - selectSeries(arr: T[], iterator: AsyncResultIterator, callback?: (results: T[]) => any): any; - filterLimit(arr: T[], limit: number, iterator: AsyncResultIterator, callback?: (results: T[]) => any): any; - selectLimit(arr: T[], limit: number, iterator: AsyncResultIterator, callback?: (results: T[]) => any): any; - reject(arr: T[], iterator: AsyncResultIterator, callback?: (results: T[]) => any): any; - rejectSeries(arr: T[], iterator: AsyncResultIterator, callback?: (results: T[]) => any): any; - rejectLimit(arr: T[], limit: number, iterator: AsyncResultIterator, callback?: (results: T[]) => any): any; + filter(arr: T[], iterator: AsyncBooleanIterator, callback?: (results: T[]) => any): any; + select(arr: T[], iterator: AsyncBooleanIterator, callback?: (results: T[]) => any): any; + filterSeries(arr: T[], iterator: AsyncBooleanIterator, callback?: (results: T[]) => any): any; + selectSeries(arr: T[], iterator: AsyncBooleanIterator, callback?: (results: T[]) => any): any; + filterLimit(arr: T[], limit: number, iterator: AsyncBooleanIterator, callback?: (results: T[]) => any): any; + selectLimit(arr: T[], limit: number, iterator: AsyncBooleanIterator, callback?: (results: T[]) => any): any; + reject(arr: T[], iterator: AsyncBooleanIterator, callback?: (results: T[]) => any): any; + rejectSeries(arr: T[], iterator: AsyncBooleanIterator, callback?: (results: T[]) => any): any; + rejectLimit(arr: T[], limit: number, iterator: AsyncBooleanIterator, callback?: (results: T[]) => any): any; reduce(arr: T[], memo: R, iterator: AsyncMemoIterator, callback?: AsyncResultCallback): any; inject(arr: T[], memo: R, iterator: AsyncMemoIterator, callback?: AsyncResultCallback): any; foldl(arr: T[], memo: R, iterator: AsyncMemoIterator, callback?: AsyncResultCallback): any; From 4862dcd46dc51e389fb9290fa27315a6a1079e02 Mon Sep 17 00:00:00 2001 From: Joe Herman Date: Tue, 13 Oct 2015 12:17:18 -0400 Subject: [PATCH 34/43] async: Remove error requirement in series, parallel. --- async/async.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/async/async.d.ts b/async/async.d.ts index 78523d9c6..6054e9a47 100644 --- a/async/async.d.ts +++ b/async/async.d.ts @@ -10,7 +10,7 @@ interface AsyncResultCallback { (err: Error, result: T): void; } interface AsyncResultArrayCallback { (err: Error, results: T[]): void; } interface AsyncResultObjectCallback { (err: Error, results: Dictionary): void; } -interface AsyncFunction { (callback: (err: Error, result?: T) => void): void; } +interface AsyncFunction { (callback: (err?: Error, result?: T) => void): void; } interface AsyncIterator { (item: T, callback: ErrorCallback): void; } interface AsyncForEachOfIterator { (item: T, key: number, callback: ErrorCallback): void; } interface AsyncResultIterator { (item: T, callback: AsyncResultCallback): void; } @@ -126,7 +126,7 @@ interface Async { during(test: (testCallback : (error: Error, truth: boolean) => void) => void, fn: AsyncVoidFunction, callback: (err: any) => void): void; doDuring(fn: AsyncVoidFunction, test: (testCallback: (error: Error, truth: boolean) => void) => void, callback: (err: any) => void): void; forever(next: (errCallback : (err: Error) => void) => void, errBack: (err: Error) => void) : void; - waterfall(tasks: Function[], callback?: (err: Error, result: any) => void): void; + waterfall(tasks: Function[], callback?: (err: Error, results?: any) => void): void; compose(...fns: Function[]): void; seq(...fns: Function[]): void; applyEach(fns: Function[], argsAndCallback: any[]): void; // applyEach(fns, args..., callback). TS does not support ... for a middle argument. Callback is optional. From bf9e64cc1d0f7fe4360acb4c42103ff3e86b4801 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 13 Oct 2015 19:00:32 +0200 Subject: [PATCH 35/43] Added definitions for angular-loading-bar fixes type strictness for typescript 1.6+ --- .../angular-loading-bar-tests.ts | 15 +++++++++++++++ angular-loading-bar/angular-loading-bar.d.ts | 18 ++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 angular-loading-bar/angular-loading-bar-tests.ts create mode 100644 angular-loading-bar/angular-loading-bar.d.ts diff --git a/angular-loading-bar/angular-loading-bar-tests.ts b/angular-loading-bar/angular-loading-bar-tests.ts new file mode 100644 index 000000000..b7ca2894e --- /dev/null +++ b/angular-loading-bar/angular-loading-bar-tests.ts @@ -0,0 +1,15 @@ +/// + +var app = angular.module('testModule', ['angular-loading-bar']); + +class TestController { + + constructor($http: ng.IHttpService) { + + $http.get("http://xyz.com", { ignoreLoadingBar: true }) + + } + +} + +app.controller('TestController', TestController); diff --git a/angular-loading-bar/angular-loading-bar.d.ts b/angular-loading-bar/angular-loading-bar.d.ts new file mode 100644 index 000000000..b1a8cd55d --- /dev/null +++ b/angular-loading-bar/angular-loading-bar.d.ts @@ -0,0 +1,18 @@ +// Type definitions for angular-loading-bar +// Project: https://github.com/chieffancypants/angular-loading-bar +// Definitions by: Stephen Lautier +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + + +declare module angular { + + interface IRequestShortcutConfig { + /** + * Indicates that the loading bar should be hidden. + */ + ignoreLoadingBar?: boolean; + } + +} \ No newline at end of file From d040016b4b5ac9a1f46a88b737e641237fbb52ff Mon Sep 17 00:00:00 2001 From: Stepan Mikhaylyuk Date: Tue, 13 Oct 2015 20:24:27 +0300 Subject: [PATCH 36/43] react input calendar definitions --- .../react-input-calendar.d.ts | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 react-input-calendar/react-input-calendar.d.ts diff --git a/react-input-calendar/react-input-calendar.d.ts b/react-input-calendar/react-input-calendar.d.ts new file mode 100644 index 000000000..ac829c215 --- /dev/null +++ b/react-input-calendar/react-input-calendar.d.ts @@ -0,0 +1,53 @@ +declare module reactInputCalendar { + export interface ReactInputCalendarProps { + /** + * Format of date, which display in input and set in date property. + * Allowed Keys: All formats supported by moment.js + * @default 'MM-DD-YYYY' + */ + format?: string; + /** + * Set initial date value + * @default current date + */ + date?: string | Date; + /** + * Set minimal view. Values: + * 0 - days + * 1 - months + * 2 - years. + * @default 0 (DaysView) + */ + minView?: number; + /** + * Format of date for the onChange event. Default on the date format (ISO 8601) to ease the save of data. + * Allowed Keys: All formats supported by moment.js + * @default 'MM-DD-YYYY' + */ + computableFormat?: string; + /** + * Set an function that will be triggered whenever there is a change in the selected date. It will return the date in the props.computableFormat format. + */ + onChange?:(selectedDate: string)=>any; + /** + * Define state when date picker would close once the user has clicked on a date. + */ + closeOnSelect?:boolean; + /** + * Setting this value to true makes the calendar widget open when the iput field is focused. + */ + openOnInputFocus?: boolean; + /** + * Value to show in the input text box if no date is set. + */ + placeholder?:string + } + interface ReactInputCalendarState { } + export class ReactInputCalendar extends __React.Component{ + render(): __React.DOMElement + } +} +declare var ReactInputCalendar: typeof reactInputCalendar.ReactInputCalendar +declare module "react-input-calendar" { + export = ReactInputCalendar +} From 834544350ce56c30de51750ca3f5a824b017217e Mon Sep 17 00:00:00 2001 From: Stepan Mikhaylyuk Date: Tue, 13 Oct 2015 20:28:09 +0300 Subject: [PATCH 37/43] Create react-input-calendar-tests.ts --- react-input-calendar/react-input-calendar-tests.ts | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 react-input-calendar/react-input-calendar-tests.ts diff --git a/react-input-calendar/react-input-calendar-tests.ts b/react-input-calendar/react-input-calendar-tests.ts new file mode 100644 index 000000000..599c8533c --- /dev/null +++ b/react-input-calendar/react-input-calendar-tests.ts @@ -0,0 +1,4 @@ +/// +/// + +var reactInp = new ReactInputCalendar(); From 16d56c547cd34ba987c4b46b043ee4c07573ee22 Mon Sep 17 00:00:00 2001 From: Stepan Mikhaylyuk Date: Tue, 13 Oct 2015 20:30:07 +0300 Subject: [PATCH 38/43] Update react-input-calendar.d.ts --- react-input-calendar/react-input-calendar.d.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/react-input-calendar/react-input-calendar.d.ts b/react-input-calendar/react-input-calendar.d.ts index ac829c215..d8c518b83 100644 --- a/react-input-calendar/react-input-calendar.d.ts +++ b/react-input-calendar/react-input-calendar.d.ts @@ -1,3 +1,9 @@ +// Type definitions for react-input-calendar +// Project: https://github.com/Rudeg/react-input-calendar +// Definitions by: Stepan Mikhaylyuk +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// declare module reactInputCalendar { export interface ReactInputCalendarProps { /** From 67db10d0fed736652de0ddf8014031680b0ab737 Mon Sep 17 00:00:00 2001 From: Stepan Mikhaylyuk Date: Tue, 13 Oct 2015 20:34:10 +0300 Subject: [PATCH 39/43] Rename react-input-calendar-tests.ts to react-input-calendar-tests.tsx --- ...act-input-calendar-tests.ts => react-input-calendar-tests.tsx} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename react-input-calendar/{react-input-calendar-tests.ts => react-input-calendar-tests.tsx} (100%) diff --git a/react-input-calendar/react-input-calendar-tests.ts b/react-input-calendar/react-input-calendar-tests.tsx similarity index 100% rename from react-input-calendar/react-input-calendar-tests.ts rename to react-input-calendar/react-input-calendar-tests.tsx From 77957b603121f6ce6f11b26754dcaf9dbadfa56b Mon Sep 17 00:00:00 2001 From: Stepan Mikhaylyuk Date: Tue, 13 Oct 2015 20:35:03 +0300 Subject: [PATCH 40/43] Create react-input-calendar-tests.tsx.tscparams --- react-input-calendar/react-input-calendar-tests.tsx.tscparams | 1 + 1 file changed, 1 insertion(+) create mode 100644 react-input-calendar/react-input-calendar-tests.tsx.tscparams diff --git a/react-input-calendar/react-input-calendar-tests.tsx.tscparams b/react-input-calendar/react-input-calendar-tests.tsx.tscparams new file mode 100644 index 000000000..c90abf04f --- /dev/null +++ b/react-input-calendar/react-input-calendar-tests.tsx.tscparams @@ -0,0 +1 @@ +--target es5 --noImplicitAny --experimentalDecorators --jsx react From 4961cbc4415fda43d32a946881bad4f106ec880d Mon Sep 17 00:00:00 2001 From: Stepan Mikhaylyuk Date: Tue, 13 Oct 2015 20:37:15 +0300 Subject: [PATCH 41/43] Update react-input-calendar-tests.tsx --- react-input-calendar/react-input-calendar-tests.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/react-input-calendar/react-input-calendar-tests.tsx b/react-input-calendar/react-input-calendar-tests.tsx index 599c8533c..127106424 100644 --- a/react-input-calendar/react-input-calendar-tests.tsx +++ b/react-input-calendar/react-input-calendar-tests.tsx @@ -1,4 +1,6 @@ /// /// -var reactInp = new ReactInputCalendar(); +import * as ReactInputCalendar from 'react-input-calendar'; +import * as React from 'react'; +React.render(, document.body); From 28a3484cf970e5a7fa87939b672a56107aa807a7 Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Wed, 14 Oct 2015 03:39:46 +0500 Subject: [PATCH 42/43] lodash: signatures of the method _.toPlainObject have been changed --- lodash/lodash-tests.ts | 29 +++++++++++++++++------------ lodash/lodash.d.ts | 15 +++++++++------ 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 7dd2249c9..f5a2f027b 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -2403,18 +2403,23 @@ result = _([]).lte(2); result = _({}).lte(2); // _.toPlainObject -result = _.toPlainObject(); -result = _.toPlainObject(true); -result = _.toPlainObject(1); -result = _.toPlainObject('a'); -result = _.toPlainObject([]); -result = _.toPlainObject({}); -result = _(true).toPlainObject(); -result = _(1).toPlainObject(); -result = _('a').toPlainObject(); -result = _([1]).toPlainObject(); -result = _([]).toPlainObject(); -result = _({}).toPlainObject(); +module TestToPlainObject { + let result: TResult; + + result = _.toPlainObject(); + result = _.toPlainObject(true); + result = _.toPlainObject(1); + result = _.toPlainObject('a'); + result = _.toPlainObject([]); + result = _.toPlainObject({}); + + result = _(true).toPlainObject().value(); + result = _(1).toPlainObject().value(); + result = _('a').toPlainObject().value(); + result = _([1]).toPlainObject().value(); + result = _([]).toPlainObject().value(); + result = _({}).toPlainObject().value(); +} /******** * Math * diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 60aaf60b7..f0ee86679 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -238,11 +238,6 @@ declare module _ { * @see _.value **/ valueOf(): T; - - /** - * @see _.toPlainObject - */ - toPlainObject(): Object; } interface LoDashWrapper extends LoDashWrapperBase> { } @@ -7180,10 +7175,18 @@ declare module _ { /** * Converts value to a plain object flattening inherited enumerable properties of value to own properties * of the plain object. + * * @param value The value to convert. * @return Returns the converted plain object. */ - toPlainObject(value?: any): Object; + toPlainObject(value?: any): TResult; + } + + interface LoDashWrapperBase { + /** + * @see _.toPlainObject + */ + toPlainObject(): LoDashObjectWrapper; } /******** From b39cce34194829c74791c7e9a4dd4313f73fd62a Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Wed, 14 Oct 2015 03:25:54 +0500 Subject: [PATCH 43/43] lodash: signatures of the method _.random have been changed --- lodash/lodash-tests.ts | 24 +++++++++++---- lodash/lodash.d.ts | 67 +++++++++++++++++++++++++++++------------- 2 files changed, 65 insertions(+), 26 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 7dd2249c9..e96e02ebb 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -2434,6 +2434,24 @@ result = _.inRange(4, 8); result = _(3).inRange(2, 4); result = _(4).inRange(8); +// _.random +module TestRandom { + let result: number; + + result = _.random(); + result = _.random(1); + result = _.random(1, 2); + result = _.random(1, 2, true); + result = _.random(1, true); + result = _.random(true); + + result = _(1).random(); + result = _(1).random(2); + result = _(1).random(2, true); + result = _(1).random(true); + result = _(true).random(); +} + /********* * Object * **********/ @@ -2911,12 +2929,6 @@ var testAttempFn: TestAttemptFn; result = _.attempt(testAttempFn); result = _(testAttempFn).attempt(); -result = _.random(0, 5); -result = _.random(5); -result = _.random(5, true); -result = _.random(1.2, 5.2); -result = _.random(0, 5, true); - // _.noop result = _.noop(); result = _.noop(1); diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 60aaf60b7..9faa72f1b 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -7243,6 +7243,53 @@ declare module _ { inRange(end: number): boolean; } + //_.random + interface LoDashStatic { + /** + * Produces a random number between min and max (inclusive). If only one argument is provided a number between + * 0 and the given number is returned. If floating is true, or either min or max are floats, a floating-point + * number is returned instead of an integer. + * + * @param min The minimum possible value. + * @param max The maximum possible value. + * @param floating Specify returning a floating-point number. + * @return Returns the random number. + */ + random( + min?: number, + max?: number, + floating?: boolean + ): number; + + /** + * @see _.random + */ + random( + min?: number, + floating?: boolean + ): number; + + /** + * @see _.random + */ + random(floating?: boolean): number; + } + + interface LoDashWrapper { + /** + * @see _.random + */ + random( + max?: number, + floating?: boolean + ): number; + + /** + * @see _.random + */ + random(floating?: boolean): number; + } + /********** * Object * **********/ @@ -9415,26 +9462,6 @@ declare module _ { step?: number): LoDashArrayWrapper; } - //_.random - interface LoDashStatic { - /** - * Produces a random number between min and max (inclusive). If only one argument is provided a - * number between 0 and the given number will be returned. If floating is truey or either min or - * max are floats a floating-point number will be returned instead of an integer. - * @param max The maximum possible value. - * @param floating Specify returning a floating-point number. - * @return A random number. - **/ - random(max: number, floating?: boolean): number; - - /** - * @see _.random - * @param min The minimum possible value. - * @return A random number between `min` and `max`. - **/ - random(min: number, max: number, floating?: boolean): number; - } - //_.runInContext interface LoDashStatic { /**