From 90e1dab8cd073844547e77ff41eb37a13ca97d11 Mon Sep 17 00:00:00 2001 From: Ben Date: Sun, 6 Sep 2015 14:29:02 -0400 Subject: [PATCH 01/89] Updated for version 1.4.1, jsdoc documentaiton Updated jquery.cookie.d.ts to conform to the latest version of jquery.cookie (1.4.1). This meant adding a defaults property to the JQueryCookieStatic interface. Also added missing jsdoc documentation for better intellisense for editors that support it. The documentation uses the Github repo documentation where possible. --- jquery.cookie/jquery.cookie.d.ts | 84 +++++++++++++++++++++++++++++--- 1 file changed, 78 insertions(+), 6 deletions(-) diff --git a/jquery.cookie/jquery.cookie.d.ts b/jquery.cookie/jquery.cookie.d.ts index 06380f999a..be88ca3638 100644 --- a/jquery.cookie/jquery.cookie.d.ts +++ b/jquery.cookie/jquery.cookie.d.ts @@ -1,34 +1,106 @@ -// Type definitions for jQuery Cookie Plugin 1.3 +// Type definitions for jQuery Cookie Plugin 1.4.1 // Project: https://github.com/carhartl/jquery-cookie -// Definitions by: Roy Goode +// Definitions by: Roy Goode , Ben Lorantfy // Definitions: https://github.com/borisyankov/DefinitelyTyped /// interface JQueryCookieOptions { + /** + * Define lifetime of the cookie. Value can be a Number which will be interpreted as days from time of creation or a Date object. If omitted, the cookie becomes a session cookie. + */ expires?: any; + /** + * Define the path where the cookie is valid. By default the path of the cookie is the path of the page where the cookie was created (standard browser behavior). If you want to make it available for instance across the entire domain use path: '/'. Default: path of page where the cookie was created. + */ path?: string; + /** + * Define the domain where the cookie is valid. Default: domain of page where the cookie was created. + */ domain?: string; + /** + * If true, the cookie transmission requires a secure protocol (https). Default: false. + */ secure?: boolean; } - +// +// The following jsdoc comments are used to add intellisense to editors that support it. Uses snippets +// of documentation from the Github repo when possible. +// +// The ordering here matters. For example, the read function with the converter parameter is purposefully after +// the set function. This is because the intellisense that shows up after you press comma should be the set first, +// since that is more common, then the conversion function if user starts typing a parameter with a function type interface JQueryCookieStatic { + /** + * By default the cookie value is encoded/decoded when writing/reading, using encodeURIComponent/decodeURIComponent. Bypass this by setting raw to true: + */ raw?: boolean; + /** + * Turn on automatic storage of JSON objects passed as the cookie value. Assumes JSON.stringify and JSON.parse + */ json?: boolean; - + /** + * Cookie attributes can be set globally by setting properties of the $.cookie.defaults object or individually for each call to $.cookie() by passing a plain object to the options argument. Per-call options override the default options. + */ + defaults?: JQueryCookieOptions; + /** + * Gets an object of cookies as key-value pairs + */ (): {[key:string]:string}; + /** + * Gets a cookie by name + * @param name The name of the cookie to get + */ (name: string): any; - (name: string, converter: (value: string) => any): any; + /** + * Sets a cookie + * @param name The name of the cookie to set + * @param value The value to set the cookie to + */ (name: string, value: string): void; + /** + * Gets a cookie by name after applying a conversion function to the value + * @param name The name of the cookie to get + * @param converter A conversion function to change the cookie's value to a different representation on the fly + */ + (name: string, converter: (value: string) => any): any; + /** + * Sets a cookie with some options + * @param name The name of the cookie to set + * @param value The value to set the cookie to + * @param options An object of options that change how the cookie is set + */ (name: string, value: string, options: JQueryCookieOptions): void; + /** + * Sets a cookie using .toString(), or if $.cookie.json is set to true using JSON.stringify() + * @param name The name of the cookie to set + * @param value The value to set the cookie to + */ (name: string, value: any): void; + /** + * Sets a cookie using .toString(), or if $.cookie.json is set to true using JSON.stringify() + * @param name The name of the cookie to set + * @param value The value to set the cookie to + * @param options An object of options that change how the cookie is set + */ (name: string, value: any, options: JQueryCookieOptions): void; } interface JQueryStatic { + /** + * A simple, lightweight jQuery plugin for reading, writing and deleting cookies. + */ cookie?: JQueryCookieStatic; - + /** + * Deletes a cookie + * @param name Name of cookie to delete + */ removeCookie(name: string): boolean; + /** + * Deletes a cookie + * @param name Name of cookie to delete + * @param options The same attributes (path, domain) as what the cookie was written with + */ removeCookie(name: string, options: JQueryCookieOptions): boolean; } From d2bf7eed77d8704ca03555d0b60071bb3ae0d7ee Mon Sep 17 00:00:00 2001 From: Ben Date: Sun, 6 Sep 2015 14:33:02 -0400 Subject: [PATCH 02/89] Updated to test new defaults property --- jquery.cookie/jquery.cookie-tests.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/jquery.cookie/jquery.cookie-tests.ts b/jquery.cookie/jquery.cookie-tests.ts index 69a8c04120..ab9b8cb5a7 100644 --- a/jquery.cookie/jquery.cookie-tests.ts +++ b/jquery.cookie/jquery.cookie-tests.ts @@ -35,3 +35,5 @@ $.cookie("test", testObject, cookieOptions); var result = $.cookie("test"); console.log(result.text); + +$.cookie.defaults = cookieOptions; From 4a86ba7d7f9227dc68c970f05dd667992fd8f40a Mon Sep 17 00:00:00 2001 From: Ryan McNamara Date: Wed, 9 Sep 2015 11:19:57 -0700 Subject: [PATCH 03/89] added definitely typed files and tests for flowjs and ngflow --- flowjs/flow/flowjs-tests.ts | 78 ++++++++++++++++++++++++++++++ flowjs/flow/flowjs.d.ts | 85 +++++++++++++++++++++++++++++++++ flowjs/ng-flow/ng-flow-tests.ts | 4 ++ flowjs/ng-flow/ng-flow.d.ts | 11 +++++ 4 files changed, 178 insertions(+) create mode 100644 flowjs/flow/flowjs-tests.ts create mode 100644 flowjs/flow/flowjs.d.ts create mode 100644 flowjs/ng-flow/ng-flow-tests.ts create mode 100644 flowjs/ng-flow/ng-flow.d.ts diff --git a/flowjs/flow/flowjs-tests.ts b/flowjs/flow/flowjs-tests.ts new file mode 100644 index 0000000000..8bedad0036 --- /dev/null +++ b/flowjs/flow/flowjs-tests.ts @@ -0,0 +1,78 @@ +/// + +// flow object +var flowObject: flowjs.IFlow; +var bool: boolean = flowObject.support; +bool = flowObject.supportDirectory; +var obj: Object = flowObject.opts; +var flowFileArray: flowjs.IFlowFile[] = flowObject.files; + +flowObject.assignBrowse( [], false, false, {}); +flowObject.assignDrop( []); +flowObject.unAssignDrop( []); +flowObject.on("", () => {}); +flowObject.off("", () => {}); +flowObject.upload(); +flowObject.pause(); +flowObject.resume(); +flowObject.cancel(); +flowObject.progress(); +bool = flowObject.isUploading(); +flowObject.addFile( {}); +flowObject.removeFile( {}); +var flowFile: flowjs.IFlowFile = flowObject.getFromUniqueIdentifier(""); +var num: number = flowObject.getSize(); +num = flowObject.sizeUploaded(); +num = flowObject.timeRemaining(); + +// flow options +var flowOptions: flowjs.IFlowOptions = {}; +flowOptions.target = ""; +flowOptions.singleFile = true; +flowOptions.chunkSize= 0; +flowOptions.forceChunkSize = true; +flowOptions.simultaneousUploads= 0; +flowOptions.fileParameterName = ""; +flowOptions.query = {}; +flowOptions.headers = {}; +flowOptions.withCredentials = true; +flowOptions.method = ""; +flowOptions.testMethod = ""; +flowOptions.uploadMethod = ""; +flowOptions.allowDuplicateUploads = true; +flowOptions.prioritizeFirstAndLastChunk = true; +flowOptions.testchunks = true; +flowOptions.preprocess = () => {}; +flowOptions.initFileFn = () => {}; +flowOptions.generateUniqueIdentifier = () => {}; +flowOptions.maxChunkRetries= 0; +flowOptions.chunkRetryInterval= 0; +flowOptions.progressCallbacksInterval= 0; +flowOptions.speedSmoothingFactor= 0; +flowOptions.successStatuses = [""]; +flowOptions.permanentErrors = [""]; + +// flow file +flowObject = flowFile.flowObj; +var htmlFile: File = flowFile.file; +var str: string = flowFile.name; +str = flowFile.relativePath; +num = flowFile.size; +str = flowFile.uniqueIdentifier; +num = flowFile.averageSpeed; +num = flowFile.currentSpeed; +var anyArray: any[] = flowFile.chunks; +bool = flowFile.paused; +bool = flowFile.error; +num = flowFile.progress(true); +flowFile.pause(); +flowFile.resume(); +flowFile.cancel(); +flowFile.retry(); +flowFile.bootstrap(); +bool = flowFile.isUploading(); +bool = flowFile.isComplete; +num = flowFile.sizeUploaded; +num = flowFile.timeRemaining; +str = flowFile.getExtension; +str = flowFile.getType; diff --git a/flowjs/flow/flowjs.d.ts b/flowjs/flow/flowjs.d.ts new file mode 100644 index 0000000000..e9e90055b2 --- /dev/null +++ b/flowjs/flow/flowjs.d.ts @@ -0,0 +1,85 @@ +// Type definitions for flowjs +// Project: https://github.com/flowjs/flow.js +// Definitions by: Ryan McNamara +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module flowjs { + interface IFlow { + support: boolean; + supportDirectory: boolean; + opts: Object; + files: IFlowFile[]; + + assignBrowse(domNodes: HTMLElement[], isDirectory: boolean, singleFile: boolean, attributes: Object): void; + assignDrop(domNodes: HTMLElement[]): void; + unAssignDrop(domNodes: HTMLElement[]): void; + on(event: string, callback: Function): void; + off(event?: string, callback?: Function): void; + upload(): void; + pause(): void; + resume(): void; + cancel(): void; + progress(): number; + isUploading(): boolean; + addFile(file: File): void; + removeFile(file: IFlowFile): void; + getFromUniqueIdentifier(uniqueIdentifier: string): IFlowFile; + getSize(): number; + sizeUploaded(): number; + timeRemaining(): number; + } + + interface IFlowOptions { + target?: string; + singleFile?: boolean; + chunkSize?: number; + forceChunkSize?: boolean; + simultaneousUploads?: number; + fileParameterName?: string; + query?: Object; + headers?: Object; + withCredentials?: boolean; + method?: string; + testMethod?: string; + uploadMethod?: string; + allowDuplicateUploads?: boolean; + prioritizeFirstAndLastChunk?: boolean; + testchunks?: boolean; + preprocess?: Function; + initFileFn?: Function; + generateUniqueIdentifier?: Function; + maxChunkRetries?: number; + chunkRetryInterval?: number; + progressCallbacksInterval?: number; + speedSmoothingFactor?: number; + successStatuses?: string[]; + permanentErrors?: string[]; + } + + interface IFlowFile { + flowObj: IFlow; + file: File; + name: string; + relativePath: string; + size: number; + uniqueIdentifier: string; + averageSpeed: number; + currentSpeed: number; + chunks: any[]; + paused: boolean; + error: boolean; + + progress(relative: boolean): number; + pause(): void; + resume(): void; + cancel(): void; + retry(): void; + bootstrap(): void; + isUploading(): boolean; + isComplete: boolean; + sizeUploaded: number; + timeRemaining: number; + getExtension: string; + getType: string; + } +} diff --git a/flowjs/ng-flow/ng-flow-tests.ts b/flowjs/ng-flow/ng-flow-tests.ts new file mode 100644 index 0000000000..beca6583c0 --- /dev/null +++ b/flowjs/ng-flow/ng-flow-tests.ts @@ -0,0 +1,4 @@ +/// + +var flowFactory: ng.flow.IFlowFactory; +flowFactory.create( {}); diff --git a/flowjs/ng-flow/ng-flow.d.ts b/flowjs/ng-flow/ng-flow.d.ts new file mode 100644 index 0000000000..4ea0afefe0 --- /dev/null +++ b/flowjs/ng-flow/ng-flow.d.ts @@ -0,0 +1,11 @@ +// Type definitions for ng-flow +// Project: https://github.com/flowjs/ng-flow +// Definitions by: Ryan McNamara +// Definitions: https://github.com/borisyankov/DefinitelyTyped +/// + +declare module ng.flow { + interface IFlowFactory { + create(options?: flowjs.IFlowOptions): flowjs.IFlow; + } +} From d450115aeffc58f11925d77c014e28f9d4fda866 Mon Sep 17 00:00:00 2001 From: Joe Skeen Date: Wed, 9 Sep 2015 15:52:16 -0600 Subject: [PATCH 04/89] fixed reference to the IGridRow type to refer to uiGrid.IGridRow within ui-grid plugins --- ui-grid/ui-grid.d.ts | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/ui-grid/ui-grid.d.ts b/ui-grid/ui-grid.d.ts index 5f66eca1f8..5cc3886f7a 100644 --- a/ui-grid/ui-grid.d.ts +++ b/ui-grid/ui-grid.d.ts @@ -1182,14 +1182,14 @@ declare module uiGrid { } export interface IRowColConstructor { - new (row: IGridRow, col: IGridColumn): IRowCol; + new (row: uiGrid.IGridRow, col: IGridColumn): IRowCol; } /** * A row and column pair that represents the intersection of these two entities */ export interface IRowCol { - row: IGridRow; + row: uiGrid.IGridRow; col: IGridColumn; /** * Gets the intersection of where the row and column meet @@ -1282,7 +1282,7 @@ declare module uiGrid { reader.readAsText( files[0] ); } */ - editFileChooserCallback?: (gridRow: IGridRow, gridCol: IGridColumn, files: FileList) => void; + editFileChooserCallback?: (gridRow: uiGrid.IGridRow, gridCol: IGridColumn, files: FileList) => void; /** * A bindable string value that is used when binding to edit controls instead of colDef.field * For example if you have a complex property on an object like: @@ -1558,7 +1558,7 @@ declare module uiGrid { * @param {any} value The cell value * @returns {any} Formatted value */ - exporterFieldCallback?: (grid: IGridInstance, row: IGridRow, col: IGridColumn, value: any) => any; + exporterFieldCallback?: (grid: IGridInstance, row: uiGrid.IGridRow, col: IGridColumn, value: any) => any; /** * A function to apply to the header displayNames before exporting. Useful for internationalisation, * for example if you were using angular-translate you'd set this to $translate.instant. @@ -2823,12 +2823,12 @@ declare module uiGrid { * returns all selected rows as gridRows * @returns {Array} The selected rows */ - getSelectedGridRows(): Array; + getSelectedGridRows(): Array; /** * Gets selected rows as entities * @returns {Array} Selected row entities */ - getSelectedRows(): Array; + getSelectedRows(): Array; /** * Selects all rows. Does nothing if multiselect = false * @param {ng.IAngularEvent} event object if raised from event @@ -2844,7 +2844,7 @@ declare module uiGrid { * @param {any} rowEntity gridOptions.data[] array value * @param {ng.IAngularEvent} event object if raised from event */ - selectRow(rowEntity: IGridRow, event?: ng.IAngularEvent): void; + selectRow(rowEntity: uiGrid.IGridRow, event?: ng.IAngularEvent): void; /** * Select the specified row by visible index * (i.e. if you specify row 0 you'll get the first visible row selected). @@ -2871,13 +2871,13 @@ declare module uiGrid { * @param {any} rowEntity gridOptions.data[] array value * @param {ng.IAngularEvent} event object if raised from event */ - toggleRowSelection(rowEntity: IGridRow, event?: ng.IAngularEvent): void; + toggleRowSelection(rowEntity: uiGrid.IGridRow, event?: ng.IAngularEvent): void; /** * UnSelect the data row * @param {any} rowEntity gridOptions.data[] array value * @param {ng.IAngularEvent} event object if raised from event */ - unSelectRow(rowEntity: IGridRow, event?: ng.IAngularEvent): void; + unSelectRow(rowEntity: uiGrid.IGridRow, event?: ng.IAngularEvent): void; // Events on: { @@ -2903,7 +2903,7 @@ declare module uiGrid { * @param {IGridRow} row The selected rows * @param {ng.IAngularEvent} event object if raised from event */ - (row: IGridRow, event?: ng.IAngularEvent): void; + (row: uiGrid.IGridRow, event?: ng.IAngularEvent): void; } export interface rowSelectionChangedBatchHandler { @@ -2912,7 +2912,7 @@ declare module uiGrid { * @param {IGridRow} row The selected rows * @param {ng.IAngularEvent} event object if raised from event */ - (row: Array, event?: ng.IAngularEvent): void; + (row: Array, event?: ng.IAngularEvent): void; } } From 2332fe2eaaed877248ac845491821cc5eb4179e5 Mon Sep 17 00:00:00 2001 From: Ritzlgrmft Date: Thu, 10 Sep 2015 10:36:36 +0200 Subject: [PATCH 05/89] Definitions added for Cordova plugin cordova-plugin-app-version (https://github.com/whiteoctober/cordova-plugin-app-version). --- cordova-plugin-app-version/appversion-tests.ts | 18 ++++++++++++++++++ cordova-plugin-app-version/appversion.d.ts | 8 ++++++++ 2 files changed, 26 insertions(+) create mode 100644 cordova-plugin-app-version/appversion-tests.ts create mode 100644 cordova-plugin-app-version/appversion.d.ts diff --git a/cordova-plugin-app-version/appversion-tests.ts b/cordova-plugin-app-version/appversion-tests.ts new file mode 100644 index 0000000000..89858c3e50 --- /dev/null +++ b/cordova-plugin-app-version/appversion-tests.ts @@ -0,0 +1,18 @@ +/// +/// +cordova.getAppVersion.getAppName() + .then(appName=> { + console.log(appName) + }); +cordova.getAppVersion.getPackageName() + .then(packageName=> { + console.log(packageName); + }); +cordova.getAppVersion.getVersionCode() + .then(versionCode=> { + console.log(versionCode); + }); +cordova.getAppVersion.getVersionNumber() + .then(versionNumber=> { + console.log(versionNumber); + }); \ No newline at end of file diff --git a/cordova-plugin-app-version/appversion.d.ts b/cordova-plugin-app-version/appversion.d.ts new file mode 100644 index 0000000000..4069e38daf --- /dev/null +++ b/cordova-plugin-app-version/appversion.d.ts @@ -0,0 +1,8 @@ +interface Cordova { + getAppVersion: { + getAppName: () => ng.IPromise; + getPackageName: () => ng.IPromise; + getVersionCode: () => ng.IPromise; + getVersionNumber: () => ng.IPromise; + }; +} \ No newline at end of file From 18c31c7a2519f4390dadeee0f9486764661c3826 Mon Sep 17 00:00:00 2001 From: Joe Skeen Date: Thu, 10 Sep 2015 07:15:14 -0600 Subject: [PATCH 06/89] change rowEntity type to be `any` --- ui-grid/ui-grid.d.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ui-grid/ui-grid.d.ts b/ui-grid/ui-grid.d.ts index 5cc3886f7a..c41cac7c6a 100644 --- a/ui-grid/ui-grid.d.ts +++ b/ui-grid/ui-grid.d.ts @@ -2823,12 +2823,12 @@ declare module uiGrid { * returns all selected rows as gridRows * @returns {Array} The selected rows */ - getSelectedGridRows(): Array; + getSelectedGridRows(): Array; /** * Gets selected rows as entities * @returns {Array} Selected row entities */ - getSelectedRows(): Array; + getSelectedRows(): Array; /** * Selects all rows. Does nothing if multiselect = false * @param {ng.IAngularEvent} event object if raised from event @@ -2844,7 +2844,7 @@ declare module uiGrid { * @param {any} rowEntity gridOptions.data[] array value * @param {ng.IAngularEvent} event object if raised from event */ - selectRow(rowEntity: uiGrid.IGridRow, event?: ng.IAngularEvent): void; + selectRow(rowEntity: any, event?: ng.IAngularEvent): void; /** * Select the specified row by visible index * (i.e. if you specify row 0 you'll get the first visible row selected). @@ -2871,13 +2871,13 @@ declare module uiGrid { * @param {any} rowEntity gridOptions.data[] array value * @param {ng.IAngularEvent} event object if raised from event */ - toggleRowSelection(rowEntity: uiGrid.IGridRow, event?: ng.IAngularEvent): void; + toggleRowSelection(rowEntity: any, event?: ng.IAngularEvent): void; /** * UnSelect the data row * @param {any} rowEntity gridOptions.data[] array value * @param {ng.IAngularEvent} event object if raised from event */ - unSelectRow(rowEntity: uiGrid.IGridRow, event?: ng.IAngularEvent): void; + unSelectRow(rowEntity: any, event?: ng.IAngularEvent): void; // Events on: { From 9d8cbdb263e5d69de355a24aeb1465c8400c924a Mon Sep 17 00:00:00 2001 From: Paul Jolly Date: Wed, 9 Sep 2015 16:05:42 +0100 Subject: [PATCH 07/89] Correctly type d3.event --- d3/d3-tests.ts | 86 ++++++++++++++++++++++++++------------------------ d3/d3.d.ts | 31 ++++++++++++++---- 2 files changed, 68 insertions(+), 49 deletions(-) diff --git a/d3/d3-tests.ts b/d3/d3-tests.ts index 105e8f29cc..414a2346ef 100644 --- a/d3/d3-tests.ts +++ b/d3/d3-tests.ts @@ -139,7 +139,7 @@ function groupedBarChart() { .style("text-anchor", "end") .text("Population"); - var state = svg.selectAll(".state") + var state = svg.selectAll(".state") .data(data) .enter().append("g") .attr("class", "g") @@ -672,8 +672,8 @@ function dragMultiples() { function dragmove(d: { x: number; y: number }) { d3.select(this) - .attr("cx", d.x = Math.max(radius, Math.min(width - radius, ( d3.event).x))) - .attr("cy", d.y = Math.max(radius, Math.min(height - radius, ( d3.event).y))); + .attr("cx", d.x = Math.max(radius, Math.min(width - radius, ( d3.event).x))) + .attr("cy", d.y = Math.max(radius, Math.min(height - radius, ( d3.event).y))); } } @@ -873,7 +873,7 @@ function populationPyramid() { // Allow the arrow keys to change the displayed year. window.focus(); d3.select(window).on("keydown", function () { - switch (d3.event.keyCode) { + switch (( d3.event).keyCode) { case 37: year = Math.max(year0, year - 10); break; case 39: year = Math.min(year1, year + 10); break; } @@ -1167,7 +1167,7 @@ function azimuthalEquidistant() { .translate([width / 2, height / 2]) .clipAngle(180 - 1e-3) .precision(.1); - + var path = d3.geo.path() .projection(projection); @@ -1209,7 +1209,7 @@ function azimuthalEquidistant() { d3.select(self.frameElement).style("height", height + "px"); } - + //Example from http://bl.ocks.org/mbostock/4060366 function voronoiTesselation() { var width = 960, @@ -1237,7 +1237,7 @@ function voronoiTesselation() { .attr("r", 2); redraw(); - + function redraw() { path = path.data(voronoi(vertices).map(function (d) { return "M" + d.join("L") + "Z"; } ), String); path.exit().remove(); @@ -1254,7 +1254,7 @@ function forceDirectedVoronoi() { simulate = true, zoomToAdd = true, color = d3.scale.quantize().domain([10000, 7250]).range(["#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"]) - + var numVertices = (w*h) / 3000; var vertices = d3.range(numVertices).map(function(i) { var angle = radius * (i+10); @@ -1266,15 +1266,15 @@ function forceDirectedVoronoi() { var prevEventScale = 1; var zoom = d3.behavior.zoom().on("zoom", function(d,i) { if (zoomToAdd){ - if (( d3.event).scale > prevEventScale) { - var angle = radius * vertices.length; - vertices.push({x: angle*Math.cos(angle)+(w/2), y: angle*Math.sin(angle)+(h/2)}) - } else if (vertices.length > 2 && ( d3.event).scale != prevEventScale) { - vertices.pop(); - } - force.nodes(vertices).start() + if (( d3.event).scale > prevEventScale) { + var angle = radius * vertices.length; + vertices.push({x: angle*Math.cos(angle)+(w/2), y: angle*Math.sin(angle)+(h/2)}) + } else if (vertices.length > 2 && ( d3.event).scale != prevEventScale) { + vertices.pop(); + } + force.nodes(vertices).start() } else { - if (( d3.event).scale > prevEventScale) { + if (( d3.event).scale > prevEventScale) { radius+= .01 } else { radius -= .01 @@ -1285,18 +1285,18 @@ function forceDirectedVoronoi() { }); force.nodes(vertices).start() } - prevEventScale = ( d3.event).scale; + prevEventScale = ( d3.event).scale; }); - + d3.select(window) .on("keydown", function() { // shift - if(d3.event.keyCode == 16) { + if(( d3.event).keyCode == 16) { zoomToAdd = false } - + // s - if(d3.event.keyCode == 83) { + if(( d3.event).keyCode == 83) { simulate = !simulate if(simulate) { force.start() @@ -1308,38 +1308,38 @@ function forceDirectedVoronoi() { .on("keyup", function() { zoomToAdd = true }) - + var svg = d3.select("#chart") .append("svg") .attr("width", w) .attr("height", h) .call(zoom) - + var force = d3.layout.force() .charge(-300) .size([w, h]) .on("tick", update); - + force.nodes(vertices).start(); - + var circle = > svg.selectAll("circle"); var path = > svg.selectAll("path"); var link = > svg.selectAll("line"); - + function update() { path = path.data(d3_geom_voronoi(vertices)); path.enter().append("path") // drag node by dragging cell .call(d3.behavior.drag() .on("drag", function(d, i) { - vertices[i] = {x: vertices[i].x + ( d3.event).dx, y: vertices[i].y + ( d3.event).dy} + vertices[i] = {x: vertices[i].x + ( d3.event).dx, y: vertices[i].y + ( d3.event).dy} }) ) .style("fill", function(d, i) { return color(0) }) path.attr("d", function(d) { return "M" + d.join("L") + "Z"; }) .transition().duration(150).style("fill", function(d, i) { return color(d3.geom.polygon(d).area()) }) path.exit().remove(); - + circle = circle.data(vertices) circle.enter().append("circle") .attr("r", 0) @@ -1347,16 +1347,16 @@ function forceDirectedVoronoi() { circle.attr("cx", function(d) { return d.x; }) .attr("cy", function(d) { return d.y; }); circle.exit().transition().attr("r", 0).remove(); - + link = link.data(d3_geom_voronoi.links(vertices)) link.enter().append("line") link.attr("x1", function(d) { return d.source.x; }) .attr("y1", function(d) { return d.source.y; }) .attr("x2", function(d) { return d.target.x; }) .attr("y2", function(d) { return d.target.y; }) - + link.exit().remove() - + if(!simulate) force.stop() } } @@ -1521,7 +1521,7 @@ module hierarchicalEdgeBundling { .value(function (d) { return d.size; } ); var bundle = d3.layout.bundle(); - + var line = d3.svg.line.radial() .interpolate("bundle") .tension(.85) @@ -1851,7 +1851,7 @@ function chordDiagram() { [8010, 16145, 8090, 8045], [1013, 990, 940, 6907] ]; - + var chord = d3.layout.chord() .padding(.05) .sortSubgroups(d3.descending) @@ -2031,7 +2031,7 @@ function irisParallel() { } function drag(d: string) { - x.range()[i] = ( d3.event).x; + x.range()[i] = ( d3.event).x; traits.sort(function (a, b) { return x(a) - x(b); } ); g.attr("transform", function (d) { return "translate(" + x(d) + ")"; } ); foreground.attr("d", path); @@ -2085,14 +2085,14 @@ function healthAndWealth() { // The x & y axes. var xAxis = d3.svg.axis().orient("bottom").scale(xScale).ticks(12, d3.format(",d")), yAxis = d3.svg.axis().scale(yScale).orient("left"); - + // Create the SVG container and set the origin. var svg = d3.select("#chart").append("svg") .attr("width", width + margin.left + margin.right) .attr("height", height + margin.top + margin.bottom) .append("g") .attr("transform", "translate(" + margin.left + "," + margin.top + ")"); - + // Add the x-axis. svg.append("g") .attr("class", "x axis") @@ -2152,7 +2152,7 @@ function healthAndWealth() { // Add an overlay for the year label. var box = (label.node()).getBBox(); - + var overlay = svg.append("rect") .attr("class", "overlay") .attr("x", box.x) @@ -2669,12 +2669,14 @@ function multiTest() { function testD3Events () { d3.select('svg') .on('click', () => { - var coords = [d3.event.pageX, d3.event.pageY]; - console.log("clicked", d3.event.target, "at " + coords); + let e = d3.event; + var coords = [e.pageX, e.pageY]; + console.log("clicked", e.target, "at " + coords); }) .on('keypress', () => { - if (d3.event.shiftKey) { - console.log('shift + ' + d3.event.which); + let e = d3.event; + if (e.shiftKey) { + console.log('shift + ' + e.which); } }); } @@ -2690,4 +2692,4 @@ function testD3MutlieTimeFormat() { ["%B", function(d) { return d.getMonth(); }], ["%Y", function() { return true; }] ]); -} \ No newline at end of file +} diff --git a/d3/d3.d.ts b/d3/d3.d.ts index ef3909e9fc..2d1b20c3bc 100644 --- a/d3/d3.d.ts +++ b/d3/d3.d.ts @@ -807,7 +807,7 @@ declare module d3 { interface Transition { transition(): Transition; - + delay(): number; delay(delay: number): Transition; delay(delay: (datum: Datum, index: number, outerIndex: number) => number): Transition; @@ -920,16 +920,33 @@ declare module d3 { export function flush(): void; } - /** - * Interface for any and all d3 events. - */ - interface Event extends KeyboardEvent, MouseEvent { - } + interface BaseEvent { + type: string; + sourceEvent?: Event; + } + + /** + * Define a D3-specific ZoomEvent per https://github.com/mbostock/d3/wiki/Zoom-Behavior#event + */ + interface ZoomEvent extends BaseEvent { + scale: number; + translate: [number, number]; + } + + /** + * Define a D3-specific DragEvent per https://github.com/mbostock/d3/wiki/Drag-Behavior#on + */ + interface DragEvent extends BaseEvent { + x: number; + y: number; + dx: number; + dy: number; + } /** * The current event's value. Use this variable in a handler registered with `selection.on`. */ - export var event: Event; + export var event: Event | BaseEvent; /** * Returns the x and y coordinates of the mouse relative to the provided container element, using d3.event for the mouse's position on the page. From b33f6c6dedba3dd7d251408008f1d0ab995e4fe0 Mon Sep 17 00:00:00 2001 From: David Pfeffer Date: Thu, 10 Sep 2015 14:59:43 -0400 Subject: [PATCH 08/89] Maintains type safety through a safeApply. --- rx-angular/rx.angular.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rx-angular/rx.angular.d.ts b/rx-angular/rx.angular.d.ts index e2d0ec8c5e..2b82e529af 100644 --- a/rx-angular/rx.angular.d.ts +++ b/rx-angular/rx.angular.d.ts @@ -10,7 +10,7 @@ declare module Rx { interface IObservable { - safeApply($scope: ng.IScope, callback: (data: any) => void): Rx.Observable; + safeApply($scope: ng.IScope, callback: (data: T) => void): Rx.Observable; } } From 812e510f7da9910aa81eed3dc0c60ec5686a1257 Mon Sep 17 00:00:00 2001 From: diontools Date: Fri, 11 Sep 2015 18:28:51 +0900 Subject: [PATCH 09/89] SwipeRecognizer extends AttrRecognizer --- hammerjs/hammerjs.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hammerjs/hammerjs.d.ts b/hammerjs/hammerjs.d.ts index 84d4f94319..4d1091f68e 100644 --- a/hammerjs/hammerjs.d.ts +++ b/hammerjs/hammerjs.d.ts @@ -302,7 +302,7 @@ interface SwipeRecognizerStatic new( options?:any ):SwipeRecognizer; } -interface SwipeRecognizer +interface SwipeRecognizer extends AttrRecognizer { } From 535bdcd579be3ff7311d374b79dc0ced6dedc0bb Mon Sep 17 00:00:00 2001 From: Joe Skeen Date: Fri, 11 Sep 2015 09:16:33 -0600 Subject: [PATCH 10/89] Fix getSelectedGridRows() for ui-grid --- ui-grid/ui-grid.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui-grid/ui-grid.d.ts b/ui-grid/ui-grid.d.ts index c41cac7c6a..05ba92a8ca 100644 --- a/ui-grid/ui-grid.d.ts +++ b/ui-grid/ui-grid.d.ts @@ -2823,7 +2823,7 @@ declare module uiGrid { * returns all selected rows as gridRows * @returns {Array} The selected rows */ - getSelectedGridRows(): Array; + getSelectedGridRows(): Array; /** * Gets selected rows as entities * @returns {Array} Selected row entities From 633cd9b7d880c28360d08f4e9686ef8e60d52774 Mon Sep 17 00:00:00 2001 From: pdeva Date: Sat, 12 Sep 2015 16:16:35 -0700 Subject: [PATCH 11/89] Added compose() function declaration --- redux/redux.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/redux/redux.d.ts b/redux/redux.d.ts index 1f33d1559e..1bcbedc63b 100644 --- a/redux/redux.d.ts +++ b/redux/redux.d.ts @@ -44,8 +44,9 @@ declare module Redux { function bindActionCreators(actionCreators: T, dispatch: Dispatch): T; function combineReducers(reducers: any): Reducer; function applyMiddleware(...middleware: Middleware[]): Function; + function compose(...functions: Function[]): T; } declare module "redux" { export = Redux; -} \ No newline at end of file +} From 3dffe331ad08084d81dee02b7aa727bd0037a9b6 Mon Sep 17 00:00:00 2001 From: Alexander Rusakov Date: Fri, 11 Sep 2015 18:23:51 +0300 Subject: [PATCH 12/89] redux-logger.d.ts --- redux-logger/redux-logger-tests.ts | 19 +++++++++++++++++++ redux-logger/redux-logger.d.ts | 20 ++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 redux-logger/redux-logger-tests.ts create mode 100644 redux-logger/redux-logger.d.ts diff --git a/redux-logger/redux-logger-tests.ts b/redux-logger/redux-logger-tests.ts new file mode 100644 index 0000000000..c57e721770 --- /dev/null +++ b/redux-logger/redux-logger-tests.ts @@ -0,0 +1,19 @@ +/// + +import createLogger from 'redux-logger'; +import { applyMiddleware, createStore } from 'redux' + +let logger = createLogger(); + +let loggerWithOpts = createLogger({ + collapsed: true, + level: 'warn', + logger: console.log, + timestamp: false, + transformer: state => state, + predicate: (getState, action) => true +}); + +let createStoreWithMiddleware = applyMiddleware( + logger, loggerWithOpts +)(createStore); diff --git a/redux-logger/redux-logger.d.ts b/redux-logger/redux-logger.d.ts new file mode 100644 index 0000000000..cc014b1585 --- /dev/null +++ b/redux-logger/redux-logger.d.ts @@ -0,0 +1,20 @@ +// Type definitions for redux-logger v1.0.6 +// Project: https://github.com/fcomb/redux-logger +// Definitions by: Alexander Rusakov +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module 'redux-logger' { + + interface ReduxLoggerOptions { + collapsed?: boolean; + level?: string; + logger?: any; + timestamp?: boolean; + transformer?: (state:any)=>any, + predicate?: (getState:Function, action:any)=>any + } + + export default function createLogger(options?:ReduxLoggerOptions):Redux.Middleware; +} From 24253c8064c1b20cfb64196aec5d0aa205b673ad Mon Sep 17 00:00:00 2001 From: Trapulo Date: Mon, 14 Sep 2015 12:07:30 +0200 Subject: [PATCH 13/89] CircularChartData color optional according to documentation, color is optional http://www.chartjs.org/docs/#doughnut-pie-chart --- chartjs/chart.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chartjs/chart.d.ts b/chartjs/chart.d.ts index 9da7245f61..d337d144a6 100644 --- a/chartjs/chart.d.ts +++ b/chartjs/chart.d.ts @@ -27,7 +27,7 @@ interface LinearChartData { interface CircularChartData { value: number; - color: string; + color?: string; highlight?: string; label?: string; } From f4a7e67bf7986e7a22123b9728848517a6585c4d Mon Sep 17 00:00:00 2001 From: Alexander Rusakov Date: Mon, 14 Sep 2015 16:38:25 +0300 Subject: [PATCH 14/89] semicolons --- redux-logger/redux-logger.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/redux-logger/redux-logger.d.ts b/redux-logger/redux-logger.d.ts index cc014b1585..28b53f3a1c 100644 --- a/redux-logger/redux-logger.d.ts +++ b/redux-logger/redux-logger.d.ts @@ -12,8 +12,8 @@ declare module 'redux-logger' { level?: string; logger?: any; timestamp?: boolean; - transformer?: (state:any)=>any, - predicate?: (getState:Function, action:any)=>any + transformer?: (state:any)=>any; + predicate?: (getState:Function, action:any)=>any; } export default function createLogger(options?:ReduxLoggerOptions):Redux.Middleware; From d0a264d5fff335375f32d643db5054b03983c3ed Mon Sep 17 00:00:00 2001 From: "Ciuca, Alexandru" Date: Mon, 14 Sep 2015 16:55:47 +0300 Subject: [PATCH 15/89] angularjs - better granularity for filter service parameter types --- angularjs/angular-tests.ts | 16 ++++++++++++++++ angularjs/angular.d.ts | 18 +++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/angularjs/angular-tests.ts b/angularjs/angular-tests.ts index 50e7562178..0174a0d616 100644 --- a/angularjs/angular-tests.ts +++ b/angularjs/angular-tests.ts @@ -933,3 +933,19 @@ function NgModelControllerTyping() { }); }; } + +function ngFilterTyping() { + var $filter: angular.IFilterService; + var items: string[]; + + $filter("name")(items, "test"); + $filter("name")(items, {name: "test"}); + $filter("name")(items, (val, index, array) => { + return array; + }); + $filter("name")(items, (val, index, array) => { + return array; + }, (actual, expected) => { + return actual == expected; + }); +} \ No newline at end of file diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts index d183167b59..be0b0861a9 100644 --- a/angularjs/angular.d.ts +++ b/angularjs/angular.d.ts @@ -782,7 +782,23 @@ declare module angular { * * @param name Name of the filter function to retrieve */ - (name: string): Function; + (name: string): IFilterFunc; + } + + interface IFilterFunc { + (array: T[], expression: string | IFilterPatternObject | IFilterPredicateFunc, comparator?: IFilterComparatorFunc|boolean): T[]; + } + + interface IFilterPatternObject { + [name: string]: string; + } + + interface IFilterPredicateFunc { + (value: T, index: number, array: T[]): T[]; + } + + interface IFilterComparatorFunc { + (actual: T, expected: T): boolean; } /** From 5ee16d32e4c50575e6ef2ee9e99fedd17d2b7abc Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Mon, 14 Sep 2015 16:22:05 +0200 Subject: [PATCH 16/89] typings for precond library added --- precond/precond-tests.ts | 43 ++++++++++++++++++++++++++++++ precond/precond-tests.ts.tscparams | 1 + precond/precond.d.ts | 17 ++++++++++++ 3 files changed, 61 insertions(+) create mode 100644 precond/precond-tests.ts create mode 100644 precond/precond-tests.ts.tscparams create mode 100644 precond/precond.d.ts diff --git a/precond/precond-tests.ts b/precond/precond-tests.ts new file mode 100644 index 0000000000..dc843e99f4 --- /dev/null +++ b/precond/precond-tests.ts @@ -0,0 +1,43 @@ +/// + +import precond = require('precond'); + +precond.checkArgument(true); +precond.checkArgument(true, "msg"); +precond.checkArgument(true, "%s %s %s", 1, "two"); + +precond.checkState(true); +precond.checkState(true, "msg"); +precond.checkState(true, "%s %s %s", 1, "two"); + +precond.checkIsDef(true); +precond.checkIsDef(true, "msg"); +precond.checkIsDef(true, "%s %s %s", 1, "two"); + +precond.checkIsDefAndNotNull(true); +precond.checkIsDefAndNotNull(true, "msg"); +precond.checkIsDefAndNotNull(true, "%s %s %s", 1, "two"); + +precond.checkIsString(true); +precond.checkIsString(true, "msg"); +precond.checkIsString(true, "%s %s %s", 1, "two"); + +precond.checkIsArray(true); +precond.checkIsArray(true, "msg"); +precond.checkIsArray(true, "%s %s %s", 1, "two"); + +precond.checkIsNumber(true); +precond.checkIsNumber(true, "msg"); +precond.checkIsNumber(true, "%s %s %s", 1, "two"); + +precond.checkIsBoolean(true); +precond.checkIsBoolean(true, "msg"); +precond.checkIsBoolean(true, "%s %s %s", 1, "two"); + +precond.checkIsFunction(true); +precond.checkIsFunction(true, "msg"); +precond.checkIsFunction(true, "%s %s %s", 1, "two"); + +precond.checkIsObject(true); +precond.checkIsObject(true, "msg"); +precond.checkIsObject(true, "%s %s %s", 1, "two"); \ No newline at end of file diff --git a/precond/precond-tests.ts.tscparams b/precond/precond-tests.ts.tscparams new file mode 100644 index 0000000000..2988d8fd66 --- /dev/null +++ b/precond/precond-tests.ts.tscparams @@ -0,0 +1 @@ +--noImplicitAny --module commonjs \ No newline at end of file diff --git a/precond/precond.d.ts b/precond/precond.d.ts new file mode 100644 index 0000000000..ef5362468a --- /dev/null +++ b/precond/precond.d.ts @@ -0,0 +1,17 @@ +// Type definitions for precond 0.2.3 +// Project: https://github.com/MathieuTurcotte/node-precond +// Definitions by: Oliver Schneider +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module "precond" { + export function checkArgument(value: any, message?: string, ...formatArgs: any[]): void; + export function checkState(value: any, message?: string, ...formatArgs: any[]): void; + export function checkIsDef(value: any, message?: string, ...formatArgs: any[]): any; + export function checkIsDefAndNotNull(value: any, message?: string, ...formatArgs: any[]): any; + export function checkIsString(value: any, message?: string, ...formatArgs: any[]): any; + export function checkIsArray(value: any, message?: string, ...formatArgs: any[]): any; + export function checkIsNumber(value: any, message?: string, ...formatArgs: any[]): any; + export function checkIsBoolean(value: any, message?: string, ...formatArgs: any[]): any; + export function checkIsFunction(value: any, message?: string, ...formatArgs: any[]): any; + export function checkIsObject(value: any, message?: string, ...formatArgs: any[]): any; +} \ No newline at end of file From ec7f772c2b8393af26b22c999f5bf2601fa9bc00 Mon Sep 17 00:00:00 2001 From: Morris Allison III Date: Mon, 14 Sep 2015 12:50:31 -0400 Subject: [PATCH 17/89] Add the "replace" option to "router.navigate()" See Backbone documentation for the option here: http://backbonejs.org/#Router-navigate --- backbone/backbone.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/backbone/backbone.d.ts b/backbone/backbone.d.ts index 701cc6d9dc..f7c5945ad3 100644 --- a/backbone/backbone.d.ts +++ b/backbone/backbone.d.ts @@ -19,6 +19,7 @@ declare module Backbone { interface NavigateOptions { trigger?: boolean; + replace?: boolean; } interface RouterOptions { From 2b368d620fdc997bbbf3c7913c19bfa9ce6aa55c Mon Sep 17 00:00:00 2001 From: Stephen Lautier Date: Mon, 14 Sep 2015 21:25:58 +0200 Subject: [PATCH 18/89] Added definitions for jasmine-es6-promise-matchers --- .../jasmine-es6-promise-matchers-tests.ts | 21 +++++++++++ .../jasmine-es6-promise-matchers.d.ts | 36 +++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 jasmine-es6-promise-matchers/jasmine-es6-promise-matchers-tests.ts create mode 100644 jasmine-es6-promise-matchers/jasmine-es6-promise-matchers.d.ts diff --git a/jasmine-es6-promise-matchers/jasmine-es6-promise-matchers-tests.ts b/jasmine-es6-promise-matchers/jasmine-es6-promise-matchers-tests.ts new file mode 100644 index 0000000000..d2917e7612 --- /dev/null +++ b/jasmine-es6-promise-matchers/jasmine-es6-promise-matchers-tests.ts @@ -0,0 +1,21 @@ +/// + +describe('specs', () => { + beforeEach(() => { + JasminePromiseMatchers.install + }); + + afterEach(() => { + JasminePromiseMatchers.uninstall + }); + + it('should have correct syntax', (done) => { + var foo = {}; + var bar = {}; + + expect(foo).toBeResolvedWith(bar, done); + expect(foo).toBeRejectedWith(bar, done); + expect(foo).toBeResolved(done); + expect(foo).toBeRejected(done); + }); +}) \ No newline at end of file diff --git a/jasmine-es6-promise-matchers/jasmine-es6-promise-matchers.d.ts b/jasmine-es6-promise-matchers/jasmine-es6-promise-matchers.d.ts new file mode 100644 index 0000000000..1735e51bcb --- /dev/null +++ b/jasmine-es6-promise-matchers/jasmine-es6-promise-matchers.d.ts @@ -0,0 +1,36 @@ +// Type definitions for jasmine-es6-promise-matchers +// Project: https://github.com/bvaughn/jasmine-es6-promise-matchers +// Definitions by: Stephen Lautier +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module JasminePromiseMatchers { + export function install():void; + export function uninstall():void; +} + +declare module jasmine { + + interface Matchers { + /** + * Verifies that a Promise is (or has been) rejected. + */ + toBeRejected(done?: () => void): boolean; + + /** + * Verifies that a Promise is (or has been) rejected with the specified parameter. + */ + toBeRejectedWith(value: any, done?: () => void): boolean; + + /** + * Verifies that a Promise is (or has been) resolved. + */ + toBeResolved(done?: () => void): boolean; + + /** + * Verifies that a Promise is (or has been) resolved with the specified parameter. + */ + toBeResolvedWith(value: any, done?: () => void): boolean; + } +} \ No newline at end of file From c2dc1fa32ed56f036f881ea9d9a9a2191792c004 Mon Sep 17 00:00:00 2001 From: tkqubo Date: Tue, 15 Sep 2015 05:03:14 +0900 Subject: [PATCH 19/89] Add core-decorators@0.1.5 --- core-decorators/core-decorators-tests.ts | 169 +++++++++++++++++++++++ core-decorators/core-decorators.d.ts | 89 ++++++++++++ 2 files changed, 258 insertions(+) create mode 100644 core-decorators/core-decorators-tests.ts create mode 100644 core-decorators/core-decorators.d.ts diff --git a/core-decorators/core-decorators-tests.ts b/core-decorators/core-decorators-tests.ts new file mode 100644 index 0000000000..e4a31432ba --- /dev/null +++ b/core-decorators/core-decorators-tests.ts @@ -0,0 +1,169 @@ +/// + +// +// @autobind +// + +import { autobind } from 'core-decorators'; + +class Person { + @autobind + getPerson() { + return this; + } +} + +let person = new Person(); +let getPerson = person.getPerson; + +getPerson() === person; + +// +// @readonly +// + +import { readonly } from 'core-decorators'; + +class Meal { + @readonly + entree: string = 'steak'; +} + +var dinner = new Meal(); +dinner.entree = 'salmon'; + +// +// @override +// + +import { override } from 'core-decorators'; + +class Parent { + speak(first: string, second: string) {} +} + +class Child extends Parent { + @override + speak() {} + // SyntaxError: Child#speak() does not properly override Parent#speak(first, second) +} + +// or + +class Child2 extends Parent { + @override + speaks() {} + // SyntaxError: No descriptor matching Child#speaks() was found on the prototype chain. + // + // Did you mean "speak"? +} + +// +// @deprecate (alias: @deprecated) +// + +import { deprecate, deprecated } from 'core-decorators'; + +class Person2 { + @deprecate + facepalm() {} + + @deprecate('We stopped facepalming') + facepalmHard() {} + + @deprecate('We stopped facepalming', { url: 'http://knowyourmeme.com/memes/facepalm' }) + facepalmHarder() {} +} + +let person2 = new Person2(); + +person2.facepalm(); +// DEPRECATION Person#facepalm: This function will be removed in future versions. + +person2.facepalmHard(); +// DEPRECATION Person#facepalmHard: We stopped facepalming + +person2.facepalmHarder(); +// DEPRECATION Person#facepalmHarder: We stopped facepalming +// +// See http://knowyourmeme.com/memes/facepalm for more details. +// + +// +// @debounce +// + +import { debounce } from 'core-decorators'; + +class Editor { + + content = ''; + + @debounce(500) + updateContent(content: string) { + this.content = content; + } +} + +// +// @suppressWarnings +// + +import { suppressWarnings } from 'core-decorators'; + +class Person3 { + @deprecated + facepalm() {} + + @suppressWarnings + facepalmWithoutWarning() { + this.facepalm(); + } +} + +let person3 = new Person3(); + +person3.facepalmWithoutWarning(); +// no warning is logged + +// +// @nonenumerable +// + +import { nonenumerable } from 'core-decorators'; + +class Meal2 { + entree = 'steak'; + + @nonenumerable + cost: number = 4.44; +} + +var dinner2 = new Meal2(); +for (var key in dinner2) { + key; + // "entree" only, not "cost" +} + +Object.keys(dinner2); +// ["entree"] + +// +// @nonconfigurable +// + +import { nonconfigurable } from 'core-decorators'; + +class Meal3 { + @nonconfigurable + entree: string = 'steak'; +} + +var dinner3 = new Meal3(); + +Object.defineProperty(dinner3, 'entree', { + enumerable: false +}); +// Cannot redefine property: entree + + diff --git a/core-decorators/core-decorators.d.ts b/core-decorators/core-decorators.d.ts new file mode 100644 index 0000000000..20ca4cfe8c --- /dev/null +++ b/core-decorators/core-decorators.d.ts @@ -0,0 +1,89 @@ +// Type definitions for core-decorators.js +// Project: https://github.com/jayphelps/core-decorators.js +// Definitions by: Qubo +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module "core-decorators" { + export interface ClassDecorator { + (target: TFunction): TFunction|void; + } + + export interface ParameterDecorator { + (target: Object, propertyKey: string|symbol, parameterIndex: number): void; + } + + export interface PropertyDecorator { + (target: Object, propertyKey: string|symbol): void; + } + + export interface MethodDecorator { + (target: Object, propertyKey: string|symbol, descriptor: TypedPropertyDescriptor): TypedPropertyDescriptor|void; + } + + export interface PropertyOrMethodDecorator extends MethodDecorator, PropertyDecorator { + (target: Object, propertyKey: string|symbol): void; + } + + export interface Deprecate extends MethodDecorator { + (message?: string, option?: DeprecateOption): MethodDecorator; + } + + export interface DeprecateOption { + url: string; + } + + /** + * Forces invocations of this function to always have this refer to the class instance, + * even if the function is passed around or would otherwise lose its this context. e.g. var fn = context.method; + */ + var autobind: MethodDecorator; + /** + * Marks a property or method as not being writable. + */ + var readonly: PropertyOrMethodDecorator; + /** + * Checks that the marked method indeed overrides a function with the same signature somewhere on the prototype chain. + */ + var override: MethodDecorator; + /** + * Calls console.warn() with a deprecation message. Provide a custom message to override the default one. You can also provide an options hash with a url, for further reading. + */ + var deprecate: Deprecate; + /** + * Calls console.warn() with a deprecation message. Provide a custom message to override the default one. You can also provide an options hash with a url, for further reading. + */ + var deprecated: Deprecate; + /** + * Creates a new debounced function which will be invoked after wait milliseconds since the time it was invoked. Default timeout is 300 ms. + */ + var debounce: (wait: number) => MethodDecorator; + /** + * Suppresses any JavaScript console.warn() call while the decorated function is called. (i.e. on the stack) + */ + var suppressWarnings: MethodDecorator; + /** + * Marks a property or method as not being enumerable. + */ + var nonenumerable: PropertyOrMethodDecorator; + /** + * Marks a property or method as not being writable. + */ + var nonconfigurable: PropertyOrMethodDecorator; + /** + * Initial implementation included, likely slow. WIP. + */ + var memoize: MethodDecorator; + + export { + autobind, + readonly, + override, + deprecate, + deprecated, + debounce, + suppressWarnings, + nonenumerable, + nonconfigurable, + memoize // WIP + }; +} From 097a226abdbdc8049377dcbbee5457b5c5284097 Mon Sep 17 00:00:00 2001 From: tkqubo Date: Tue, 15 Sep 2015 05:05:25 +0900 Subject: [PATCH 20/89] Add version to d.ts comment --- core-decorators/core-decorators.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core-decorators/core-decorators.d.ts b/core-decorators/core-decorators.d.ts index 20ca4cfe8c..160802fc1f 100644 --- a/core-decorators/core-decorators.d.ts +++ b/core-decorators/core-decorators.d.ts @@ -1,4 +1,4 @@ -// Type definitions for core-decorators.js +// Type definitions for core-decorators.js v0.1.5 // Project: https://github.com/jayphelps/core-decorators.js // Definitions by: Qubo // Definitions: https://github.com/borisyankov/DefinitelyTyped From 62a031c2b200b809eb8e442bc20cb1571bb70b31 Mon Sep 17 00:00:00 2001 From: tkqubo Date: Tue, 15 Sep 2015 05:20:11 +0900 Subject: [PATCH 21/89] Comment out all the test code --- core-decorators/core-decorators-tests.ts | 302 +++++++++++------------ 1 file changed, 151 insertions(+), 151 deletions(-) diff --git a/core-decorators/core-decorators-tests.ts b/core-decorators/core-decorators-tests.ts index e4a31432ba..7ec80d2f3c 100644 --- a/core-decorators/core-decorators-tests.ts +++ b/core-decorators/core-decorators-tests.ts @@ -1,169 +1,169 @@ -/// - +///// // -// @autobind +//// +//// @autobind +//// // - -import { autobind } from 'core-decorators'; - -class Person { - @autobind - getPerson() { - return this; - } -} - -let person = new Person(); -let getPerson = person.getPerson; - -getPerson() === person; - +//import { autobind } from 'core-decorators'; // -// @readonly +//class Person { +// @autobind +// getPerson() { +// return this; +// } +//} // - -import { readonly } from 'core-decorators'; - -class Meal { - @readonly - entree: string = 'steak'; -} - -var dinner = new Meal(); -dinner.entree = 'salmon'; - +//let person = new Person(); +//let getPerson = person.getPerson; // -// @override +//getPerson() === person; // - -import { override } from 'core-decorators'; - -class Parent { - speak(first: string, second: string) {} -} - -class Child extends Parent { - @override - speak() {} - // SyntaxError: Child#speak() does not properly override Parent#speak(first, second) -} - -// or - -class Child2 extends Parent { - @override - speaks() {} - // SyntaxError: No descriptor matching Child#speaks() was found on the prototype chain. - // - // Did you mean "speak"? -} - +//// +//// @readonly +//// // -// @deprecate (alias: @deprecated) +//import { readonly } from 'core-decorators'; // - -import { deprecate, deprecated } from 'core-decorators'; - -class Person2 { - @deprecate - facepalm() {} - - @deprecate('We stopped facepalming') - facepalmHard() {} - - @deprecate('We stopped facepalming', { url: 'http://knowyourmeme.com/memes/facepalm' }) - facepalmHarder() {} -} - -let person2 = new Person2(); - -person2.facepalm(); -// DEPRECATION Person#facepalm: This function will be removed in future versions. - -person2.facepalmHard(); -// DEPRECATION Person#facepalmHard: We stopped facepalming - -person2.facepalmHarder(); -// DEPRECATION Person#facepalmHarder: We stopped facepalming +//class Meal { +// @readonly +// entree: string = 'steak'; +//} // -// See http://knowyourmeme.com/memes/facepalm for more details. +//var dinner = new Meal(); +//dinner.entree = 'salmon'; // - +//// +//// @override +//// // -// @debounce +//import { override } from 'core-decorators'; // - -import { debounce } from 'core-decorators'; - -class Editor { - - content = ''; - - @debounce(500) - updateContent(content: string) { - this.content = content; - } -} - +//class Parent { +// speak(first: string, second: string) {} +//} // -// @suppressWarnings +//class Child extends Parent { +// @override +// speak() {} +// // SyntaxError: Child#speak() does not properly override Parent#speak(first, second) +//} // - -import { suppressWarnings } from 'core-decorators'; - -class Person3 { - @deprecated - facepalm() {} - - @suppressWarnings - facepalmWithoutWarning() { - this.facepalm(); - } -} - -let person3 = new Person3(); - -person3.facepalmWithoutWarning(); -// no warning is logged - +//// or // -// @nonenumerable +//class Child2 extends Parent { +// @override +// speaks() {} +// // SyntaxError: No descriptor matching Child#speaks() was found on the prototype chain. +// // +// // Did you mean "speak"? +//} // - -import { nonenumerable } from 'core-decorators'; - -class Meal2 { - entree = 'steak'; - - @nonenumerable - cost: number = 4.44; -} - -var dinner2 = new Meal2(); -for (var key in dinner2) { - key; - // "entree" only, not "cost" -} - -Object.keys(dinner2); -// ["entree"] - +//// +//// @deprecate (alias: @deprecated) +//// +// +//import { deprecate, deprecated } from 'core-decorators'; +// +//class Person2 { +// @deprecate +// facepalm() {} +// +// @deprecate('We stopped facepalming') +// facepalmHard() {} +// +// @deprecate('We stopped facepalming', { url: 'http://knowyourmeme.com/memes/facepalm' }) +// facepalmHarder() {} +//} +// +//let person2 = new Person2(); +// +//person2.facepalm(); +//// DEPRECATION Person#facepalm: This function will be removed in future versions. +// +//person2.facepalmHard(); +//// DEPRECATION Person#facepalmHard: We stopped facepalming +// +//person2.facepalmHarder(); +//// DEPRECATION Person#facepalmHarder: We stopped facepalming +//// +//// See http://knowyourmeme.com/memes/facepalm for more details. +//// +// +//// +//// @debounce +//// +// +//import { debounce } from 'core-decorators'; +// +//class Editor { +// +// content = ''; +// +// @debounce(500) +// updateContent(content: string) { +// this.content = content; +// } +//} +// +//// +//// @suppressWarnings +//// +// +//import { suppressWarnings } from 'core-decorators'; +// +//class Person3 { +// @deprecated +// facepalm() {} +// +// @suppressWarnings +// facepalmWithoutWarning() { +// this.facepalm(); +// } +//} +// +//let person3 = new Person3(); +// +//person3.facepalmWithoutWarning(); +//// no warning is logged +// +//// +//// @nonenumerable +//// +// +//import { nonenumerable } from 'core-decorators'; +// +//class Meal2 { +// entree = 'steak'; +// +// @nonenumerable +// cost: number = 4.44; +//} +// +//var dinner2 = new Meal2(); +//for (var key in dinner2) { +// key; +// // "entree" only, not "cost" +//} +// +//Object.keys(dinner2); +//// ["entree"] +// +//// +//// @nonconfigurable +//// +// +//import { nonconfigurable } from 'core-decorators'; +// +//class Meal3 { +// @nonconfigurable +// entree: string = 'steak'; +//} +// +//var dinner3 = new Meal3(); +// +//Object.defineProperty(dinner3, 'entree', { +// enumerable: false +//}); +//// Cannot redefine property: entree // -// @nonconfigurable // - -import { nonconfigurable } from 'core-decorators'; - -class Meal3 { - @nonconfigurable - entree: string = 'steak'; -} - -var dinner3 = new Meal3(); - -Object.defineProperty(dinner3, 'entree', { - enumerable: false -}); -// Cannot redefine property: entree - - From 4dcbaa948eb967877f210b49c5b6996465ab63e2 Mon Sep 17 00:00:00 2001 From: tkqubo Date: Tue, 15 Sep 2015 05:23:17 +0900 Subject: [PATCH 22/89] Add tscparams file and uncomment all the test codes --- core-decorators/core-decorators-tests.ts | 302 +++++++++--------- .../core-decorators-tests.ts.tscparams | 1 + 2 files changed, 152 insertions(+), 151 deletions(-) create mode 100644 core-decorators/core-decorators-tests.ts.tscparams diff --git a/core-decorators/core-decorators-tests.ts b/core-decorators/core-decorators-tests.ts index 7ec80d2f3c..e4a31432ba 100644 --- a/core-decorators/core-decorators-tests.ts +++ b/core-decorators/core-decorators-tests.ts @@ -1,169 +1,169 @@ -///// +/// + // -//// -//// @autobind -//// +// @autobind // -//import { autobind } from 'core-decorators'; + +import { autobind } from 'core-decorators'; + +class Person { + @autobind + getPerson() { + return this; + } +} + +let person = new Person(); +let getPerson = person.getPerson; + +getPerson() === person; + // -//class Person { -// @autobind -// getPerson() { -// return this; -// } -//} +// @readonly // -//let person = new Person(); -//let getPerson = person.getPerson; + +import { readonly } from 'core-decorators'; + +class Meal { + @readonly + entree: string = 'steak'; +} + +var dinner = new Meal(); +dinner.entree = 'salmon'; + // -//getPerson() === person; +// @override // -//// -//// @readonly -//// + +import { override } from 'core-decorators'; + +class Parent { + speak(first: string, second: string) {} +} + +class Child extends Parent { + @override + speak() {} + // SyntaxError: Child#speak() does not properly override Parent#speak(first, second) +} + +// or + +class Child2 extends Parent { + @override + speaks() {} + // SyntaxError: No descriptor matching Child#speaks() was found on the prototype chain. + // + // Did you mean "speak"? +} + // -//import { readonly } from 'core-decorators'; +// @deprecate (alias: @deprecated) // -//class Meal { -// @readonly -// entree: string = 'steak'; -//} + +import { deprecate, deprecated } from 'core-decorators'; + +class Person2 { + @deprecate + facepalm() {} + + @deprecate('We stopped facepalming') + facepalmHard() {} + + @deprecate('We stopped facepalming', { url: 'http://knowyourmeme.com/memes/facepalm' }) + facepalmHarder() {} +} + +let person2 = new Person2(); + +person2.facepalm(); +// DEPRECATION Person#facepalm: This function will be removed in future versions. + +person2.facepalmHard(); +// DEPRECATION Person#facepalmHard: We stopped facepalming + +person2.facepalmHarder(); +// DEPRECATION Person#facepalmHarder: We stopped facepalming // -//var dinner = new Meal(); -//dinner.entree = 'salmon'; +// See http://knowyourmeme.com/memes/facepalm for more details. // -//// -//// @override -//// + // -//import { override } from 'core-decorators'; +// @debounce // -//class Parent { -// speak(first: string, second: string) {} -//} + +import { debounce } from 'core-decorators'; + +class Editor { + + content = ''; + + @debounce(500) + updateContent(content: string) { + this.content = content; + } +} + // -//class Child extends Parent { -// @override -// speak() {} -// // SyntaxError: Child#speak() does not properly override Parent#speak(first, second) -//} +// @suppressWarnings // -//// or + +import { suppressWarnings } from 'core-decorators'; + +class Person3 { + @deprecated + facepalm() {} + + @suppressWarnings + facepalmWithoutWarning() { + this.facepalm(); + } +} + +let person3 = new Person3(); + +person3.facepalmWithoutWarning(); +// no warning is logged + // -//class Child2 extends Parent { -// @override -// speaks() {} -// // SyntaxError: No descriptor matching Child#speaks() was found on the prototype chain. -// // -// // Did you mean "speak"? -//} +// @nonenumerable // -//// -//// @deprecate (alias: @deprecated) -//// -// -//import { deprecate, deprecated } from 'core-decorators'; -// -//class Person2 { -// @deprecate -// facepalm() {} -// -// @deprecate('We stopped facepalming') -// facepalmHard() {} -// -// @deprecate('We stopped facepalming', { url: 'http://knowyourmeme.com/memes/facepalm' }) -// facepalmHarder() {} -//} -// -//let person2 = new Person2(); -// -//person2.facepalm(); -//// DEPRECATION Person#facepalm: This function will be removed in future versions. -// -//person2.facepalmHard(); -//// DEPRECATION Person#facepalmHard: We stopped facepalming -// -//person2.facepalmHarder(); -//// DEPRECATION Person#facepalmHarder: We stopped facepalming -//// -//// See http://knowyourmeme.com/memes/facepalm for more details. -//// -// -//// -//// @debounce -//// -// -//import { debounce } from 'core-decorators'; -// -//class Editor { -// -// content = ''; -// -// @debounce(500) -// updateContent(content: string) { -// this.content = content; -// } -//} -// -//// -//// @suppressWarnings -//// -// -//import { suppressWarnings } from 'core-decorators'; -// -//class Person3 { -// @deprecated -// facepalm() {} -// -// @suppressWarnings -// facepalmWithoutWarning() { -// this.facepalm(); -// } -//} -// -//let person3 = new Person3(); -// -//person3.facepalmWithoutWarning(); -//// no warning is logged -// -//// -//// @nonenumerable -//// -// -//import { nonenumerable } from 'core-decorators'; -// -//class Meal2 { -// entree = 'steak'; -// -// @nonenumerable -// cost: number = 4.44; -//} -// -//var dinner2 = new Meal2(); -//for (var key in dinner2) { -// key; -// // "entree" only, not "cost" -//} -// -//Object.keys(dinner2); -//// ["entree"] -// -//// -//// @nonconfigurable -//// -// -//import { nonconfigurable } from 'core-decorators'; -// -//class Meal3 { -// @nonconfigurable -// entree: string = 'steak'; -//} -// -//var dinner3 = new Meal3(); -// -//Object.defineProperty(dinner3, 'entree', { -// enumerable: false -//}); -//// Cannot redefine property: entree + +import { nonenumerable } from 'core-decorators'; + +class Meal2 { + entree = 'steak'; + + @nonenumerable + cost: number = 4.44; +} + +var dinner2 = new Meal2(); +for (var key in dinner2) { + key; + // "entree" only, not "cost" +} + +Object.keys(dinner2); +// ["entree"] + // +// @nonconfigurable // + +import { nonconfigurable } from 'core-decorators'; + +class Meal3 { + @nonconfigurable + entree: string = 'steak'; +} + +var dinner3 = new Meal3(); + +Object.defineProperty(dinner3, 'entree', { + enumerable: false +}); +// Cannot redefine property: entree + + diff --git a/core-decorators/core-decorators-tests.ts.tscparams b/core-decorators/core-decorators-tests.ts.tscparams new file mode 100644 index 0000000000..3f0863ac67 --- /dev/null +++ b/core-decorators/core-decorators-tests.ts.tscparams @@ -0,0 +1 @@ +--experimentalDecorators --noImplicitAny --target ES5 From 30220afd65d394da7664ce231147c136be348c06 Mon Sep 17 00:00:00 2001 From: fredericogalvao Date: Mon, 14 Sep 2015 17:39:43 -0300 Subject: [PATCH 23/89] Adding phonegap-plugin-push definitions. --- .../phonegap-plugin-push-tests.ts | 59 ++++++ .../phonegap-plugin-push.d.ts | 178 ++++++++++++++++++ 2 files changed, 237 insertions(+) create mode 100644 phonegap-plugin-push/phonegap-plugin-push-tests.ts create mode 100644 phonegap-plugin-push/phonegap-plugin-push.d.ts diff --git a/phonegap-plugin-push/phonegap-plugin-push-tests.ts b/phonegap-plugin-push/phonegap-plugin-push-tests.ts new file mode 100644 index 0000000000..916a6cf826 --- /dev/null +++ b/phonegap-plugin-push/phonegap-plugin-push-tests.ts @@ -0,0 +1,59 @@ +/// + +function test() { + var options:PhonegapPluginPush.InitOptions = { + android: { + senderID: '123456789', + icon: 'phonegap', + iconColor: 'blue', + sound: true, + vibrate: true, + clearNotifications: false + }, + ios: { + badge: true, + sound: true, + alert: true + }, + windows: {} + }; + var push:PhonegapPluginPush.PushNotification; + + /*from constructor*/ + push = new PushNotification(options); + + push.unregister(() => { + console.log('did unregister'); + }, () => { + console.log('did not unregister'); + }); + + /*from init*/ + push = PushNotification.init(options); + + push.on('registration', (data:PhonegapPluginPush.RegistrationEventResponse) => { + console.log(data.registrationId); + }); + + push.on('notification', (data:PhonegapPluginPush.NotificationEventResponse) => { + console.log(data.message); + console.log(data.title); + console.log(data.count); + console.log(data.sound); + console.log(data.image); + + /*the rest of the additional fields are not 'canon'*/ + console.log(data.additionalData); + console.log(data.additionalData.foreground); + }); + + push.on('error', (e:Error) => { + console.log(e.message); + }); + + push.setApplicationIconBadgeNumber(() => { + console.log('did setApplicationIconBadgeNumber'); + }, () => { + console.log('did not setApplicationIconBadgeNumber'); + }, 1); +} diff --git a/phonegap-plugin-push/phonegap-plugin-push.d.ts b/phonegap-plugin-push/phonegap-plugin-push.d.ts new file mode 100644 index 0000000000..e9168a6424 --- /dev/null +++ b/phonegap-plugin-push/phonegap-plugin-push.d.ts @@ -0,0 +1,178 @@ +// Type definitions for phonegap-plugin-push +// Project: https://github.com/phonegap/phonegap-plugin-push +// Definitions by: Frederico Galvão +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module PhonegapPluginPush { + type EventResponse = RegistrationEventResponse | NotificationEventResponse | Error + + interface PushNotification { + /** + * The event registration will be triggered on each successful registration with the 3rd party push service. + * @param event + * @param callback + */ + on(event:"registration", callback:(response:RegistrationEventResponse)=>any):void + /** + * The event notification will be triggered each time a push notification is received by a 3rd party push service on the device. + * @param event + * @param callback + */ + on(event:"notification", callback:(response:NotificationEventResponse)=>any):void + /** + * The event error will trigger when an internal error occurs and the cache is aborted. + * @param event + * @param callback + */ + on(event:"error", callback:(response:Error)=>any):void + /*Generic one, needed for the overloads*/ + /** + * + * @param event Name of the event to listen to. See below(above) for all the event names. + * @param callback is called when the event is triggered. + */ + on(event:string, callback:(response:EventResponse)=>any):void + + /** + * The unregister method is used when the application no longer wants to receive push notifications. + * @param successHandler + * @param errorHandler + */ + unregister(successHandler:()=>any, errorHandler?:()=>any):void + /*TODO according to js source code, "errorHandler" is optional, but is "count" also optional? I can't read objetive-C code (can anyone at all? I wonder...)*/ + /** + * Set the badge count visible when the app is not running + * + * The count is an integer indicating what number should show up in the badge. Passing 0 will clear the badge. Each notification event contains a data.count value which can be used to set the badge to correct number. + * @param successHandler + * @param errorHandler + * @param count + */ + setApplicationIconBadgeNumber(successHandler:()=>any, errorHandler:()=>any, count:number):void + } + + /** + * platform specific initialization options. + */ + interface InitOptions { + /** + * Android specific initialization options. + */ + android?: { + /** + * Maps to the project number in the Google Developer Console. + */ + senderID:string + /** + * The name of a drawable resource to use as the small-icon. + */ + icon?:string + /** + * Sets the background color of the small icon. + * Supported Formats - http://developer.android.com/reference/android/graphics/Color.html#parseColor(java.lang.String) + */ + iconColor?:string + /** + * If true it plays the sound specified in the push data or the default system sound. Default is true. + */ + sound?:boolean + /** + * If true the device vibrates on receipt of notification. Default is true. + */ + vibrate?:boolean + /** + * If true the app clears all pending notifications when it is closed. Default is true. + */ + clearNotifications?:boolean + } + + /** + * iOS specific initialization options. + */ + ios?: { + /** + * If true the device shows an alert on receipt of notification. Default is false. + */ + badge?: boolean + /** + * If true the device sets the badge number on receipt of notification. Default is false. + */ + sound?: boolean + /** + * If true the device plays a sound on receipt of notification. Default is false. + */ + alert?: boolean + } + + /** + * Windows specific initialization options. + */ + windows?: { + + } + } + + interface RegistrationEventResponse { + /** + * The registration ID provided by the 3rd party remote push service. + */ + registrationId:string + } + + interface NotificationEventResponse { + /** + * The text of the push message sent from the 3rd party service. + */ + message:string + /** + * The optional title of the push message sent from the 3rd party service. + */ + title?:string + /** + * The number of messages to be displayed in the badge iOS or message count in the notification shade in Android. + * For windows, it represents the value in the badge notification which could be a number or a status glyph. + */ + count:string + /** + * The name of the sound file to be played upon receipt of the notification. + */ + sound:string + /** + * The path of the image file to be displayed in the notification. + */ + image:string + /** + * An optional collection of data sent by the 3rd party push service that does not fit in the above properties. + */ + additionalData: NotificationEventAdditionalData + } + + interface NotificationEventAdditionalData { + /** + * TODO: document all possible properties (I only got the android ones) + * + * Loosened up with a dictionary notation, but all non-defined properties need to use (map['prop']) notation + * + * Ideally the developer would overload (merged declaration) this or create a new interface that would extend this one + * so that he could specify any custom code without having to use array notation (map['prop']) for all of them. + */ + [name: string]: any + /** + * Whether the notification was received while the app was in the foreground + */ + foreground?:boolean + collapse_key?:string + from?:string + notId?:string + } + + interface PushNotificationStatic { + init(options:InitOptions):PushNotification + new(options:InitOptions):PushNotification + } +} + +interface Window { + PushNotification:PhonegapPluginPush.PushNotificationStatic +} +declare var PushNotification:PhonegapPluginPush.PushNotificationStatic; From cfc40da29bebbe9adfc83c918dee9b4522ef3e16 Mon Sep 17 00:00:00 2001 From: tkqubo Date: Tue, 15 Sep 2015 05:41:40 +0900 Subject: [PATCH 24/89] Add react-props-decorators@0.1.0 --- .../react-props-decorators-tests.ts | 17 ++++++++++++++ .../react-props-decorators-tests.ts.tscparams | 1 + .../react-props-decorators.d.ts | 23 +++++++++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 react-props-decorators/react-props-decorators-tests.ts create mode 100644 react-props-decorators/react-props-decorators-tests.ts.tscparams create mode 100644 react-props-decorators/react-props-decorators.d.ts diff --git a/react-props-decorators/react-props-decorators-tests.ts b/react-props-decorators/react-props-decorators-tests.ts new file mode 100644 index 0000000000..6ba9b7cef3 --- /dev/null +++ b/react-props-decorators/react-props-decorators-tests.ts @@ -0,0 +1,17 @@ +/// +/// + +import React from 'react'; +import { propTypes, defaultProps } from 'react-props-decorators'; + +@propTypes({ + foo: React.PropTypes.string, + bar: React.PropTypes.number +}) +@defaultProps({ + foo: "defaultString", + bar: 100 +}) +class Baz extends React.Component { + /* ... */ +} diff --git a/react-props-decorators/react-props-decorators-tests.ts.tscparams b/react-props-decorators/react-props-decorators-tests.ts.tscparams new file mode 100644 index 0000000000..3f0863ac67 --- /dev/null +++ b/react-props-decorators/react-props-decorators-tests.ts.tscparams @@ -0,0 +1 @@ +--experimentalDecorators --noImplicitAny --target ES5 diff --git a/react-props-decorators/react-props-decorators.d.ts b/react-props-decorators/react-props-decorators.d.ts new file mode 100644 index 0000000000..98edc9884b --- /dev/null +++ b/react-props-decorators/react-props-decorators.d.ts @@ -0,0 +1,23 @@ +// Type definitions for react-props-decorators +// Project: https://github.com/popkirby/react-props-decorators +// Definitions by: Qubo +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module "react-props-decorators" { + import * as React from 'react'; + + export interface ClassDecorator { + (target:TFunction): TFunction|void; + } + + var propTypes: (map: React.ValidationMap) => ClassDecorator; + var defaultProps: (defaultProps: any) => ClassDecorator; + + export { + propTypes, + defaultProps + } +} + From 9718a35bba88f7b34627a9f41a1794c342f039cd Mon Sep 17 00:00:00 2001 From: tkqubo Date: Tue, 15 Sep 2015 05:48:18 +0900 Subject: [PATCH 25/89] Fix bug --- react-props-decorators/react-props-decorators-tests.ts | 4 ++-- react-props-decorators/react-props-decorators.d.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/react-props-decorators/react-props-decorators-tests.ts b/react-props-decorators/react-props-decorators-tests.ts index 6ba9b7cef3..33691834c3 100644 --- a/react-props-decorators/react-props-decorators-tests.ts +++ b/react-props-decorators/react-props-decorators-tests.ts @@ -1,7 +1,7 @@ /// /// -import React from 'react'; +import * as React from 'react'; import { propTypes, defaultProps } from 'react-props-decorators'; @propTypes({ @@ -12,6 +12,6 @@ import { propTypes, defaultProps } from 'react-props-decorators'; foo: "defaultString", bar: 100 }) -class Baz extends React.Component { +class Baz extends React.Component { /* ... */ } diff --git a/react-props-decorators/react-props-decorators.d.ts b/react-props-decorators/react-props-decorators.d.ts index 98edc9884b..9b62d84f9f 100644 --- a/react-props-decorators/react-props-decorators.d.ts +++ b/react-props-decorators/react-props-decorators.d.ts @@ -1,4 +1,4 @@ -// Type definitions for react-props-decorators +// Type definitions for react-props-decorators 0.1.0 // Project: https://github.com/popkirby/react-props-decorators // Definitions by: Qubo // Definitions: https://github.com/borisyankov/DefinitelyTyped From 1129c4a2c4fb0a5c4b359531bbd6d0ec24faf4fa Mon Sep 17 00:00:00 2001 From: mathieudugal Date: Mon, 14 Sep 2015 19:03:13 -0400 Subject: [PATCH 26/89] Add types descriptions for module ol.geom --- openlayers/openlayers.d.ts | 614 ++++++++++++++++++++++++++++++++++++- 1 file changed, 599 insertions(+), 15 deletions(-) diff --git a/openlayers/openlayers.d.ts b/openlayers/openlayers.d.ts index 5aba19b54c..89680ac91d 100644 --- a/openlayers/openlayers.d.ts +++ b/openlayers/openlayers.d.ts @@ -2733,12 +2733,41 @@ declare module ol { } module geom { - + // Type definitions interface GeometryLayout extends String { } interface GeometryType extends String { } + + /** + * Abstract base class; only used for creating subclasses; do not instantiate + * in apps, as cannot be rendered. + */ + class Circle extends ol.geom.SimpleGeometry { - class Circle { + /** + * Test if the geometry and the passed extent intersect. + * @param extent Extent + * @returns true if the geometry and the extent intersect. + */ + intersectsExtent(extent: ol.Extent): boolean; + + /** + * Transform each coordinate of the circle from one coordinate reference system + * to another. The geometry is modified in place. + * If you do not want the geometry modified in place, first clone() it and + * then use this function on the clone. + * + * Internally a circle is currently represented by two points: the center of + * the circle `[cx, cy]`, and the point to the right of the circle + * `[cx + r, cy]`. This `transform` function just transforms these two points. + * So the resulting geometry is also a circle, and that circle does not + * correspond to the shape that would be obtained by transforming every point + * of the original circle. + * @param source The current projection. Can be a string identifier or a {@link ol.proj.Projection} object. + * @param destination The desired projection. Can be a string identifier or a {@link ol.proj.Projection} object. + * @returns This geometry. Note that original geometry is modified in place. + */ + transform(source: ol.proj.ProjectionLike, destination: ol.proj.ProjectionLike): ol.geom.Circle; } /** @@ -2762,35 +2791,590 @@ declare module ol { getExtent(extent?: ol.Extent): ol.Extent; } - class GeometryCollection { + /** + * An array of ol.geom.Geometry objects. + */ + class GeometryCollection extends ol.geom.Geometry { + + /** + * constructor + * @param geometries Geometries. + */ + constructor(geometries?: Array); + + /** + * Apply a transform function to each coordinate of the geometry. The geometry is modified in place. + * If you do not want the geometry modified in place, first clone() it and then use this function on the clone. + * @param transformFn TransformFunction + */ + applyTransform(transformFn: ol.TransformFunction): void; + + /** + * Make a complete copy of the geometry. + * @returns Clone. + */ + clone(): ol.geom.GeometryCollection; + + /** + * Return the geometries that make up this geometry collection. + * @returns Geometries. + */ + getGeometries(): Array; + + /** + * Get the type of this geometry. + * @returns Geometry type + */ + getType(): ol.geom.GeometryType; + + /** + * Test if the geometry and the passed extent intersect. + * @param extent Extent + * @returns true if the geometry and the extent intersect. + */ + intersectsExtent(extent: ol.Extent): boolean; + + /** + * Set the geometries that make up this geometry collection. + * @param geometries Geometries. + */ + setGeometries(geometries: Array): void; + } - class LinearRing { + /** + * Linear ring geometry. Only used as part of polygon; cannot be rendered + * on its own. + */ + class LinearRing extends SimpleGeometry { + + /** + * constructor + * @param coordinates Coordinates. + * @param layout Layout. + */ + constructor(coordinates: Array, layout?: ol.geom.GeometryLayout); + + /** + * Make a complete copy of the geometry. + * @returns Clone. + */ + clone(): ol.geom.LinearRing; + + /** + * Return the area of the linear ring on projected plane. + * @returns Area (on projected plane). + */ + getArea(): number; + + /** + * Return the coordinates of the linear ring. + * @returns Coordinates. + */ + getCoordinates(): Array; + + /** + * Get the type of this geometry. + * @returns Geometry type + */ + getType(): ol.geom.GeometryType; + + /** + * @Set the coordinates of the linear ring + * @param coordinates Coordinates. + * @param layout Layout. + */ + setCoordinates(coordinates: Array, layout?: any): void; + } - class LineString { - new(): LineString; + /** + * Linestring geometry. + */ + class LineString extends ol.geom.SimpleGeometry { + + /** + * constructor + * @param coordinates Coordinates. + * @param layout Layout. + */ + constructor(coordinates: Array, layout?: ol.geom.GeometryLayout); + + /** + * Append the passed coordinate to the coordinates of the linestring. + * @param coordinate Coordinate. + */ + appendCoordinate(coordinate: ol.Coordinate): void; + + /** + * Make a complete copy of the geometry. + * @returns Clone. + */ + clone(): ol.geom.LineString; + + /** + * Returns the coordinate at `m` using linear interpolation, or `null` if no + * such coordinate exists. + * + * `extrapolate` controls extrapolation beyond the range of Ms in the + * MultiLineString. If `extrapolate` is `true` then Ms less than the first + * M will return the first coordinate and Ms greater than the last M will + * return the last coordinate. + * + * @param m M. + * @param extrapolate Extrapolate. Default is `false`. + * @returns Coordinate. + */ + getCoordinateAtM(m: number, extrapolate?: boolean): ol.Coordinate; + + /** + * Return the coordinates of the linestring. + * @returns Coordinates. + */ + getCoordinates(): Array; + + /** + * Return the length of the linestring on projected plane. + * @returns Length (on projected plane). + */ + getLength(): number; + + /** + * Get the type of this geometry. + * @returns Geometry type + */ + getType(): ol.geom.GeometryType; + + /** + * Test if the geometry and the passed extent intersect. + * @param extent Extent + * @returns true if the geometry and the extent intersect. + */ + intersectsExtent(extent: ol.Extent): boolean; + + /** + * Set the coordinates of the linestring. + * @param coordinates Coordinates. + * @param layout Layout. + */ + setCoordinates(coordinates: Array, layout?: ol.geom.GeometryLayout) : void; } - class MultiLineString { + /** + * Multi-linestring geometry. + */ + class MultiLineString extends ol.geom.SimpleGeometry { + + /** + * constructor + * @param coordinates Coordinates. + * @param layout Layout. + */ + constructor(coordinates: Array>, layout?: ol.geom.GeometryLayout); + + /** + * Append the passed linestring to the multilinestring. + * @param lineString LineString. + */ + appendLineString(lineString: ol.geom.LineString): void; + + /** + * Make a complete copy of the geometry. + * @returns Clone. + */ + clone(): ol.geom.MultiLineString; + + /** + * Returns the coordinate at `m` using linear interpolation, or `null` if no + * such coordinate exists. + * + * `extrapolate` controls extrapolation beyond the range of Ms in the + * MultiLineString. If `extrapolate` is `true` then Ms less than the first + * M will return the first coordinate and Ms greater than the last M will + * return the last coordinate. + * + * `interpolate` controls interpolation between consecutive LineStrings + * within the MultiLineString. If `interpolate` is `true` the coordinates + * will be linearly interpolated between the last coordinate of one LineString + * and the first coordinate of the next LineString. If `interpolate` is + * `false` then the function will return `null` for Ms falling between + * LineStrings. + * + * @param m M. + * @param extrapolate Extrapolate. Default is `false`. + * @param interpolate Interpolate. Default is `false`. + * @returns Coordinate. + */ + getCoordinateAtM(m: number, extrapolate?: boolean, interpolate?: boolean): ol.Coordinate; + + /** + * Return the coordinates of the multilinestring. + * @returns Coordinates. + */ + getCoordinates(): Array>; + + /** + * Return the linestring at the specified index. + * @param index Index. + * @returns LineString. + */ + getLineString(index: number): ol.geom.LineString; + + /** + * Return the linestrings of this multilinestring. + * @returns LineStrings. + */ + getLineStrings(): Array; + + /** + * Get the type of this geometry. + * @returns Geometry type + */ + getType(): ol.geom.GeometryType; + + /** + * Test if the geometry and the passed extent intersect. + * @param extent Extent + * @returns true if the geometry and the extent intersect. + */ + intersectsExtent(extent: ol.Extent): boolean; + + /** + * Set the coordinates of the multilinestring. + * @param coordinates Coordinates. + * @param layout Layout. + */ + setCoordinates(coordinates: Array>, layout?: ol.geom.GeometryLayout): void; } - class MultiPoint { + /** + * Multi-point geometry. + */ + class MultiPoint extends ol.geom.SimpleGeometry { + + /** + * constructor + * @param coordinates Coordinates. + * @param layout Layout. + */ + constructor(coordinates: Array, layout?: ol.geom.GeometryLayout); + + /** + * Append the passed point to this multipoint. + * @param {ol.geom.Point} point Point. + */ + appendPoint(point: ol.geom.Point): void; + + /** + * Make a complete copy of the geometry. + * @returns Clone. + */ + clone(): ol.geom.MultiPoint; + + /** + * Return the coordinates of the multipoint. + * @returns Coordinates. + */ + getCoordinates(): Array; + + /** + * Return the point at the specified index. + * @param index Index. + * @returns Point. + */ + getPoint(index: number): ol.geom.Point; + + /** + * Return the points of this multipoint. + * @returns Points. + */ + getPoints(): Array; + + /** + * Get the type of this geometry. + * @returns Geometry type + */ + getType(): ol.geom.GeometryType; + + /** + * Test if the geometry and the passed extent intersect. + * @param extent Extent + * @returns true if the geometry and the extent intersect. + */ + intersectsExtent(extent: ol.Extent): boolean; + + /** + * Set the coordinates of the multipoint. + * @param coordinates Coordinates. + * @param layout Layout. + */ + setCoordinates(coordinates: Array, layout?: ol.geom.GeometryLayout): void; } + + /** + * Multi-polygon geometry. + */ + class MultiPolygon extends ol.geom.SimpleGeometry { + + /** + * constructor + * @param coordinates Coordinates. + * @param layout Layout. + */ + constructor(coordinates: Array>>, layout?: ol.geom.GeometryLayout); + + /** + * Append the passed polygon to this multipolygon. + * @param polygon Polygon. + */ + appendPolygon(polygon: ol.geom.Polygon): void; + + /** + * Make a complete copy of the geometry. + * @returns Clone. + */ + clone(): ol.geom.MultiPolygon; + + /** + * Return the area of the multipolygon on projected plane. + * @returns Area (on projected plane). + */ + getArea(): number; + + /** + * Get the coordinate array for this geometry. This array has the structure + * of a GeoJSON coordinate array for multi-polygons. + * + * @param right Orient coordinates according to the right-hand + * rule (counter-clockwise for exterior and clockwise for interior rings). + * If `false`, coordinates will be oriented according to the left-hand rule + * (clockwise for exterior and counter-clockwise for interior rings). + * By default, coordinate orientation will depend on how the geometry was + * constructed. + * @returns Coordinates. + */ + getCoordinates(right?: boolean): Array>>; + + /** + * Return the interior points as {@link ol.geom.MultiPoint multipoint}. + * @returns Interior points. + */ + getInteriorPoints(): ol.geom.MultiPoint; + + /** + * Return the polygon at the specified index. + * @param index Index. + * @returns Polygon. + */ + getPolygon(index: number): ol.geom.Polygon; + + /** + * Return the polygons of this multipolygon. + * @returns Polygons. + */ + getPolygons(): Array; + + /** + * Get the type of this geometry. + * @returns Geometry type + */ + getType(): ol.geom.GeometryType; + + /** + * Test if the geometry and the passed extent intersect. + * @param extent Extent + * @returns true if the geometry and the extent intersect. + */ + intersectsExtent(extent: ol.Extent): boolean; - class MultiPolygon { + /** + * Set the coordinates of the multipolygon. + * @param coordinates Coordinates. + * @param layout Layout. + */ + setCoordinates(coordinates: Array>>, layout?: ol.geom.GeometryLayout): void; } + /** + * Point geometry. + */ class Point extends SimpleGeometry { - constructor(coordinates: ol.Coordinate, layout?: geom.GeometryLayout); - getCoordinates(): ol.Coordinate; - setCoordinates(coordinates: ol.Coordinate, opt?: geom.GeometryLayout): void; + + /** + * constructor + * @param coordinates Coordinates. + * @param layout Layout. + */ + constructor(coordinates: ol.Coordinate, layout?: ol.geom.GeometryLayout); + + /** + * Make a complete copy of the geometry. + * @returns Clone. + */ + clone(): ol.geom.Point; + + /** + * Return the coordinate of the point. + * @returns Coordinates. + */ + getCoordinates(): ol.Coordinate; + + /** + * Get the type of this geometry. + * @returns Geometry type + */ + getType(): ol.geom.GeometryType; + + /** + * Test if the geometry and the passed extent intersect. + * @param extent Extent + * @returns true if the geometry and the extent intersect. + */ + intersectsExtent(extent: ol.Extent): boolean; + + /** + * Set the coordinate of the point. + * @param coordinates Coordinates. + * @param layout Layout. + */ + setCoordinates(coordinates: ol.Coordinate, layout?: ol.geom.GeometryLayout): void; } - class Polygon { - } + /** + * Polygon geometry. + */ + class Polygon extends SimpleGeometry { - class SimpleGeometry extends Geometry { + /** + * constructor + * @param coordinates Coordinates. + * @param layout Layout. + */ + constructor(coordinates: Array>, layout?: ol.geom.GeometryLayout); + + /** + * Create an approximation of a circle on the surface of a sphere. + * @param sphere The sphere. + * @param center Center (`[lon, lat]` in degrees). + * @param radius The great-circle distance from the center to the polygon vertices. + * @param n Optional number of vertices for the resulting polygon. Default is `32`. + * @returns The "circular" polygon. + */ + static circular(sphere: ol.Sphere, center: ol.Coordinate, radius: number, n?: number): ol.geom.Polygon; + + /** + * Append the passed linear ring to this polygon. + * @param linearRing Linear ring. + */ + appendLinearRing(linearRing: ol.geom.LinearRing): void; + + /** + * Make a complete copy of the geometry. + * @returns Clone. + */ + clone(): ol.geom.Polygon; + + /** + * Return the area of the polygon on projected plane. + * @returns Area (on projected plane). + */ + getArea(): number; + + /** + * Get the coordinate array for this geometry. This array has the structure + * of a GeoJSON coordinate array for polygons. + * + * @param right Orient coordinates according to the right-hand + * rule (counter-clockwise for exterior and clockwise for interior rings). + * If `false`, coordinates will be oriented according to the left-hand rule + * (clockwise for exterior and counter-clockwise for interior rings). + * By default, coordinate orientation will depend on how the geometry was + * constructed. + * @returns Coordinates. + */ + getCoordinates(right?: boolean): Array>; + + /** + * Return an interior point of the polygon. + * @returns Interior point. + */ + getInteriorPoint(): ol.geom.Point; + + /** + * Return the Nth linear ring of the polygon geometry. Return `null` if the + * given index is out of range. + * The exterior linear ring is available at index `0` and the interior rings + * at index `1` and beyond. + * + * @param index Index. + * @returns Linear ring. + */ + getLinearRing(index: number): ol.geom.LinearRing; + + /** + * Return the linear rings of the polygon. + * @returns Linear rings. + */ + getLinearRings(): Array; + + /** + * Get the type of this geometry. + * @returns Geometry type + */ + getType(): ol.geom.GeometryType; + + /** + * Test if the geometry and the passed extent intersect. + * @param extent Extent + * @returns true if the geometry and the extent intersect. + */ + intersectsExtent(extent: ol.Extent): boolean; + + /** + * Set the coordinates of the polygon. + * @param coordinates Coordinates. + * @param layout Layout. + */ + setCoordinates(coordinates: Array>, layout?: ol.geom.GeometryLayout): void; + } + /** + * Abstract base class; only used for creating subclasses; do not instantiate + * in apps, as cannot be rendered. + */ + class SimpleGeometry extends ol.geom.Geometry { + + /** + * Apply a transform function to each coordinate of the geometry. The geometry is modified in place. + * If you do not want the geometry modified in place, first clone() it and then use this function on the clone. + * @param transformFn TransformFunction + */ + applyTransform(transformFn: ol.TransformFunction): void; + + /** + * Return the first coordinate of the geometry. + * @returns First coordinate. + */ + getFirstCoordinate(): ol.Coordinate; + + /** + * Return the last coordinate of the geometry. + * @returns Last point. + */ + getLastCoordinate(): ol.Coordinate; + + /** + * Return the {@link ol.geom.GeometryLayout layout} of the geometry. + * @returns Layout. + */ + getLayout(): ol.geom.GeometryLayout; + + /** + * Translate the geometry. This modifies the geometry coordinates in place. + * If instead you want a new geometry, first clone() this geometry. + * @param deltaX Delta X + * @param deltaY Delta Y + */ + translate(deltaX: number, deltaY: number): void; } } From 19a92cecc19b749d4a5c75cc7680556ee81b955b Mon Sep 17 00:00:00 2001 From: Alexander Rusakov Date: Tue, 15 Sep 2015 11:44:49 +0300 Subject: [PATCH 27/89] predicate returns boolean --- redux-logger/redux-logger.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/redux-logger/redux-logger.d.ts b/redux-logger/redux-logger.d.ts index 28b53f3a1c..6bc7775f97 100644 --- a/redux-logger/redux-logger.d.ts +++ b/redux-logger/redux-logger.d.ts @@ -13,7 +13,7 @@ declare module 'redux-logger' { logger?: any; timestamp?: boolean; transformer?: (state:any)=>any; - predicate?: (getState:Function, action:any)=>any; + predicate?: (getState:Function, action:any)=>boolean; } export default function createLogger(options?:ReduxLoggerOptions):Redux.Middleware; From e24b3227132ba441741d16a9c03b2efab78704e4 Mon Sep 17 00:00:00 2001 From: "Pascal Senn (GIAPSE)" Date: Tue, 15 Sep 2015 14:57:21 +0200 Subject: [PATCH 28/89] Added Gridstack definition file and test --- gridstack/gridstack-tests.ts | 16 +++ gridstack/gridstack.d.ts | 241 +++++++++++++++++++++++++++++++++++ 2 files changed, 257 insertions(+) create mode 100644 gridstack/gridstack-tests.ts create mode 100644 gridstack/gridstack.d.ts diff --git a/gridstack/gridstack-tests.ts b/gridstack/gridstack-tests.ts new file mode 100644 index 0000000000..473d3306e7 --- /dev/null +++ b/gridstack/gridstack-tests.ts @@ -0,0 +1,16 @@ +// Type definitions for Gridstack +// Project: http://troolee.github.io/gridstack.js/ +// Definitions by: Pascal Senn +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +var options = { + float: true; +}; +var gridstack:GridStack = $(document).gridstack(options); + +gridstack.add_widget("test", 1, 2, 3, 4, true); +gridstack.batch_update(); +gridstack.cell_height();; +gridstack.cell_height(2); +gridstack.cell_width(); +gridstack.get_cell_from_pixel({ left:20, top: 20 }); diff --git a/gridstack/gridstack.d.ts b/gridstack/gridstack.d.ts new file mode 100644 index 0000000000..58ee79fbd8 --- /dev/null +++ b/gridstack/gridstack.d.ts @@ -0,0 +1,241 @@ +// Type definitions for Gridstack +// Project: http://troolee.github.io/gridstack.js/ +// Definitions by: Pascal Senn +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +interface JQuery { + gridstack (options: IGridstackOptions):GridStack +} + +interface GridStack { + /** + * Creates new widget and returns it. + * + * Widget will be always placed even if result height is more than actual grid height. You need to use will_it_fit method before calling add_widget for additional check. + * + * @param {string} el widget to add + * @param {number} x widget position x + * @param {number} y widget position y + * @param {number} width widget dimension width + * @param {number} height widget dimension height + * @param {boolean} auto_position if true then x, y parameters will be ignored and widget will be places on the first available position + */ + add_widget(el: string, x: number, y: number, width: number, height: number, auto_position: boolean): JQuery + /** + * Initailizes batch updates. You will see no changes until commit method is called. + */ + batch_update() + /** + * Gets current cell height. + */ + cell_height():number + /** + * Update current cell height. This method rebuilds an internal CSS stylesheet. Note: You can expect performance issues if call this method too often. + * @param {number} val the cell height + */ + cell_height(val:number) + /** + * Gets current cell width. + */ + cell_width():number + /** + * Finishes batch updates. Updates DOM nodes. You must call it after batch_update. + */ + commit() + /** + * Destroys a grid instance. + */ + destroy() + /* + * Disables widgets moving/resizing. + */ + disable() + /* + * Enables widgets moving/resizing. + */ + enable() + /* + * Get the position of the cell under a pixel on screen. + * @param {MousePosition} position the position of the pixel to resolve in absolute coordinates, as an object with top and leftproperties + */ + get_cell_from_pixel(position: MousePosition): CellPosition, + /* + * Checks if specified area is empty. + * @param {number} x the position x. + * @param {number} y the position y. + * @param {number} width the width of to check + * @param {number} height the height of to check + */ + is_area_empty(x: number, y: number, width: number, height: number) + /* + * Locks/unlocks widget. + * @param {HTMLElement} el widget to modify. + * @param {boolean} val if true widget will be locked. + */ + locked(el: HTMLElement, val: boolean) + /* + * Set the minWidth for a widget. + * @param {HTMLElement} el widget to modify. + * @param {number} val A numeric value of the number of columns + */ + min_width(el: HTMLElement, val: number) + /* + * Set the minHeight for a widget. + * @param {HTMLElement} el widget to modify. + * @param {number} val A numeric value of the number of rows + */ + min_height(el: HTMLElement, val: number) + /* + * Enables/Disables moving. + * @param {HTMLElement} el widget to modify. + * @param {number} val if true widget will be draggable. + */ + movable(el: HTMLElement, val: boolean) + /** + * Changes widget position + * @param {HTMLElement} el widget to modify + * @param {number} x new position x. If value is null or undefined it will be ignored. + * @param {number} y new position y. If value is null or undefined it will be ignored. + * + */ + move(el: HTMLElement, x: number, y: number) + /** + * Removes widget from the grid. + * @param {HTMLElement} el widget to modify + * @param {boolean} detach_node if false DOM node won't be removed from the tree (Optional. Default true). + */ + remove_widget(el: HTMLElement, detach_node?:boolean) + /** + * Removes all widgets from the grid. + */ + remove_all() + /** + * Changes widget size + * @param {HTMLElement} el widget to modify + * @param {number} width new dimensions width. If value is null or undefined it will be ignored. + * @param {number} height new dimensions height. If value is null or undefined it will be ignored. + */ + resize(el: HTMLElement, width: number, height: number) + /** + * Enables/Disables resizing. + * @param {HTMLElement} el widget to modify + * @param {boolean} val if true widget will be resizable. + */ + resizable(el: HTMLElement, val:boolean) + /** + * Toggle the grid static state. Also toggle the grid-stack-static class. + * @param {boolean} static_value if true the grid become static. + */ + set_static(static_value:boolean) + /** + * Updates widget position/size. + * @param {HTMLElement} el widget to modify + * @param {number} x new position x. If value is null or undefined it will be ignored. + * @param {number} y new position y. If value is null or undefined it will be ignored. + * @param {number} width new dimensions width. If value is null or undefined it will be ignored. + * @param {number} height new dimensions height. If value is null or undefined it will be ignored. + */ + update(el: HTMLElement, x: number, y: number, width: number, height: number) + /** + * Returns true if the height of the grid will be less the vertical constraint. Always returns true if grid doesn't have height constraint. + * @param {number} x new position x. If value is null or undefined it will be ignored. + * @param {number} y new position y. If value is null or undefined it will be ignored. + * @param {number} width new dimensions width. If value is null or undefined it will be ignored. + * @param {number} height new dimensions height. If value is null or undefined it will be ignored. + * @param {boolean} auto_position if true then x, y parameters will be ignored and widget will be places on the first available position + */ + will_it_fit(x: number, y: number, width: number, height: number, auto_position:boolean):boolean + + +} +/** +* Defines the coordiantes of a object +*/ +interface MousePosition { + top: number, + left:number, +} +/** +* Defines the position of a cell inside the grid +*/ +interface CellPosition { + x: number, + y:number +} +declare module GridStackUI { + interface Utils { + /** + * Sorts array of nodes + *@param nodes array to sort + *@param dir 1 for asc, -1 for desc (optional) + *@param width width of the grid. If undefined the width will be calculated automatically (optional). + **/ + sort(nodes:HTMLElement[], dir:number, width:number) + } +} +/** +* Gridstack Options +* Defines the options for a Gridstack +*/ +interface IGridstackOptions { + /** + * if true the resizing handles are shown even if the user is not hovering over the widget (default: false) + */ + always_show_resize_handle: boolean; + /** + * turns animation on (default: true) + */ + animate: boolean; + /** + * if false gridstack will not initialize existing items (default: true) + */ + auto: boolean; + /** + * one cell height (default: 60) + */ + cell_height: number; + /** + * allows to override jQuery UI draggable options. (default: { handle: '.grid-stack-item-content', scroll: true, appendTo: 'body' }) + */ + draggable: {}; + /** + * draggable handle selector (default: '.grid-stack-item-content') + */ + handle: string; + /** + * maximum rows amount.Default is 0 which means no maximum rows + */ + height: number; + /** + * enable floating widgets (default: false) See example + */ + float: boolean; + /** + * widget class (default: 'grid-stack-item') + */ + item_class: string; + /** + * minimal width.If window width is less, grid will be shown in one - column mode (default: 768) + */ + min_width: number; + /** + * class for placeholder (default: 'grid-stack-placeholder') + */ + placeholder_class: string; + /** + * allows to override jQuery UI resizable options. (default: { autoHide: true, handles: 'se' }) + */ + resizable: {}; + /** + * makes grid static (default false).If true widgets are not movable/ resizable.You don't even need jQueryUI draggable/resizable. A CSS class grid-stack-static is also added to the container. + */ + static_grid: boolean; + /** + * vertical gap size (default: 20) + */ + vertical_margin: number; + /** + * amount of columns (default: 12) + */ + width: number; +} From bfdee37043dd6c1a755acab4f347cf95a255cf25 Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Tue, 15 Sep 2015 01:36:11 +0500 Subject: [PATCH 29/89] lodash: changed _.initial() method --- lodash/lodash-tests.ts | 17 +++++--- lodash/lodash.d.ts | 98 +++++++----------------------------------- 2 files changed, 26 insertions(+), 89 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 5b9add244c..22ccc3e99c 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -282,13 +282,16 @@ result = _.indexOf([1, 2, 3, 1, 2, 3], 2); result = _.indexOf([1, 2, 3, 1, 2, 3], 2, 3); result = _.indexOf([1, 1, 2, 2, 3, 3], 2, true); -result = _.initial([1, 2, 3]); -result = _.initial([1, 2, 3], 2); -result = _.initial([1, 2, 3], function (num) { - return num > 1; -}); -result = _.initial(foodsOrganic, 'organic'); -result = _.initial(foodsType, { 'type': 'vegetable' }); +//_.initial +{ + let testInitalArray: TResult[]; + let testInitalList: _.List; + let result: TResult[]; + result = _.initial(testInitalArray); + result = _.initial(testInitalList); + result = _(testInitalArray).initial().value(); + result = _(testInitalList).initial().value(); +} result = _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]); diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index b6c95710bd..4e0880850a 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -937,92 +937,26 @@ declare module _ { //_.initial interface LoDashStatic { /** - * Gets all but the last element or last n elements of an array. If a callback is provided - * elements at the end of the array are excluded from the result as long as the callback - * returns truey. The callback is bound to thisArg and invoked with three arguments; - * (value, index, array). - * - * 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 array The array to query. - * @param n Leaves this many elements behind, optional. - * @return Returns everything but the last `n` elements of `array`. - **/ - initial( - array: Array): T[]; + * Gets all but the last element of array. + * + * @param array The array to query. + * @return Returns the slice of array. + */ + initial(array: T[]|List): T[]; + } + interface LoDashArrayWrapper { /** - * @see _.initial - **/ - initial( - array: List): T[]; + * @see _.initial + */ + initial(): LoDashArrayWrapper; + } + interface LoDashObjectWrapper { /** - * @see _.initial - * @param n The number of elements to exclude. - **/ - initial( - array: Array, - n: number): T[]; - - /** - * @see _.initial - * @param n The number of elements to exclude. - **/ - initial( - array: List, - n: number): T[]; - - /** - * @see _.initial - * @param callback The function called per element - **/ - initial( - array: Array, - callback: ListIterator): T[]; - - /** - * @see _.initial - * @param callback The function called per element - **/ - initial( - array: List, - callback: ListIterator): T[]; - - /** - * @see _.initial - * @param pluckValue _.pluck style callback - **/ - initial( - array: Array, - pluckValue: string): T[]; - - /** - * @see _.initial - * @param pluckValue _.pluck style callback - **/ - initial( - array: List, - pluckValue: string): T[]; - - /** - * @see _.initial - * @param whereValue _.where style callback - **/ - initial( - array: Array, - whereValue: W): T[]; - - /** - * @see _.initial - * @param whereValue _.where style callback - **/ - initial( - array: List, - whereValue: W): T[]; + * @see _.initial + */ + initial(): LoDashArrayWrapper; } //_.intersection From f6bf1593866905d9503ebe8a12bb7a3b18eaee53 Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Mon, 14 Sep 2015 23:04:49 +0500 Subject: [PATCH 30/89] lodash: changed _.drop() method --- lodash/lodash-tests.ts | 21 +++++++--- lodash/lodash.d.ts | 94 ++++++++++++------------------------------ 2 files changed, 41 insertions(+), 74 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 5b9add244c..54b6586c2a 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -175,18 +175,27 @@ result = <_.LoDashArrayWrapper>_([0, 1, false, 2, '', 3]).compact(); result = _.difference([1, 2, 3, 4, 5], [5, 2, 10]); result = <_.LoDashArrayWrapper>_([1, 2, 3, 4, 5]).difference([5, 2, 10]); +// _.drop +{ + let testDropArray: TResult[]; + let testDropList: _.List; + let result: TResult[]; + result = _.drop(testDropArray); + result = _.drop(testDropArray, 42); + result = _.drop(testDropList); + result = _.drop(testDropList, 42); + result = _(testDropArray).drop().value(); + result = _(testDropArray).drop(42).value(); + result = _(testDropList).drop().value(); + result = _(testDropList).drop(42).value(); +} + result = _.rest([1, 2, 3]); result = _.rest([1, 2, 3], 2); result = _.rest([1, 2, 3], (num) => num < 3) result = _.rest(foodsOrganic, 'test'); result = _.rest(foodsType, { 'type': 'value' }); -result = _.drop([1, 2, 3]); -result = _.drop([1, 2, 3], 2); -result = _.drop([1, 2, 3], (num) => num < 3) -result = _.drop(foodsOrganic, 'test'); -result = _.drop(foodsType, { 'type': 'value' }); - result = _.tail([1, 2, 3]) result = _.tail([1, 2, 3], 2) result = _.tail([1, 2, 3], (num) => num < 3) diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index b6c95710bd..39263df8b5 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -397,6 +397,32 @@ declare module _ { ...others: List[]): LoDashArrayWrapper; } + //_.drop + interface LoDashStatic { + /** + * Creates a slice of array with n elements dropped from the beginning. + * + * @param array The array to query. + * @param n The number of elements to drop. + * @return Returns the slice of array. + */ + drop(array: T[]|List, n?: number): T[]; + } + + interface LoDashArrayWrapper { + /** + * @see _.drop + */ + drop(n?: number): LoDashArrayWrapper; + } + + interface LoDashObjectWrapper { + /** + * @see _.drop + */ + drop(n?: number): LoDashArrayWrapper; + } + //_.findIndex interface LoDashStatic { /** @@ -1280,74 +1306,6 @@ declare module _ { array: List, whereValue: W): T[]; - /** - * @see _.rest - **/ - drop(array: Array): T[]; - - /** - * @see _.rest - **/ - drop(array: List): T[]; - - /** - * @see _.rest - **/ - drop( - array: Array, - callback: ListIterator, - thisArg?: any): T[]; - - /** - * @see _.rest - **/ - drop( - array: List, - callback: ListIterator, - thisArg?: any): T[]; - - /** - * @see _.rest - **/ - drop( - array: Array, - n: number): T[]; - - /** - * @see _.rest - **/ - drop( - array: List, - n: number): T[]; - - /** - * @see _.rest - **/ - drop( - array: Array, - pluckValue: string): T[]; - - /** - * @see _.rest - **/ - drop( - array: List, - pluckValue: string): T[]; - - /** - * @see _.rest - **/ - drop( - array: Array, - whereValue: W): T[]; - - /** - * @see _.rest - **/ - drop( - array: List, - whereValue: W): T[]; - /** * @see _.rest **/ From 2f9096fa7309f985fee2f1b2faf278281a05281c Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Tue, 15 Sep 2015 02:33:09 +0500 Subject: [PATCH 31/89] lodash: changed _.intersection() method --- lodash/lodash-tests.ts | 13 ++++++++++++- lodash/lodash.d.ts | 28 +++++++++++++++++++--------- 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 5b9add244c..049e7c4f16 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -290,7 +290,18 @@ result = _.initial([1, 2, 3], function (num) { result = _.initial(foodsOrganic, 'organic'); result = _.initial(foodsType, { 'type': 'vegetable' }); -result = _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]); +// _.intersection +{ + let testIntersectionArray: TResult[]; + let testIntersectionList: _.List; + let result: TResult[]; + result = _.intersection(testIntersectionArray, testIntersectionList); + result = _.intersection(testIntersectionList, testIntersectionArray, testIntersectionList); + result = _(testIntersectionArray).intersection(testIntersectionArray).value(); + result = _(testIntersectionArray).intersection(testIntersectionList, testIntersectionArray).value(); + result = _(testIntersectionList).intersection(testIntersectionArray).value(); + result = _(testIntersectionList).intersection(testIntersectionList, testIntersectionArray).value(); +} result = _.last([1, 2, 3]); result = _([1, 2, 3]).last(); diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index b6c95710bd..bb8c325ec1 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -1028,17 +1028,27 @@ declare module _ { //_.intersection interface LoDashStatic { /** - * Creates an array of unique values present in all provided arrays using strict - * equality for comparisons, i.e. ===. - * @param arrays The arrays to inspect. - * @return Returns an array of composite values. - **/ - intersection(...arrays: Array[]): T[]; + * Creates an array of unique values that are included in all of the provided arrays using SameValueZero for + * equality comparisons. + * + * @param arrays The arrays to inspect. + * @return Returns the new array of shared values. + */ + intersection(...arrays: (T[]|List)[]): T[]; + } + interface LoDashArrayWrapper { /** - * @see _.intersection - **/ - intersection(...arrays: List[]): T[]; + * @see _.intersection + */ + intersection(...arrays: (TResult[]|List)[]): LoDashArrayWrapper; + } + + interface LoDashObjectWrapper { + /** + * @see _.intersection + */ + intersection(...arrays: (TResult[]|List)[]): LoDashArrayWrapper; } //_.last From dacf9af77663385080fee3811ddb60917e06ca5b Mon Sep 17 00:00:00 2001 From: mathieudugal Date: Tue, 15 Sep 2015 17:14:45 -0400 Subject: [PATCH 32/89] Test the ol.geom module Tests related to the typing definitions of the ol.geom module --- openlayers/openlayers-tests.ts | 174 ++++++++++++++++++++++++++++++++- 1 file changed, 173 insertions(+), 1 deletion(-) diff --git a/openlayers/openlayers-tests.ts b/openlayers/openlayers-tests.ts index 0092737467..1e59ebb445 100644 --- a/openlayers/openlayers-tests.ts +++ b/openlayers/openlayers-tests.ts @@ -16,8 +16,11 @@ var featureLoader: ol.FeatureLoader; var easingFunction: (t: number) => number; // Type variables for OpenLayers +var circle: ol.geom.Circle; var color: ol.Color; var coordinate: ol.Coordinate; +var coordinatesArray: Array; +var coordinatesArrayDim2: Array>; var extent: ol.Extent; var boundingCoordinates: Array; var size: ol.Size; @@ -27,14 +30,28 @@ var feature: ol.Feature; var featureArray: Array; var graticule: ol.Graticule var geometry: ol.geom.Geometry; +var geometriesArray: Array; var feature: ol.Feature; var featureArray: Array; var featureFormat: ol.format.Feature; var geometry: ol.geom.Geometry; +var geometryCollection: ol.geom.GeometryCollection; +var geometryLayout: ol.geom.GeometryLayout; +var geometryType: ol.geom.GeometryType; +var linearRing: ol.geom.LinearRing; +var lineString: ol.geom.LineString; var loadingstrategy: ol.LoadingStrategy; +var multiLineString: ol.geom.MultiLineString; +var multiPoint: ol.geom.MultiPoint; +var multiPolygon: ol.geome.MultiPolygon; +var point: ol.geom.Point; +var polygon: ol.geom.Polygon; +var simpleGeometry: ol.geom.SimpleGeometry; var tilegrid: ol.tilegrid.TileGrid; var vector: ol.source.Vector; var projection: ol.proj.Projection; +var projectionLike: ol.proj.ProjectionLike; +var transformFn: ol.TransformFunction; // // ol.Attribution @@ -103,17 +120,172 @@ loadingstrategy = ol.loadingstrategy.all; loadingstrategy = ol.loadingstrategy.bbox; loadingstrategy = ol.loadingstrategy.tile(tilegrid); +// +// +// ol.geom.Circle +// +booleanValue = circle.intersectsExtent(extent); +circle = circle.transform(projectionLike, projectionLike); + // // // ol.geom.Geometry // - var geometryResult: ol.geom.Geometry; coordinate = geometryResult.getClosestPoint(coordinate); geometryResult.getClosestPoint(coordinate, coordinate); extent = geometryResult.getExtent(); geometryResult.getExtent(extent); +// +// +// ol.geom.GeometryCollection +// +geometryCollection = new ol.geom.GeometryCollection(geometriesArray) +geometryCollection = new ol.geom.GeometryCollection(); +voidValue = geometryCollection.applyTransform(transformFn); +geometryCollection = geometryCollection.clone(); +geometriesArray = geometryCollection.getGeometries(); +geometryType = geometryCollection.getType(); +booleanValue = geometryCollection.intersectsExtent(extent); +voidValue = geometryCollection.setGeometries(geometriesArray); + +// +// +// ol.geom.LinearRing +// +linearRing = new ol.geom.LinearRing(coordinatesArray); +linearRing = new ol.geom.LinearRing(coordinatesArray, geometryLayout); +linearRing = linearRing.clone(); +numberValue = linearRing.getArea(); +coordinatesArray = linearRing.getCoordinates(); +geometryType = linearRing.getType(); +voidValue = linearRing.setCoordinates(coordinatesArray); +voidValue = linearRing.setCoordinates(coordinatesArray, geometryLayout); + +// +// +// ol.geom.LineString +// +lineString = new ol.geom.LineString(coordinatesArray); +lineString = new ol.geom.LineString(coordinatesArray, geometryLayout); +voidValue = lineString.appendCoordinate(coordinate); +lineString = lineString.clone(); +coordinate = lineString.getCoordinateAtM(numberValue); +coordinate = lineString.getCoordinateAtM(numberValue, booleanValue); +coordinatesArray = lineString.getCoordinates(); +numberValue = lineString.getLength(); +geometryType = lineString.getType(); +booleanValue = lineString.intersectsExtent(extent); +voidValue = lineString.setCoordinates(coordinatesArray); +voidValue = lineString.setCoordinates(coordinatesArray, geometryLayout); + +// +// +// ol.geom.MultiLineString +// +var lineStringsArray: Array; + +multiLineString = new ol.geom.MultiLineString(coordinatesArrayDim2); +multiLineString = new ol.geom.MultiLineString(coordinatesArrayDim2, geometryLayout); +voidValue = multiLineString.appendLineString(lineString); +multiLineString = multiLineString.clone(); +coordinate = multiLineString.getCoordinateAtM(numberValue); +coordinate = multiLineString.getCoordinateAtM(numberValue, booleanValue); +coordinate = multiLineString.getCoordinateAtM(numberValue, booleanValue, booleanValue); +coordinatesArrayDim2 = multiLineString.getCoordinates(); +lineString = multiLineString.getLineString(numberValue); +lineStringsArray = multiLineString.getLineStrings(); +geometryType = multiLineString.getType(); +booleanValue = multiLineString.intersectsExtent(extent); +voidValue = multiLineString.setCoordinates(coordinatesArrayDim2); +voidValue = multiLineString.setCoordinates(coordinatesArrayDim2, geometryLayout); + +// +// +// ol.geom.MultiPoint +// +var pointsArray: Array; + +multiPoint = new ol.geom.MultiPoint(coordinatesArray); +multiPoint = new ol.geom.MultiPoint(coordinatesArray, geometryLayout); +voidValue = multiPoint.appendPoint(point); +multiPoint = multiPoint.clone(); +coordinatesArray = multiPoint.getCoordinates(); +point = multiPoint.getPoint(numberValue); +pointsArray = multiPoint.getPoints(); +geometryType = multiPoint.getGeometryType(); +booleanValue = multiPoint.intersectsExtent(extent); +voidValue = multiPoint.setCoordinates(coordinatesArray); +voidValue = multiPoint.setCoordinates(coordinatesArray, geometryLayout); + +// +// +// ol.geom.MultiPolygon +// +var coordinatesArrayDim3: Array>>; +var polygonsArray: Array; + +multiPolygon = new ol.geom.MultiPolygon(coordinatesArrayDim3); +multiPolygon = new ol.geom.MultiPolygon(coordinatesArrayDim3, geometryLayout); +voidValue = multiPolygon.appendPolygon(polygon); +multiPolygon = multiPolygon.clone(); +numberValue = multiPolygon.getArea(); +coordinatesArrayDim3 = multiPolygon.getCoordinates(); +coordinatesArrayDim3 = multiPolygon.getCoordinates(booleanValue); +multiPoint = multiPolygon.getInteriorPoints(); +polygon = multiPolygon.getPolygon(numberValue); +polygonsArray = multiPolygon.getPolygons(); +geometryType = multiPolygon.getType(); +booleanValue = multiPolygon.intersectsExtent(extent); +voidValue = multiPolygon.setCoordinates(coordinatesArrayDim3); +voidValue = multiPolygon.setCoordinates(coordinatesArrayDim3, geometryLayout); + +// +// +// ol.geom.Point +// +point = new ol.geom.Point(coordinate); +point = new ol.geom.Point(coordinate, geometryLayout); +point = point.clone(); +coordinate = point.getCoordinates(); +geometryType = point.getType(); +booleanValue = point.intersectsExtent(extent); +voidValue = point.setCoordinates(coordinate); +voidValue = point.setCoordinates(coordinate, geometryLayout); + +// +// +// ol.geom.Polygon +// +var localSphere: ol.sphere; +var linearRingsArray: Array; + +polygon = new ol.geom.Polygon(coordinatesArrayDim2); +polygon = new ol.geom.Polygon(coordinatesArrayDim2, geometryLayout); +polygon = ol.geom.Polygon.circular(localSphere, coordinate, numberValue); +polygon = ol.geom.Polygon.circular(localSphere, coordinate, numberValue, numberValue); +voidValue = polygon.appendLinearRing(linearRing); +polygon = polygon.clone(); +numberValue = polygon.getArea(); +coordinatesArrayDim2 = polygon.getCoordinates(); +coordinatesArrayDim2 = polygon.getCoordinates(booleanValue); +point = polygon.getInteriorPoint(); +linearRing = polygon.getLinearRing(numberValue); +linearRingsArray = polygon.getLinearRings(); +geometryType = polygon.getType(); +booleanValue = polygon.intersectsExtent(extent); + +// +// +// ol.geom.SimpleGeometry +// +simpleGeometry.applyTransform(transformFn); +coordinate = simpleGeometry.getFirstCoordinate(); +coordinate = simpleGeometry.getLastCoordinate(); +geometryLayout = simpleGeometry.getGeometryLayout(); +voidValue = simpleGeometry.translate(numberValue, numberValue); + // // ol.source // From 5bca47d46a833a2ccd7910a3697c04a119011422 Mon Sep 17 00:00:00 2001 From: mathieudugal Date: Tue, 15 Sep 2015 17:21:24 -0400 Subject: [PATCH 33/89] Fix errors --- openlayers/openlayers-tests.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/openlayers/openlayers-tests.ts b/openlayers/openlayers-tests.ts index 1e59ebb445..f60e45bd94 100644 --- a/openlayers/openlayers-tests.ts +++ b/openlayers/openlayers-tests.ts @@ -43,7 +43,7 @@ var lineString: ol.geom.LineString; var loadingstrategy: ol.LoadingStrategy; var multiLineString: ol.geom.MultiLineString; var multiPoint: ol.geom.MultiPoint; -var multiPolygon: ol.geome.MultiPolygon; +var multiPolygon: ol.geom.MultiPolygon; var point: ol.geom.Point; var polygon: ol.geom.Polygon; var simpleGeometry: ol.geom.SimpleGeometry; @@ -214,7 +214,7 @@ multiPoint = multiPoint.clone(); coordinatesArray = multiPoint.getCoordinates(); point = multiPoint.getPoint(numberValue); pointsArray = multiPoint.getPoints(); -geometryType = multiPoint.getGeometryType(); +geometryType = multiPoint.getType(); booleanValue = multiPoint.intersectsExtent(extent); voidValue = multiPoint.setCoordinates(coordinatesArray); voidValue = multiPoint.setCoordinates(coordinatesArray, geometryLayout); @@ -258,7 +258,7 @@ voidValue = point.setCoordinates(coordinate, geometryLayout); // // ol.geom.Polygon // -var localSphere: ol.sphere; +var localSphere: ol.Sphere; var linearRingsArray: Array; polygon = new ol.geom.Polygon(coordinatesArrayDim2); @@ -283,7 +283,7 @@ booleanValue = polygon.intersectsExtent(extent); simpleGeometry.applyTransform(transformFn); coordinate = simpleGeometry.getFirstCoordinate(); coordinate = simpleGeometry.getLastCoordinate(); -geometryLayout = simpleGeometry.getGeometryLayout(); +geometryLayout = simpleGeometry.getLayout(); voidValue = simpleGeometry.translate(numberValue, numberValue); // From 930256560156f9c8a9694ee0f4087aee8d9122dd Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Wed, 16 Sep 2015 03:11:24 +0500 Subject: [PATCH 34/89] lodash: changed _.slice() method --- lodash/lodash-tests.ts | 14 ++++++++++++-- lodash/lodash.d.ts | 28 +++++++++++++++++++++++++++- 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 5b9add244c..56734e3a4a 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -135,8 +135,6 @@ result = _([1, 2, 3, 4]).pop(); result = <_.LoDashArrayWrapper>_([1, 2, 3, 4]).push(5, 6, 7); result = <_.LoDashArrayWrapper>_([1, 2, 3, 4]).reverse(); result = _([1, 2, 3, 4]).shift(); -result = <_.LoDashArrayWrapper>_([1, 2, 3, 4]).slice(1, 2); -result = <_.LoDashArrayWrapper>_([1, 2, 3, 4]).slice(2); result = <_.LoDashArrayWrapper>_([1, 2, 3, 4]).sort((a, b) => 1); result = <_.LoDashArrayWrapper>_([1, 2, 3, 4]).splice(1); result = <_.LoDashArrayWrapper>_([1, 2, 3, 4]).splice(1, 2, 5, 6); @@ -315,6 +313,18 @@ result = _.remove(foodsOrganic, 'organic'); result = _.remove(foodsType, { 'type': 'vegetable' }); var typedResult: IFoodType[] = _.remove([ { name: 'apple' }, { name: 'orange' }], { name: 'orange' }); +// _.slice +{ + let testSliceArray: TResult[]; + let result: TResult[]; + result = _.slice(testSliceArray); + result = _.slice(testSliceArray, 42); + result = _.slice(testSliceArray, 42, 42); + result = _(testSliceArray).slice().value(); + result = _(testSliceArray).slice(42).value(); + result = _(testSliceArray).slice(42, 42).value(); +} + result = _.sortedIndex([20, 30, 50], 40); result = _.sortedIndex([{ 'x': 20 }, { 'x': 30 }, { 'x': 50 }], { 'x': 40 }, 'x'); var sortedIndexDict: { wordToNumber: { [idx: string]: number } } = { diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index b6c95710bd..bdc6d129e8 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -258,7 +258,6 @@ declare module _ { push(...items: T[]): LoDashArrayWrapper; reverse(): LoDashArrayWrapper; shift(): T; - slice(start: number, end?: number): LoDashArrayWrapper; sort(compareFn?: (a: T, b: T) => number): LoDashArrayWrapper; splice(start: number): LoDashArrayWrapper; splice(start: number, deleteCount: number, ...items: any[]): LoDashArrayWrapper; @@ -1417,6 +1416,33 @@ declare module _ { whereValue: W): T[]; } + //_.slice + interface LoDashStatic { + /** + * Creates a slice of array from start up to, but not including, end. + * + * @param array The array to slice. + * @param start The start position. + * @param end The end position. + * @return Returns the slice of array. + */ + slice( + array: T[], + start?: number, + end?: number + ): T[]; + } + + interface LoDashArrayWrapper { + /** + * @see _.slice + */ + slice( + start?: number, + end?: number + ): LoDashArrayWrapper; + } + //_.sortedIndex interface LoDashStatic { /** From d92927cf93831fc3b0ea7fa2cedaa3d2361ad696 Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Wed, 16 Sep 2015 02:28:13 +0500 Subject: [PATCH 35/89] lodash: added _.unzipWith() method --- lodash/lodash-tests.ts | 18 ++++++++++++++++++ lodash/lodash.d.ts | 43 ++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 59 insertions(+), 2 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 5b9add244c..167620da56 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -363,6 +363,24 @@ result = _(['A', 'b', 'C', 'a', 'B', 'c']).unique(function (letter) { result = _([1, 2.5, 3, 1.5, 2, 3.5]).unique(function (num) { return this.floor(num); }, Math).value(); result = <{ x: number; }[]>_([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }]).unique('x').value(); +// _.unzipWith +{ + let testUnzipWithArray: (number[]|_.List)[]; + let testUnzipWithList: _.List>; + let testUnzipWithIterator: {(prev: TResult, curr: number, index?: number, list?: number[]): TResult}; + let result: TResult[]; + result = _.unzipWith(testUnzipWithArray); + result = _.unzipWith(testUnzipWithArray, testUnzipWithIterator); + result = _.unzipWith(testUnzipWithArray, testUnzipWithIterator, any); + result = _.unzipWith(testUnzipWithList); + result = _.unzipWith(testUnzipWithList, testUnzipWithIterator); + result = _.unzipWith(testUnzipWithList, testUnzipWithIterator, any); + result = _(testUnzipWithArray).unzipWith(testUnzipWithIterator).value(); + result = _(testUnzipWithArray).unzipWith(testUnzipWithIterator, any).value(); + result = _(testUnzipWithList).unzipWith(testUnzipWithIterator).value(); + result = _(testUnzipWithList).unzipWith(testUnzipWithIterator, any).value(); +} + result = _.without([1, 2, 1, 0, 3, 1, 4], 0, 1); // _.xor diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index b6c95710bd..077576a840 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -1852,6 +1852,45 @@ declare module _ { whereValue: W): LoDashArrayWrapper; } + //_.unzipWith + interface LoDashStatic { + /** + * This method is like _.unzip except that it accepts an iteratee to specify how regrouped values should be + * combined. The iteratee is bound to thisArg and invoked with four arguments: (accumulator, value, index, + * group). + * + * @param array The array of grouped elements to process. + * @param iteratee The function to combine regrouped values. + * @param thisArg The this binding of iteratee. + * @return Returns the new array of regrouped elements. + */ + unzipWith( + array: List>, + iteratee?: MemoIterator, + thisArg?: any + ): TResult[]; + } + + interface LoDashArrayWrapper { + /** + * @see _.unzipWith + */ + unzipWith( + iteratee?: MemoIterator, + thisArg?: any + ): LoDashArrayWrapper; + } + + interface LoDashObjectWrapper { + /** + * @see _.unzipWith + */ + unzipWith( + iteratee?: MemoIterator, + thisArg?: any + ): LoDashArrayWrapper; + } + //_.without interface LoDashStatic { /** @@ -8489,10 +8528,10 @@ declare module _ { } interface MemoVoidIterator { - (prev: TResult, curr: T, indexOrKey: any, list?: T[]): void; + (prev: TResult, curr: T, indexOrKey?: any, list?: T[]): void; } interface MemoIterator { - (prev: TResult, curr: T, indexOrKey: any, list?: T[]): TResult; + (prev: TResult, curr: T, indexOrKey?: any, list?: T[]): TResult; } /* interface MemoListIterator { From fda3f446c8d12557aae3223830bae8bf07721e8f Mon Sep 17 00:00:00 2001 From: Andrew Fong Date: Wed, 16 Sep 2015 00:00:24 +0000 Subject: [PATCH 36/89] chrome.runtime.openOptionsPage --- chrome/chrome-tests.ts | 9 +++++++++ chrome/chrome.d.ts | 1 + 2 files changed, 10 insertions(+) diff --git a/chrome/chrome-tests.ts b/chrome/chrome-tests.ts index cbbe93791f..f17c9abc8e 100644 --- a/chrome/chrome-tests.ts +++ b/chrome/chrome-tests.ts @@ -249,3 +249,12 @@ function contentSettings() { } }); } + +// https://developer.chrome.com/extensions/runtime#method-openOptionsPage +function testOptionsPage() { + chrome.runtime.openOptionsPage(); + chrome.runtime.openOptionsPage(function() { + // Do a thing ... + }); +} + diff --git a/chrome/chrome.d.ts b/chrome/chrome.d.ts index 2fc2fb6fc6..34bb95205c 100755 --- a/chrome/chrome.d.ts +++ b/chrome/chrome.d.ts @@ -1649,6 +1649,7 @@ declare module chrome.runtime { export function getPackageDirectoryEntry(callback: (directoryEntry: any) => void): void; export function getPlatformInfo(callback: (platformInfo: PlatformInfo) => void): void; export function getURL(path: string): string; + export function openOptionsPage(callback?: () => void): void; export function reload(): void; export function requestUpdateCheck(callback: (status: string, details?: UpdateCheckDetails) => void): void; export function restart(): void; From 2aace82653a4a5658385ec844fb672a933c0294f Mon Sep 17 00:00:00 2001 From: psnider Date: Wed, 16 Sep 2015 00:42:38 +0000 Subject: [PATCH 37/89] Added Error to support stack --- node/node.d.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/node/node.d.ts b/node/node.d.ts index b7edca1f70..fa29b88f48 100644 --- a/node/node.d.ts +++ b/node/node.d.ts @@ -9,6 +9,11 @@ * * ************************************************/ +interface Error { + stack?: string; +} + + // compat for TypeScript 1.5.3 // if you use with --target es3 or --target es5 and use below definitions, // use the lib.es6.d.ts that is bundled with TypeScript 1.5.3. From 1c048a3cf65c5a57e0b0f66a48cd1040fea6e2f2 Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Wed, 16 Sep 2015 19:52:53 +0500 Subject: [PATCH 38/89] lodash: added _.prototype.plant() method --- lodash/lodash-tests.ts | 26 ++++++++++++++++++++++++++ lodash/lodash.d.ts | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index fc36241c58..af1dbe3e89 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -453,6 +453,32 @@ result = _([1, 2]).zipWith([1, 2], [1, 2], [1, 2], [1, 2], [1, result = _({}).commit(); } +// _.prototype.plant +{ + let result: _.LoDashWrapper; + result = _(any).plant(42); +} +{ + let result: _.LoDashStringWrapper; + result = _(any).plant(''); +} +{ + let result: _.LoDashWrapper; + result = _(any).plant(true); +} +{ + let result: _.LoDashNumberArrayWrapper; + result = _(any).plant([42]); +} +{ + let result: _.LoDashArrayWrapper; + result = _(any).plant([]); +} +{ + let result: _.LoDashObjectWrapper<{}>; + result = _(any).plant<{}>({}); +} + /************** * Collection * **************/ diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index db2405580a..7ec04214ce 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -2066,6 +2066,46 @@ declare module _ { commit(): TWrapper; } + //_.prototype.plant + interface LoDashWrapperBase { + /** + * Creates a clone of the chained sequence planting value as the wrapped value. + * @param value The value to plant as the wrapped value. + * @return Returns the new lodash wrapper instance. + */ + plant(value: number): LoDashWrapper; + + /** + * @see _.plant + */ + plant(value: string): LoDashStringWrapper; + + /** + * @see _.plant + */ + plant(value: boolean): LoDashWrapper; + + /** + * @see _.plant + */ + plant(value: number[]): LoDashNumberArrayWrapper; + + /** + * @see _.plant + */ + plant(value: T[]): LoDashArrayWrapper; + + /** + * @see _.plant + */ + plant(value: T): LoDashObjectWrapper; + + /** + * @see _.plant + */ + plant(value: any): LoDashWrapper; + } + /************** * Collection * **************/ From 8c900f86c78582ce6ea8213249f42be1d06f381d Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Mon, 14 Sep 2015 07:25:24 +0500 Subject: [PATCH 39/89] lodash: changed _.runInContext() method --- lodash/lodash-tests.ts | 11 ++++++++--- lodash/lodash.d.ts | 18 +++++++++++++----- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index fc36241c58..a2ab359c80 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -1768,9 +1768,6 @@ result = _([]).noop(true, 'a', 1); result = _({}).noop(true, 'a', 1); result = _(any).noop(true, 'a', 1); -var tempObject = {}; -result = _.runInContext(tempObject); - // _.property interface TestPropertyObject { a: { @@ -2084,6 +2081,14 @@ result = (_(TestMethodOfObject).methodOf(1, 2).value())(['a', '0 result = _({}).noConflict(); } +// _.runInContext +{ + let result: typeof _; + result = _.runInContext(); + result = _.runInContext({}); + result = _({}).runInContext(); +} + // _.uniqueId result = _.uniqueId(); result = _.uniqueId(''); diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index db2405580a..7c2f61574d 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -8552,11 +8552,19 @@ declare module _ { //_.runInContext interface LoDashStatic { /** - * Create a new lodash function using the given context object. - * @param context The context object - * @returns The lodash function. - **/ - runInContext(context: any): typeof _; + * Create a new pristine lodash function using the given context object. + * + * @param context The context object. + * @return Returns a new lodash function. + */ + runInContext(context?: Object): typeof _; + } + + interface LoDashObjectWrapper { + /** + * @see _.runInContext + */ + runInContext(): typeof _; } //_.times From de0d7f205e8cbb3127514f94708391d759660b5f Mon Sep 17 00:00:00 2001 From: tkqubo Date: Thu, 17 Sep 2015 06:00:34 +0900 Subject: [PATCH 40/89] Add gulp-svg-sprite --- gulp-svg-sprite/gulp-svg-sprite-tests.ts | 51 ++++++++++++++++++++++++ gulp-svg-sprite/gulp-svg-sprite.d.ts | 22 ++++++++++ svg-sprite/svg-sprite.d.ts | 4 +- 3 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 gulp-svg-sprite/gulp-svg-sprite-tests.ts create mode 100644 gulp-svg-sprite/gulp-svg-sprite.d.ts diff --git a/gulp-svg-sprite/gulp-svg-sprite-tests.ts b/gulp-svg-sprite/gulp-svg-sprite-tests.ts new file mode 100644 index 0000000000..6c1ba71df9 --- /dev/null +++ b/gulp-svg-sprite/gulp-svg-sprite-tests.ts @@ -0,0 +1,51 @@ +/// +/// +/// + +import svgSprite = require('gulp-svg-sprite'); +import spriter = require('svg-sprite'); +import gulp = require('gulp') + +let config: spriter.Config; + +// Basic configuration example +config = { + mode : { + css : { // Activate the «css» mode + render : { + css : true // Activate CSS output (with default options) + } + } + } +}; + +gulp.src('**/*.svg', {cwd: 'path/to/assets'}) + .pipe(svgSprite(config)) + .pipe(gulp.dest('out')); + + +config = { + shape : { + dimension : { // Set maximum dimensions + maxWidth : 32, + maxHeight : 32 + }, + spacing : { // Add padding + padding : 10 + }, + dest : 'out/intermediate-svg' // Keep the intermediate files + }, + mode : { + view : { // Activate the «view» mode + bust : false, + render : { + scss : true // Activate Sass output (with default options) + } + }, + symbol : true // Activate the «symbol» mode + } +}; + +gulp.src('**/*.svg', {cwd: 'path/to/assets'}) + .pipe(svgSprite(config)) + .pipe(gulp.dest('out')); diff --git a/gulp-svg-sprite/gulp-svg-sprite.d.ts b/gulp-svg-sprite/gulp-svg-sprite.d.ts new file mode 100644 index 0000000000..094c5e2eb1 --- /dev/null +++ b/gulp-svg-sprite/gulp-svg-sprite.d.ts @@ -0,0 +1,22 @@ +// Type definitions for gulp-svg-sprite +// Project: https://github.com/jkphl/gulp-svg-sprite +// Definitions by: Qubo +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// +/// + +declare module "gulp-svg-sprite" { + import spriter = require('svg-sprite'); + + namespace svgSprite { + interface SvgSprite { + (options?: spriter.Config): NodeJS.ReadWriteStream; + } + } + + var svgSprite: svgSprite.SvgSprite; + + export = svgSprite; +} + diff --git a/svg-sprite/svg-sprite.d.ts b/svg-sprite/svg-sprite.d.ts index c319fb174b..3030bc05a8 100644 --- a/svg-sprite/svg-sprite.d.ts +++ b/svg-sprite/svg-sprite.d.ts @@ -291,12 +291,12 @@ declare module "svg-sprite" { * which all reside in the directory tmpl/css. Example: {css: true, scss: {dest: '_sprite.scss'}} * @default {} */ - render?: { [key: string]: RenderingConfiguration }; + render?: { [key: string]: RenderingConfiguration|boolean }; /** * Enabling this will trigger the creation of an HTML document demoing the usage of the sprite. Please see below for details on [rendering configurations](#rendering-configurations). * @default false */ - example?: RenderingConfiguration; + example?: RenderingConfiguration|boolean; /** * Specify svg-sprite which output mode to use with this configuration */ From 06d310cac577b8e4bfdbc2cd0e367e694029746a Mon Sep 17 00:00:00 2001 From: tkqubo Date: Thu, 17 Sep 2015 06:01:56 +0900 Subject: [PATCH 41/89] Add version --- gulp-svg-sprite/gulp-svg-sprite.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gulp-svg-sprite/gulp-svg-sprite.d.ts b/gulp-svg-sprite/gulp-svg-sprite.d.ts index 094c5e2eb1..50aa003627 100644 --- a/gulp-svg-sprite/gulp-svg-sprite.d.ts +++ b/gulp-svg-sprite/gulp-svg-sprite.d.ts @@ -1,4 +1,4 @@ -// Type definitions for gulp-svg-sprite +// Type definitions for gulp-svg-sprite 1.2.9 // Project: https://github.com/jkphl/gulp-svg-sprite // Definitions by: Qubo // Definitions: https://github.com/borisyankov/DefinitelyTyped From b1c0b5542da12ee4792d72740a1ce07516da23ab Mon Sep 17 00:00:00 2001 From: mfrantz Date: Wed, 16 Sep 2015 16:49:21 -0700 Subject: [PATCH 42/89] bluebird: Add 'each' --- bluebird/bluebird-tests.ts | 47 ++++++++++++++++++++++++++++++++++++++ bluebird/bluebird.d.ts | 17 ++++++++++++++ 2 files changed, 64 insertions(+) diff --git a/bluebird/bluebird-tests.ts b/bluebird/bluebird-tests.ts index 2377da0d00..b8eecf2cad 100644 --- a/bluebird/bluebird-tests.ts +++ b/bluebird/bluebird-tests.ts @@ -550,6 +550,13 @@ fooArrProm = fooArrProm.filter((item: Foo) => { // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +fooArrProm = fooArrProm.each((item: Foo): Bar => bar); +fooArrProm = fooArrProm.each((item: Foo, index: number): Bar => index ? bar : null); +fooArrProm = fooArrProm.each((item: Foo, index: number, arrayLength: number): Bar => bar); +fooArrProm = fooArrProm.each((item: Foo, index: number, arrayLength: number): Promise => barProm); + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + fooProm = Promise.try(() => { return foo; @@ -1123,3 +1130,43 @@ fooArrProm = Promise.filter(fooArr, (item: Foo, index: number, arrayLength: numb }); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +// each() + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +// fooThenArrThen + +fooArrThen = Promise.each(fooThenArrThen, (item: Foo) => bar); +fooArrThen = Promise.each(fooThenArrThen, (item: Foo) => barThen); +fooArrThen = Promise.each(fooThenArrThen, (item: Foo, index: number, arrayLength: number) => bar); +fooArrThen = Promise.each(fooThenArrThen, (item: Foo, index: number, arrayLength: number) => barThen); + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +// fooArrThen + +fooArrThen = Promise.each(fooArrThen, (item: Foo) => bar); +fooArrThen = Promise.each(fooArrThen, (item: Foo) => barThen); +fooArrThen = Promise.each(fooArrThen, (item: Foo, index: number, arrayLength: number) => bar); +fooArrThen = Promise.each(fooArrThen, (item: Foo, index: number, arrayLength: number) => barThen); + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +// fooThenArr + +fooArrThen = Promise.each(fooThenArr, (item: Foo) => bar); +fooArrThen = Promise.each(fooThenArr, (item: Foo) => barThen); +fooArrThen = Promise.each(fooThenArr, (item: Foo, index: number, arrayLength: number) => bar); +fooArrThen = Promise.each(fooThenArr, (item: Foo, index: number, arrayLength: number) => barThen); + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +// fooArr + +fooArrThen = Promise.each(fooArr, (item: Foo) => bar); +fooArrThen = Promise.each(fooArr, (item: Foo) => barThen); +fooArrThen = Promise.each(fooArr, (item: Foo, index: number, arrayLength: number) => bar); +fooArrThen = Promise.each(fooArr, (item: Foo, index: number, arrayLength: number) => barThen); + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/bluebird/bluebird.d.ts b/bluebird/bluebird.d.ts index 543a2ef0a0..dcf1a57a06 100644 --- a/bluebird/bluebird.d.ts +++ b/bluebird/bluebird.d.ts @@ -328,6 +328,11 @@ declare class Promise implements Promise.Thenable, Promise.Inspection { filter(filterer: (item: U, index: number, arrayLength: number) => Promise.Thenable, options?: Promise.ConcurrencyOption): Promise; filter(filterer: (item: U, index: number, arrayLength: number) => boolean, options?: Promise.ConcurrencyOption): Promise; + /** + * Same as calling ``Promise.each(thisPromise, iterator)``. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. + */ + each(iterator: (item: R, index: number, arrayLength: number) => U | Promise.Thenable): Promise; + /** * Start the chain of promises with `Promise.try`. Any synchronous exceptions will be turned into rejections on the returned promise. * @@ -607,6 +612,18 @@ declare class Promise implements Promise.Thenable, Promise.Inspection { // array with values static filter(values: R[], filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable, option?: Promise.ConcurrencyOption): Promise; static filter(values: R[], filterer: (item: R, index: number, arrayLength: number) => boolean, option?: Promise.ConcurrencyOption): Promise; + + /** + * Iterate over an array, or a promise of an array, which contains promises (or a mix of promises and values) with the given iterator function with the signature (item, index, value) where item is the resolved value of a respective promise in the input array. Iteration happens in serially. If any promise in the input array is rejected the returned promise is rejected as well. + * + * Resolves to the original array unmodified, this method is meant to be used for side effects. If the iterator function returns a promise or a thenable, the result for the promise is awaited for before continuing with next iteration. + */ + // promise of array with promises of value + static each(values: Promise.Thenable[]>, iterator: (item: R, index: number, arrayLength: number) => U | Promise.Thenable): Promise; + // array with promises of value + static each(values: Promise.Thenable[], iterator: (item: R, index: number, arrayLength: number) => U | Promise.Thenable): Promise; + // array with values OR promise of array with values + static each(values: R[] | Promise.Thenable, iterator: (item: R, index: number, arrayLength: number) => U | Promise.Thenable): Promise; } declare module Promise { From 5fd34fe3e2ac3945694ebb08cc502fb61b510037 Mon Sep 17 00:00:00 2001 From: Stephen Lautier Date: Thu, 17 Sep 2015 01:53:52 +0200 Subject: [PATCH 43/89] added new property "typescript" within Params --- gulp-typescript/gulp-typescript.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/gulp-typescript/gulp-typescript.d.ts b/gulp-typescript/gulp-typescript.d.ts index da517a511b..7b16d0a5a2 100644 --- a/gulp-typescript/gulp-typescript.d.ts +++ b/gulp-typescript/gulp-typescript.d.ts @@ -23,6 +23,7 @@ declare module "gulp-typescript" { sourceRoot?: string; sortOutput?: boolean; target?: string; + typescript?: any; } interface Project { From d36fd3b0621c917cf5a7f5c1c6484cdd3003599e Mon Sep 17 00:00:00 2001 From: mfrantz Date: Wed, 16 Sep 2015 17:08:10 -0700 Subject: [PATCH 44/89] bluebird: Fix typo in 'each' comment copied from wiki This typo has since been fixed in the original document: https://github.com/petkaantonov/bluebird/blob/master/API.md#eachfunction-iterator---promise --- bluebird/bluebird.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bluebird/bluebird.d.ts b/bluebird/bluebird.d.ts index dcf1a57a06..350761fddc 100644 --- a/bluebird/bluebird.d.ts +++ b/bluebird/bluebird.d.ts @@ -614,7 +614,7 @@ declare class Promise implements Promise.Thenable, Promise.Inspection { static filter(values: R[], filterer: (item: R, index: number, arrayLength: number) => boolean, option?: Promise.ConcurrencyOption): Promise; /** - * Iterate over an array, or a promise of an array, which contains promises (or a mix of promises and values) with the given iterator function with the signature (item, index, value) where item is the resolved value of a respective promise in the input array. Iteration happens in serially. If any promise in the input array is rejected the returned promise is rejected as well. + * Iterate over an array, or a promise of an array, which contains promises (or a mix of promises and values) with the given iterator function with the signature (item, index, value) where item is the resolved value of a respective promise in the input array. Iteration happens serially. If any promise in the input array is rejected the returned promise is rejected as well. * * Resolves to the original array unmodified, this method is meant to be used for side effects. If the iterator function returns a promise or a thenable, the result for the promise is awaited for before continuing with next iteration. */ From 3251d88b3a375de5043e7aa47d2706579954ac2a Mon Sep 17 00:00:00 2001 From: Ritzlgrmft Date: Thu, 17 Sep 2015 11:02:48 +0200 Subject: [PATCH 45/89] naming convention fixed Travis errors fixed --- cordova-plugin-app-version/appversion.d.ts | 8 -------- ...ests.ts => cordova-plugin-app-version-tests.ts} | 4 ++-- .../cordova-plugin-app-version.d.ts | 14 ++++++++++++++ 3 files changed, 16 insertions(+), 10 deletions(-) delete mode 100644 cordova-plugin-app-version/appversion.d.ts rename cordova-plugin-app-version/{appversion-tests.ts => cordova-plugin-app-version-tests.ts} (77%) create mode 100644 cordova-plugin-app-version/cordova-plugin-app-version.d.ts diff --git a/cordova-plugin-app-version/appversion.d.ts b/cordova-plugin-app-version/appversion.d.ts deleted file mode 100644 index 4069e38daf..0000000000 --- a/cordova-plugin-app-version/appversion.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -interface Cordova { - getAppVersion: { - getAppName: () => ng.IPromise; - getPackageName: () => ng.IPromise; - getVersionCode: () => ng.IPromise; - getVersionNumber: () => ng.IPromise; - }; -} \ No newline at end of file diff --git a/cordova-plugin-app-version/appversion-tests.ts b/cordova-plugin-app-version/cordova-plugin-app-version-tests.ts similarity index 77% rename from cordova-plugin-app-version/appversion-tests.ts rename to cordova-plugin-app-version/cordova-plugin-app-version-tests.ts index 89858c3e50..9f366dfb86 100644 --- a/cordova-plugin-app-version/appversion-tests.ts +++ b/cordova-plugin-app-version/cordova-plugin-app-version-tests.ts @@ -1,5 +1,5 @@ -/// -/// +/// +/// cordova.getAppVersion.getAppName() .then(appName=> { console.log(appName) diff --git a/cordova-plugin-app-version/cordova-plugin-app-version.d.ts b/cordova-plugin-app-version/cordova-plugin-app-version.d.ts new file mode 100644 index 0000000000..8b99a9638b --- /dev/null +++ b/cordova-plugin-app-version/cordova-plugin-app-version.d.ts @@ -0,0 +1,14 @@ +/// +// Type definitions for cordova-plugin-app-version v0.1.7 +// Project: https://github.com/whiteoctober/cordova-plugin-app-version +// Definitions by: Markus Wagner +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +interface Cordova { + getAppVersion: { + getAppName: () => Q.IPromise; + getPackageName: () => Q.IPromise; + getVersionCode: () => Q.IPromise; + getVersionNumber: () => Q.IPromise; + }; +} \ No newline at end of file From 03f5ce9a40dcc719f681faa02b68cf61bd123a25 Mon Sep 17 00:00:00 2001 From: Matias Emanuel Surdi Date: Thu, 17 Sep 2015 13:01:57 +0200 Subject: [PATCH 46/89] Add noTimestamp option --- jsonwebtoken/jsonwebtoken.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/jsonwebtoken/jsonwebtoken.d.ts b/jsonwebtoken/jsonwebtoken.d.ts index 9f0baef2bc..205970f6a1 100644 --- a/jsonwebtoken/jsonwebtoken.d.ts +++ b/jsonwebtoken/jsonwebtoken.d.ts @@ -27,6 +27,7 @@ declare module "jsonwebtoken" { audience?: string; subject?: string; issuer?: string; + noTimestamp?: boolean; } export interface VerifyOptions { From 781e4c294d0721cf31344e721e0107d307c1a66b Mon Sep 17 00:00:00 2001 From: Ritzlgrmft Date: Thu, 17 Sep 2015 14:51:02 +0200 Subject: [PATCH 47/89] Travis errors fixed --- .../cordova-plugin-app-version-tests.ts | 3 ++- cordova-plugin-app-version/cordova-plugin-app-version.d.ts | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/cordova-plugin-app-version/cordova-plugin-app-version-tests.ts b/cordova-plugin-app-version/cordova-plugin-app-version-tests.ts index 9f366dfb86..3b27435bd4 100644 --- a/cordova-plugin-app-version/cordova-plugin-app-version-tests.ts +++ b/cordova-plugin-app-version/cordova-plugin-app-version-tests.ts @@ -1,5 +1,6 @@ /// -/// +/// + cordova.getAppVersion.getAppName() .then(appName=> { console.log(appName) diff --git a/cordova-plugin-app-version/cordova-plugin-app-version.d.ts b/cordova-plugin-app-version/cordova-plugin-app-version.d.ts index 8b99a9638b..a754368e38 100644 --- a/cordova-plugin-app-version/cordova-plugin-app-version.d.ts +++ b/cordova-plugin-app-version/cordova-plugin-app-version.d.ts @@ -1,9 +1,10 @@ -/// -// Type definitions for cordova-plugin-app-version v0.1.7 +// Type definitions for cordova-plugin-app-version v0.1.7 // Project: https://github.com/whiteoctober/cordova-plugin-app-version // Definitions by: Markus Wagner // Definitions: https://github.com/borisyankov/DefinitelyTyped +/// + interface Cordova { getAppVersion: { getAppName: () => Q.IPromise; From e9cc82ad94e783336c3cb82556dc8bdf62709be3 Mon Sep 17 00:00:00 2001 From: Ritzlgrmft Date: Thu, 17 Sep 2015 15:49:54 +0200 Subject: [PATCH 48/89] Internal logger logLog added --- log4javascript/log4javascript-tests.ts | 6 ++- log4javascript/log4javascript.d.ts | 60 +++++++++++++++----------- 2 files changed, 39 insertions(+), 27 deletions(-) diff --git a/log4javascript/log4javascript-tests.ts b/log4javascript/log4javascript-tests.ts index 7d55c3891b..c3b77c5b69 100644 --- a/log4javascript/log4javascript-tests.ts +++ b/log4javascript/log4javascript-tests.ts @@ -1,4 +1,4 @@ -/// +/// function aSimpleLoggingMessageString() { var log = log4javascript.getDefaultLogger(); @@ -47,4 +47,8 @@ function changingTheFormatOfLogMessages() { var popUpAppender = new log4javascript.PopUpAppender(); var layout = new log4javascript.PatternLayout("[%-5p] %m"); popUpAppender.setLayout(layout); +} + +function configureLogLog() { + log4javascript.logLog.setQuietMode(true); } \ No newline at end of file diff --git a/log4javascript/log4javascript.d.ts b/log4javascript/log4javascript.d.ts index 98f23d1f72..44d226d0b3 100644 --- a/log4javascript/log4javascript.d.ts +++ b/log4javascript/log4javascript.d.ts @@ -1051,38 +1051,46 @@ declare module log4javascript { // #region log4javascript error handling /** - * Sets whether LogLog is in quiet mode or not. In quiet mode, no messages sent to LogLog have any visible effect. By default, - * quiet mode is switched off. - * @param quietMode Whether to turn quiet mode on or off. + * log4javascript has a single rudimentary logger-like object of its own to handle messages generated by log4javascript itself. + * This logger is called logLog and is accessed via log4javascript.logLog. */ - export function setQuietMode(quietMode: boolean): void; + export namespace logLog { - /** - * Sets how many errors LogLog will display alerts for. By default, only the first error encountered generates an alert to the - * user. If you turn all errors on by supplying true to this method then all errors will generate alerts. - * @param showAllErrors Whether to show all errors or just the first. - */ - export function setAlertAllErrors(alertAllErrors: boolean): void; + /** + * Sets whether logLog is in quiet mode or not. In quiet mode, no messages sent to logLog have any visible effect. By default, + * quiet mode is switched off. + * @param quietMode Whether to turn quiet mode on or off. + */ + export function setQuietMode(quietMode: boolean): void; - /** - * Logs a debugging message to an in-memory list. - */ - export function debug(message: string, exception?: Error): void; + /** + * Sets how many errors logLog will display alerts for. By default, only the first error encountered generates an alert to the + * user. If you turn all errors on by supplying true to this method then all errors will generate alerts. + * @param showAllErrors Whether to show all errors or just the first. + */ + export function setAlertAllErrors(alertAllErrors: boolean): void; - /** - * Displays an alert of all debugging messages. - */ - export function displayDebug(): void; + /** + * Logs a debugging message to an in-memory list. + */ + export function debug(message: string, exception?: Error): void; - /** - * Currently has no effect. - */ - export function warn(message: string, exception?: Error): void; + /** + * Displays an alert of all debugging messages. + */ + export function displayDebug(): void; - /** - * Generates an alert to the user if and only if the error is the first one encountered and setAlertAllErrors(true) has not been called. - */ - export function error(message: string, exception?: Error): void; + /** + * Currently has no effect. + */ + export function warn(message: string, exception?: Error): void; + + /** + * Generates an alert to the user if and only if the error is the first one encountered and setAlertAllErrors(true) has not been called. + */ + export function error(message: string, exception?: Error): void; + + } // #endregion } From 64f0e13df830ca820116e794e71f7eee8fa19641 Mon Sep 17 00:00:00 2001 From: kpisaksen Date: Thu, 17 Sep 2015 16:16:23 +0200 Subject: [PATCH 49/89] Correcting array error When I added string array to the path parameter on use, I accidentally added ErrorRequestHandler array too. It's not removed. --- express/express.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/express/express.d.ts b/express/express.d.ts index 973d45fc72..e2f6d5df21 100644 --- a/express/express.d.ts +++ b/express/express.d.ts @@ -107,7 +107,7 @@ declare module "express" { use(path: string, ...handler: RequestHandler[]): T; use(path: string, handler: ErrorRequestHandler): T; use(path: string[], ...handler: RequestHandler[]): T; - use(path: string[], handler: ErrorRequestHandler[]): T; + use(path: string[], handler: ErrorRequestHandler): T; } export function Router(options?: any): Router; From c3bb5bb17e0aac32c386b2ed11aa4d334b0f374b Mon Sep 17 00:00:00 2001 From: Ritzlgrmft Date: Thu, 17 Sep 2015 16:31:15 +0200 Subject: [PATCH 50/89] Definitions for cordova-plugin-ibeacon added --- .../cordova-plugin-ibeacon-tests.ts | 62 ++++++++++++ .../cordova-plugin-ibeacon.d.ts | 95 +++++++++++++++++++ 2 files changed, 157 insertions(+) create mode 100644 cordova-plugin-ibeacon/cordova-plugin-ibeacon-tests.ts create mode 100644 cordova-plugin-ibeacon/cordova-plugin-ibeacon.d.ts diff --git a/cordova-plugin-ibeacon/cordova-plugin-ibeacon-tests.ts b/cordova-plugin-ibeacon/cordova-plugin-ibeacon-tests.ts new file mode 100644 index 0000000000..7520c39d52 --- /dev/null +++ b/cordova-plugin-ibeacon/cordova-plugin-ibeacon-tests.ts @@ -0,0 +1,62 @@ +/// +/// + +function registerDelegates() { + cordova.plugins.locationManager.enableDebugLogs(); + + cordova.plugins.locationManager.delegate.didRangeBeaconsInRegion = (pluginResult) => didRangeBeaconsInRegion(pluginResult); + cordova.plugins.locationManager.delegate.didEnterRegion = (pluginResult) => didEnterRegion(pluginResult); + cordova.plugins.locationManager.delegate.didExitRegion = (pluginResult) => didExitRegion(pluginResult); + cordova.plugins.locationManager.delegate.didDetermineStateForRegion = (pluginResult) => didDetermineStateForRegion(pluginResult); + cordova.plugins.locationManager.delegate.didChangeAuthorizationStatus = (authorizationStatus) => didChangeAuthorizationStatus(authorizationStatus); + cordova.plugins.locationManager.delegate.didStartMonitoringForRegion = (pluginResult) => didStartMonitoringForRegion(pluginResult); + cordova.plugins.locationManager.delegate.monitoringDidFailForRegionWithError = (pluginResult) => monitoringDidFailForRegionWithError(pluginResult); + + cordova.plugins.locationManager.onDomDelegateReady(); +} + +function didRangeBeaconsInRegion(pluginResult: BeaconPlugin.PluginResult): void { + for (var beacon of pluginResult.beacons) { + console.log(beacon.uuid, beacon.major, beacon.minor, beacon.accuracy, beacon.proximity, beacon.rssi, beacon.tx); + } +} + +function didEnterRegion(pluginResult: BeaconPlugin.PluginResult): void { + var region: BeaconPlugin.Region = new cordova.plugins.locationManager.BeaconRegion("identifier", "uuid", 1, 2);; + cordova.plugins.locationManager.startRangingBeaconsInRegion(this.createBeaconRegionFromPluginResult(pluginResult)) + .then(() => { + console.log("startRangingBeaconsInRegion succeeded"); + }) + .catch((reason: any) => { + console.error("startRangingBeaconsInRegion failed: " + reason); + }); +} + +function didExitRegion(pluginResult: BeaconPlugin.PluginResult): void { + var region: BeaconPlugin.Region; + cordova.plugins.locationManager.stopRangingBeaconsInRegion(region) + .then(() => { + console.log("stopRangingBeaconsInRegion succeeded"); + }) + .catch((reason: any) => { + console.error("stopRangingBeaconsInRegion failed: " + reason); + }); +} + +function didDetermineStateForRegion(pluginResult: BeaconPlugin.PluginResult): void { + if (pluginResult.state === "CLRegionStateInside") { + console.log(pluginResult.region.identifier); + } +} + +function didChangeAuthorizationStatus(authorizationStatus: string): void { + console.log(authorizationStatus); +} + +function didStartMonitoringForRegion(pluginResult: BeaconPlugin.PluginResult): void { + console.log(pluginResult.region.identifier); +} + +function monitoringDidFailForRegionWithError(pluginResult: BeaconPlugin.PluginResult): void { + console.log(pluginResult.region.identifier); +} \ No newline at end of file diff --git a/cordova-plugin-ibeacon/cordova-plugin-ibeacon.d.ts b/cordova-plugin-ibeacon/cordova-plugin-ibeacon.d.ts new file mode 100644 index 0000000000..8f1f6af1a6 --- /dev/null +++ b/cordova-plugin-ibeacon/cordova-plugin-ibeacon.d.ts @@ -0,0 +1,95 @@ +// Type definitions for cordova-plugin-ibeacon v3.3.0 +// Project: https://github.com/petermetz/cordova-plugin-ibeacon +// Definitions by: Markus Wagner +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +interface CordovaPlugins { + locationManager: BeaconPlugin.LocationManager; +} + +declare module BeaconPlugin { + /** + * Beacon Plugin. + */ + export interface LocationManager { + delegate: Delegate; + BeaconRegion: BeaconRegion; + onDomDelegateReady(): void; + startMonitoringForRegion(region: Region): Q.Promise; + stopMonitoringForRegion(region: Region): Q.Promise; + requestStateForRegion(region: Region): Q.Promise; + startRangingBeaconsInRegion(region: Region): Q.Promise; + stopRangingBeaconsInRegion(region: Region): Q.Promise; + getAuthorizationStatus(): Q.Promise; + requestWhenInUseAuthorization(): Q.Promise; + requestAlwaysAuthorization(): Q.Promise; + getMonitoredRegions(): Q.Promise; + getRangedRegions(): Q.Promise; + isRangingAvailable(): Q.Promise; + isMonitoringAvailableForClass(region: Region): Q.Promise; + startAdvertising(region: Region, measuredPower: boolean): Q.Promise; + stopAdvertising(): Q.Promise; + isAdvertisingAvailable(): Q.Promise; + isAdvertising(): Q.Promise; + disableDebugLogs(): Q.Promise; + enableDebugNotifications(): Q.Promise; + disableDebugNotifications(): Q.Promise; + enableDebugLogs(): Q.Promise; + isBluetoothEnabled(): Q.Promise; + enableBluetooth(): Q.Promise; + disableBluetooth(): Q.Promise; + appendToDeviceLog(message: string): Q.Promise; + } + + export interface PluginResult { + eventType: string; + region: Region; + beacons: Beacon[]; + authorizationStatus: string; + state: string; + } + + export interface Delegate { + didDetermineStateForRegion(pluginResult: PluginResult): void; + didStartMonitoringForRegion(pluginResult: PluginResult): void; + didExitRegion(pluginResult: PluginResult): void; + didEnterRegion(pluginResult: PluginResult): void; + didRangeBeaconsInRegion(pluginResult: PluginResult): void; + peripheralManagerDidStartAdvertising(pluginResult: PluginResult): void; + peripheralManagerDidUpdateState(pluginResult: PluginResult): void; + didChangeAuthorizationStatus(authorizationStatus: string): void; + monitoringDidFailForRegionWithError(pluginResult: PluginResult): void; + } + + export interface Region { + identifier: string; + new (identifier: string): Region; + } + + export interface BeaconRegion extends Region { + uuid: string; + major: string; + minor: string; + notifyEntryStateOnDisplay: boolean; + new (identifier: string, uuid: string, major?: number, minor?: number, notifyEntryStateOnDisplay?: boolean): BeaconRegion; + } + + export interface CircularRegion extends Region { + latitude: number; + longitude: number; + radius: number; + new (identifier: string, latitude: number, longitude: number, radius: number): CircularRegion; + } + + export interface Beacon { + uuid: string; + major: string; + minor: string; + proximity: string; + tx: number; + rssi: number; + accuracy: number; + } +} From bf220bcf37b916fe838533dd6150212259d00e32 Mon Sep 17 00:00:00 2001 From: Ralf Sternberg Date: Thu, 17 Sep 2015 17:09:37 +0200 Subject: [PATCH 51/89] Add typescript definitions for Tabris.js --- tabris/README.md | 8 + tabris/tabris-tests.ts | 302 +++++++++ tabris/tabris.d.ts | 1446 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 1756 insertions(+) create mode 100644 tabris/README.md create mode 100644 tabris/tabris-tests.ts create mode 100644 tabris/tabris.d.ts diff --git a/tabris/README.md b/tabris/README.md new file mode 100644 index 0000000000..23d3d1a496 --- /dev/null +++ b/tabris/README.md @@ -0,0 +1,8 @@ +# TypeScript definitions for Tabris.js + +[Tabris.js](http://tabrisjs.com) is a framework for developing mobile apps with native UIs in JavaScript. +The JavaScript library is available on [npm](https://www.npmjs.com/package/tabris). + +Current supported version is 1.2. + +See http://definitelytyped.org/guides/contributing.html diff --git a/tabris/tabris-tests.ts b/tabris/tabris-tests.ts new file mode 100644 index 0000000000..28ab53cecd --- /dev/null +++ b/tabris/tabris-tests.ts @@ -0,0 +1,302 @@ +/// + +var page = tabris.create("Page", {}); + +function test_events() { + var listener = () => console.log("triggered"); + var widget = tabris.create("Composite", {}); + widget.on("foo", listener); + widget.trigger("foo", "details"); + widget.off("foo", listener); + widget.off("foo"); + widget.off(null, listener); + widget.off(); +} + +function test_Action() { + var widget: tabris.Action = tabris.create("Action", {}); + widget.set("foo", 23); + widget.set({ + image: {src: "http://example.org"}, + title: "foo", + placementPriority: "high" + }); + var self: tabris.Action = widget.on("event", function(widget: tabris.Action) {}); +} + +function test_Button() { + var widget: tabris.Button = tabris.create("Button", {}); + widget.set("foo", 23); + widget.set({ + width: 200, + height: 400, + alignment: "center", + image: {src: "http://example.org"}, + text: "foo" + }); +} + +function test_CheckBox() { + var widget: tabris.CheckBox = tabris.create("CheckBox", {}); + widget.set("foo", 23); + widget.set({ + selection: true, + text: "foo" + }); +} + +function test_Canvas() { + var widget: tabris.Canvas = tabris.create("Canvas", {}); + widget.set("foo", 23); + widget.set({ + }); + var ctx: tabris.CanvasContext = widget.getContext("2d", 200, 300); +} + +function test_Cell() { + var widget: tabris.Cell = tabris.create("Cell", {}); + widget.set("foo", 23); + widget.set({ + }); +} + +function test_CollectionView() { + var widget: tabris.CollectionView = tabris.create("CollectionView", {}); + widget.set("foo", 23); + widget.set({ + cellType: (item: any) => "foo", + initializeCell: (cell: tabris.Cell, type: string) => {}, + itemHeight: (item: any, type: string) => 23, + items: ["foo", "bar", "baz"], + refreshEnabled: true, + refreshIndicator: true, + refreshMessage: "foo" + }); + widget.insert(["item1", "item2"]); + widget.insert(["item1", "item2"], 3); + widget.refresh(); + widget.refresh(3); + widget.remove(3); + widget.remove(3, 2); + widget.reveal(23); +} + +function test_Composite() { + var widget: tabris.Composite = tabris.create("Composite", {}); + widget.set("foo", 23); + widget.set({ + }); +} + +function test_Drawer() { + var widget: tabris.Drawer = tabris.create("Drawer", {}); + widget.set("foo", 23); + widget.set({ + }); + var same: tabris.Drawer = widget.open(); + var same: tabris.Drawer = widget.close(); +} + +function test_ImageView() { + var widget: tabris.ImageView = tabris.create("ImageView", {}); + widget.set("foo", 23); + widget.set({ + image: {src: "http://example.com"}, + scaleMode: "auto" + }); +} + +function test_Page() { + var page: tabris.Page = tabris.create("Page", {}); + page.set("foo", 23); + page.set({ + image: {src: "http://example.com"}, + title: "foo", + topLevel: true + }); + page.open().close(); +} + +function test_PageSelector() { + var widget: tabris.PageSelector = tabris.create("PageSelector", {}); + widget.set("foo", 23); + widget.set({ + }); +} + +function test_Picker() { + var widget: tabris.Picker = tabris.create("Picker", {}); + widget.set("foo", 23); + widget.set({ + selection: "foo", + selectionIndex: 23, + items: ["foo", "bar", "baz"] + }); +} + +function test_ProgressBar() { + var widget: tabris.ProgressBar = tabris.create("ProgressBar", {}); + widget.set("foo", 23); + widget.set({ + minimum: 0, + maximum: 100, + selection: 23, + state: "normal" + }); +} + +function test_RadioButton() { + var widget: tabris.RadioButton = tabris.create("RadioButton", {}); + widget.set("foo", 23); + widget.set({ + selection: true, + text: "foo" + }); +} + +function test_ScrollView() { + var widget: tabris.ScrollView = tabris.create("ScrollView", {}); + widget.set("foo", 23); + widget.set({ + direction: "horizontal" + }); +} + +function test_SearchAction() { + var widget: tabris.SearchAction = tabris.create("SearchAction", {}); + widget.set("foo", 23); + widget.set({ + message: "foo", + proposals: ["foo", "bar", "baz"], + text: "foo" + }); +} + +function test_Slider() { + var widget: tabris.Slider = tabris.create("Slider", {}); + widget.set("foo", 23); + widget.set({ + minimum: 0, + maximum: 100, + selection: 23 + }); +} + +function test_Switch() { + var widget: tabris.Switch = tabris.create("Switch", {}); + widget.set("foo", 23); + widget.set({ + selection: true + }); +} + +function test_TextInput() { + var widget: tabris.TextInput = tabris.create("TextInput", {}); + widget.set("foo", 23); + widget.set({ + alignment: "center", + autoCapitalize: true, + autoCorrect: false, + editable: true, + text: "foo", + message: "bar", + type: "search", + keyboard: "ascii" + }); +} + +function test_Tab() { + var widget: tabris.Tab = tabris.create("Tab", {}); + widget.set("foo", 23); + widget.set({ + badge: "foo", + title: "bar", + image: {src: "http://example.org"} + }); +} + +function test_TabFolder() { + var widget: tabris.TabFolder = tabris.create("TabFolder", {}); + widget.set("foo", 23); + widget.set({ + paging: true, + tabBarLocation: "auto", + selection: tab1 + }); + var tab1: tabris.Tab, tab2: tabris.Tab; + var same: tabris.TabFolder = widget.append(tab1, tab2); +} + +function test_TextView() { + var widget: tabris.TextView = tabris.create("TextView", {}); + widget.set("foo", 23); + widget.set({ + alignment: "center", + markupEnabled: true, + maxLines: 23, + text: "foo" + }); +} + +function test_ToggleButton() { + var widget: tabris.ToggleButton = tabris.create("ToggleButton", {}); + widget.set("foo", 23); + widget.set({ + alignment: "center", + image: {src: "http://example.org/"}, + selection: true, + text: "foo" + }); +} + +function test_Video() { + var widget: tabris.Video = tabris.create("Video", {}); + widget.set("foo", 23); + widget.set({ + url: "http://example.org" + }); +} + +function test_WebView() { + var widget: tabris.WebView = tabris.create("WebView", {}); + widget.set("foo", 23); + widget.set({ + html: "", + url: "http://example.org" + }); +} + +function test_WidgetCollection() { + var collection: tabris.WidgetCollection = page.find(); + var length: number = collection.length; + var grandParents: tabris.WidgetCollection = collection.parent().parent(); + var grandChildren: tabris.WidgetCollection = collection.children().children(); + var found: tabris.WidgetCollection = collection.find().find(".class"); + collection.appendTo(page); + collection.dispose(); +} + +function test_tabris_app() { + tabris.app.installPatch("url", (error: Error, patch: Object) => {}); + tabris.app.reload(); +} + +function test_tabris_device() { + var lang: string = tabris.device.get("language"); + var model: string = tabris.device.get("model"); + var orient: string = tabris.device.get("orientation"); + var platform: string = tabris.device.get("platform"); + var factor: number = tabris.device.get("scaleFactor"); + var height: number = tabris.device.get("screenHeight"); + var width: number = tabris.device.get("screenWidth"); + var version: string = tabris.device.get("version"); + var same: tabris.Device = tabris.device.on("change:orientation", () => {}).off("change:orientation"); +} + +function test_tabris_ui() { + var page: tabris.Page = tabris.ui.get("activePage"); + var bg: string = tabris.ui.get("background"); + var tc: string = tabris.ui.get("textColor"); + var visible: boolean = tabris.ui.get("toolbarVisible"); + var same: tabris.UI = tabris.ui.on("change:activePage", () => {}).off("change:activePage"); +} diff --git a/tabris/tabris.d.ts b/tabris/tabris.d.ts new file mode 100644 index 0000000000..9a0b4defe7 --- /dev/null +++ b/tabris/tabris.d.ts @@ -0,0 +1,1446 @@ +// Type definitions for Tabris.js v1.2 +// Project: http://tabrisjs.com +// Definitions by: Tabris.js team +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module tabris { + + // Types + + interface Bounds { + + /** + * the horizontal offset from the parent's left edge in dip + */ + left: number; + + /** + * the vertical offset from the parent's top edge in dip + */ + top: number; + + /** + * the width of the widget in dip + */ + width: number; + + /** + * the height of the widget in dip + */ + height: number; + + } + + interface Transformation { + + /** + * Clock-wise rotation in radians. Defaults to `0`. + */ + rotation: number; + + /** + * Horizontal scale factor. Defaults to `1`. + */ + scaleX: number; + + /* + * Vertical scale factor. Defaults to `1`. + */ + scaleY: number; + + /** + * Horizontal translation (shift) in dip. Defaults to `0`. + */ + translationX: number; + + /** + * Vertical translation (shift) in dip. Defaults to `0`. + */ + translationY: number; + + } + + // TODO A plain string can be used as a shorthand, e.g. `"image.jpg"` equals `{src: "image.jpg"}`. + interface Image { + + /** + * Image path or URL. + */ + src?: string; + + /** + * Image width, extracted from the image file when missing. + */ + width?: number; + + /** + * Image height, extracted from the image file when missing. + */ + height?: number; + + /** + * Image scale factor - the image will be scaled down by this factor. + * Ignored when width or height are set. + */ + scale?: number; + + } + + interface CanvasContext { + // TODO + } + + // Events + + /** + * Event handling API supported by widgets and various other objects. + */ + interface EventSupport { + + /** + * Adds the *listener* to the list of functions to be notified when *event* is fired. + * In the listener function, `this` will point to the object itself. Supports chaining. + * + * @param event the name of the event to listen on + * @param listener the listener function + */ + on (event: string, listener: (target: T, ...args: any[]) => any): T; + + /** + * Same as `on`, but removes the listener after it has been invoked by an event. + * Supports chaining. + * + * @param event the name of the event to listen on + * @param listener the listener function + */ + once (event: string, listener: (target: T, ...args: any[]) => any): T; + + /** + * Removes all listeners for all events from this widget. Supports chaining. + */ + off (): T; + + /** + * Removes all listeners for *event* from this widget. Supports chaining. + * + * @param event the event name to remove listeners for + */ + off (event: string): T; + + /** + * Removes all occurrences of *listener* that are bound to *event* from this widget. + * Supports chaining. + * + * @param event the event to remove the listener from + * @param listener the listener function to remove + */ + off (event: string, listener: (target: T, ...args: any[]) => any): T; + + /** + * Triggers an event on this object. Supports chaining. + * + * @param event the name of the event to trigger + * @param args the arguments to pass to the listener functions + */ + trigger (event: string, ...args: any[]): T; + + } + + interface AnimationOptions { + + /** + * The time until the animation starts in ms, defaults to `0`. + */ + delay?: number; + + /** + * The duration in ms. + */ + duration: number; + + /** + * One of `linear`, `ease-in`, `ease-out`, `ease-in-out`. + */ + easing: string; + + /** + * The number of times to repeat the animation, defaults to `0`. + */ + repeat: number; + + /** + * `true` to alternate the direction of the animation on every repeat. + */ + reverse: boolean; + + /** + * No effect, but will be given in animation events. + */ + name: string; + + } + + // Widget + + function create (type: string, properties: WidgetProperties): Widget; + + /** + * API supported by all widgets. + */ + interface Widget extends EventSupport { + + // Property Support + + /** + * Gets the current value of the given *property*. + * + * @param property + */ + get (property: string): any; + + /** + * Sets the given property. Supports chaining. + * + * @param property the name of the property to set + * @param value the value to set the property to + * @param options passed to the change event resulting from this method call + */ + set (property: string, value: any, options?: Object): T; + + /** + * Sets all key-value pairs in the properties object as widget properties. Supports chaining. + * + * @param properties the properties to set + * @param options passed to the change event resulting from this method call + */ + set (properties: WidgetProperties, options?: Object): T; + + /** + * Starts an animation that transforms the given properties from their current values to the given ones. + * Supported properties are *transform* and *opacity*. + * + * @param properties The properties and target values to animate. + * @param options Configures the animation itself. + */ + animate (properties: WidgetProperties, options: AnimationOptions): void; + + /** + * Appends this widget to the given parent. + * The parent widget must support children (extending *Composite*). + * + * @param parent the parent widget to append this one to + */ + appendTo (parent: Composite): T; + + /** + * Applies the given properties to all descendants that match the associated selector(s). + * + * @param properties an object in the format + * `{selector: {property: value, property: value, ... }, selector: ...}` + */ + apply (properties: Object): T; + + /** + * Returns a (possibly empty) collection of all children of this widget. + */ + children (): WidgetCollection; + + /** + * Returns a (possibly empty) collection of all children of this widget that match the selector. + * + * @param selector a selector string to filter children + */ + children (selector: string): WidgetCollection; + + /** + * Removes this widget from its parent and destroys it. Also disposes of all its children. + * Triggers a `remove` event on the parent and a `dispose` event on itself. + * The widget can no longer be used. + */ + dispose (): void; + + /** + * Returns a (possibly empty) collection of all descendants of this widget. + */ + find (): WidgetCollection + + /** + * Returns a (possibly empty) collection of all descendants of this widget that match the selector. + * @param selector + */ + find (selector: string): WidgetCollection + + /** + * Returns `true` if the widget has been disposed, otherwise `false`. + */ + isDisposed (): boolean + + /** + * Returns the parent of this widget. + */ + parent (): T; + + /** + * An application-wide unique identifier automatically assigned to all widgets on creation. + * Do not change it. + */ + cid: string; + + /** + * Direct access to the value of the property of the same name. + * May be used instead of `widget.get("id");`. + * Do not use this field to change the value, instead use `widget.set("id", id);`. + */ + id: string; + + /** + * The exact string that was used to create this widget using the `tabris.create` method. + */ + type: string; + + } + + interface WidgetProperties { + + /** + * The background color of the widget. + */ + background?: string; + + /** + * An image to be displayed on the widget's background. + * If the image is smaller than the widget, it will be tiled. + */ + backgroundImage?: Image; + + /** + * The vertical position of the widget's baseline relative to a sibling widget. + */ + baseline?: any; + + /** + * The position of the widget's bottom edge relative to the parent or a sibling widget. + */ + bottom?: any; + + /** + * The actual location and size of the widget, relative to its parent. This property is read-only. + */ + bounds?: Bounds; + + /** + * The horizontal position of the widget's center relative to the parent's center. + */ + centerX?: number; + + /** + * The vertical position of the widget's center relative to the parent's center. + */ + centerY?: number; + + /** + * Whether the widget can be operated. + */ + enabled?: boolean; + + /** + * The font used for the widget. + */ + font?: string; + + /** + * The height of the widget. + */ + height?: number; + + /** + * Whether the entire widget should be highlighted while touched. + */ + highlightOnTouch?: boolean; + + /** + * A string to identify the widget by using selectors. Id's are optional. + * It is strongly recommended that they are unique within a page. + */ + id?: string; + + /** + * Shorthand for all layout properties. See [Layout](../layout.md). + */ + layoutData?: Object; + + /** + * The position of the widget's left edge relative to the parent or a sibling widget. + */ + left?: any; + + /** + * Opacity of the entire widget. Can be used for fade animations. + */ + opacity?: number; + + /** + * The position of the widget's right edge relative to the parent or a sibling widget. + */ + right?: any; + + /** + * Text color of the widget. + */ + textColor?: string; + + /** + * The position of the widget's top edge relative to the parent or a sibling widget. + */ + top?: any; + + /** + * Modifications to the widget's shape, size, or position. Can be used for animations. + * **Note:** In Android, the *transform* property does not affect the *bounds* property, + * while it does so in iOS. + */ + transform?: Transformation; + + /** + * Whether the widget is visible. + */ + visible?: boolean; + + /** + * The width of the widget. + */ + width?: number; + + } + + // Action + + function create (type: "Action", properties: ActionProperties): Action; + + /** + * An executable item that is integrated in the application's navigation menu. + * Add a listener on *select* to implement the action. + */ + interface Action extends Widget { + + set (property: string, value: any, options?: Object): Action; + set (properties: ActionProperties, options?: Object): Action; + + } + + interface ActionProperties extends WidgetProperties { + + /** + * Icon image for the action. + */ + image?: Image; + + /** + * Actions with higher placement priority will be placed at a more significant position in the UI, + * e.g. low priority actions could go into a menu instead of being included in a toolbar. + * Any of `low`, `high`, `normal`. + */ + placementPriority?: string; + + /** + * The text to be displayed for the action. + */ + title?: string; + + } + + // Button + + function create (type: "Button", properties: ButtonProperties): Button; + + /** + * A push button. Can contain a text or an image. + */ + interface Button extends Widget