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 diff --git a/async/async.d.ts b/async/async.d.ts index a8b38c5fc..6054e9a47 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; } @@ -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; } @@ -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; @@ -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. 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 { 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..93a4516bf --- /dev/null +++ b/easy-table/easy-table-0.2.0-tests.ts @@ -0,0 +1,14 @@ +/// + +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; +} diff --git a/easy-table/easy-table-tests.ts b/easy-table/easy-table-tests.ts index 732426064..911031d90 100644 --- a/easy-table/easy-table-tests.ts +++ b/easy-table/easy-table-tests.ts @@ -1,15 +1,103 @@ -/// +/// -import EasyTable = require('easy-table'); +import Table = require("easy-table"); -var table = new EasyTable(); +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 Data { + 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..60bcb0457 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: string): CellPrinter; + + public static padLeft: CellPrinter; + + /** + * Create a printer which pads with `ch` on the right + * + * @param {String} ch + * @returns {Function} + */ + public static rightPadder(ch: string): 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?: PrintColumnOptions): 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?: TotalOptions): EasyTable; + /** + * Predefined helpers for totals + */ + public static aggr: Aggregators; + + /** + * 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 | FormatObject, cb?: TablePostProcessing): string; + + /** + * Same as `Table.print()` but yields the result to `console.log()` + */ + public static log(obj: T | T[], format?: FormatFunction | FormatObject, 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 PrintColumnOptions { + /** + * 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 Aggregators { + /** + * 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 TotalOptions { + /** + * 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 FormatObject { + [key: string]: ColumnFormat; + } + + interface ColumnFormat { + name?: string; + printer?: CellPrinter } export = EasyTable; diff --git a/localForage/localForage-tests.ts b/localForage/localForage-tests.ts index 59e429a76..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 diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 7dd2249c9..daa640fcb 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'); @@ -1988,23 +1981,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); @@ -2403,18 +2426,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 * @@ -2424,6 +2452,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 * **********/ @@ -2434,6 +2510,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 +3005,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..b2659d0aa 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> { } @@ -4375,117 +4370,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 { /** @@ -6174,6 +6058,51 @@ 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. + * @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; /** * 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 @@ -6183,8 +6112,43 @@ declare module _ { * @return Returns the new curried function. */ curry( - func: Function, - arity?: number): TResult; + func: Function, + arity?: number): TResult; + } + + 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 { @@ -6196,6 +6160,46 @@ 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. + * @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; /** * This method is like _.curry except that arguments are applied to func in the manner of _.partialRight * instead of _.partial. @@ -6204,8 +6208,8 @@ declare module _ { * @return Returns the new curried function. */ curryRight( - func: Function, - arity?: number): TResult; + func: Function, + arity?: number): TResult; } interface LoDashObjectWrapper { @@ -7180,10 +7184,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; } /******** @@ -7208,6 +7220,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 * **********/ @@ -7243,6 +7359,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 +9578,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 { /** 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"; 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 diff --git a/moment/moment-node.d.ts b/moment/moment-node.d.ts index 9490d0320..c67b4f742 100644 --- a/moment/moment-node.d.ts +++ b/moment/moment-node.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Moment.js 2.10.6 +// Type definitions for Moment.js 2.8.0 // Project: https://github.com/timrwood/moment // Definitions by: Michael Lakerveld , Aaron King , Hiroki Horiuchi , Dick van den Brink , Adi Dahiya , Matt Brooks // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -303,7 +303,7 @@ declare module moment { get(unit: string): number; set(unit: string, value: number): Moment; - set(input: MomentInput): Moment; + set(objectLiteral: MomentInput): Moment; } type formatFunction = () => string; @@ -454,8 +454,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; diff --git a/react-input-calendar/react-input-calendar-tests.tsx b/react-input-calendar/react-input-calendar-tests.tsx new file mode 100644 index 000000000..127106424 --- /dev/null +++ b/react-input-calendar/react-input-calendar-tests.tsx @@ -0,0 +1,6 @@ +/// +/// + +import * as ReactInputCalendar from 'react-input-calendar'; +import * as React from 'react'; +React.render(, document.body); 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 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..d8c518b83 --- /dev/null +++ b/react-input-calendar/react-input-calendar.d.ts @@ -0,0 +1,59 @@ +// 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 { + /** + * 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 +} diff --git a/roslib/roslib-tests.ts b/roslib/roslib-tests.ts new file mode 100644 index 000000000..c209b4a0c --- /dev/null +++ b/roslib/roslib-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' +}); diff --git a/roslib/roslib.d.ts b/roslib/roslib.d.ts new file mode 100644 index 000000000..667a37983 --- /dev/null +++ b/roslib/roslib.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) : void; + connect(url: string) : void; + } + + + export class Service { + constructor(data: { + ros: Ros, + name: string, + serviceType: string + }); + } +} 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; diff --git a/sortablejs/sortablejs-tests.ts b/sortablejs/sortablejs-tests.ts new file mode 100755 index 000000000..56b8b0a32 --- /dev/null +++ b/sortablejs/sortablejs-tests.ts @@ -0,0 +1,299 @@ +// 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: any, iterator: number) { + return `
item ${iterator + 1}
`; +}).join(''); + +Sortable.create(simpleList, { + delay: 500, + chosenClass: 'chosen' +}); + +simpleList.innerHTML = Array.apply(null, new Array(10)).map(function(value: any, iterator: number) { + return '
item ' + + (iterator + 1) + + '
'; +}).join(''); + +Sortable.create(simpleList, {}); + +simpleList.innerHTML = Array.apply(null, new Array(100)).map(function(value: any, iterator: number) { + return '
item ' + + (iterator + 1) + + '
'; +}).join(''); + +(function() { + 'use strict'; + + var byId = function(id: string) { return document.getElementById(id); }, + + 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: number, + name = deps[idx], + script = document.createElement('script'); + + script.type = 'text/javascript'; + script.src = desc[deps[idx]]; + + 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: any) { + 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: any) { + 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: any) { + $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: any) { + count += todo.done ? 0 : 1; + }); + return count; + }; + + $scope.archive = function() { + var oldTodos = $scope.todos; + $scope.todos = []; + angular.forEach(oldTodos, function(todo: any) { + if (!todo.done) $scope.todos.push(todo); + }); + }; + }]) + .controller('TodoControllerNext', ['$scope', function($scope: any) { + $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: any) { + count += todo.done ? 0 : 1; + }); + return count; + }; + + $scope.sortableConfig = { group: 'todo', animation: 150 }; + 'Start End Add Update Remove Sort'.split(' ').forEach(function(name: string) { + $scope.sortableConfig['on' + name] = console.log.bind(console, name); + }); + }]); +})(); + +// Background +document.addEventListener("DOMContentLoaded", function() { + function setNoiseBackground(el: any, width: number, height: number, opacity: number) { + 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/sortablejs/sortablejs.d.ts b/sortablejs/sortablejs.d.ts new file mode 100755 index 000000000..a471a4e69 --- /dev/null +++ b/sortablejs/sortablejs.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 SortableUtils { + /** + * 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: SortableUtils; + + /** + * 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; +} diff --git a/ui-grid/ui-grid.d.ts b/ui-grid/ui-grid.d.ts index 481326b13..8b67f649b 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 */ @@ -718,6 +722,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