From 69791d3db22c76d3d3a846998734c0fe1e2b3c21 Mon Sep 17 00:00:00 2001 From: huer12 Date: Wed, 8 Jan 2014 10:19:06 +0100 Subject: [PATCH 01/42] Basic version for https://github.com/ericmbarnard/KoGrid --- knockout.kogrid/ko-grid.d.ts | 191 +++++++++++++++++++++++++++++++++++ 1 file changed, 191 insertions(+) create mode 100644 knockout.kogrid/ko-grid.d.ts diff --git a/knockout.kogrid/ko-grid.d.ts b/knockout.kogrid/ko-grid.d.ts new file mode 100644 index 000000000..807eecdaf --- /dev/null +++ b/knockout.kogrid/ko-grid.d.ts @@ -0,0 +1,191 @@ +// Type definitions for ng-grid +// Project: http://knockout-contrib.github.io/KoGrid/ +// DefinitelyTyped: https://github.com/borisyankov/DefinitelyTyped + +// These are very definitely preliminary. Please feel free to improve. + + +declare module kg { + export interface DomUtilityService { + UpdateGridLayout(grid: Grid); + BuildStyles(grid: Grid); + } + + var domUtilityService; + + export interface Row { + selected: KnockoutObservable; + entity: EntityType; + } + + export interface RowFactory { + rowCache: Row[]; + } + + export interface SelectionService { + setSelection(row: Row, selected: boolean); + multi: boolean; + lastClickedRow: Row; + } + + export interface Grid { + configureColumnWidths(): void; + rowFactory: RowFactory; + config: GridOptions; + $$selectionPhase: boolean; + selectionService: SelectionService; + } + + export interface Plugin { + onGridInit(grid: Grid): void; + } + + export interface GridOptions { + /** Callback for when you want to validate something after selection. */ + afterSelectionChange?(row: Row); + + /** Callback if you want to inspect something before selection, + return false if you want to cancel the selection. return true otherwise. + If you need to wait for an async call to proceed with selection you can + use rowItem.changeSelection(event) method after returning false initially. + Note: when shift+ Selecting multiple items in the grid this will only get called + once and the rowItem will be an array of items that are queued to be selected. */ + beforeSelectionChange?: Function; + + /** definitions of columns as an array [], if not defined columns are auto-generated. See github wiki for more details. */ + columnDefs?: ColumnDef[]; + + /** Column width of columns in grid. */ + columnWidth?: number; + + /** Data being displayed in the grid. Each item in the array is mapped to a row being displayed. */ + data?: KnockoutObservableArray; + + /** Row selection check boxes appear as the first column. */ + displaySelectionCheckbox: boolean; + + /** Enable or disable resizing of columns */ + enableColumnResize?: boolean; + + /** Enables the server-side paging feature */ + enablePaging?: boolean; + + /** Enable column pinning */ + enablePinning?: boolean; + + /** Enable drag and drop row reordering. Only works in HTML5 compliant browsers. */ + enableRowReordering?: boolean; + + /** To be able to have selectable rows in grid. */ + enableRowSelection?: boolean; + + /** Enables or disables sorting in grid. */ + enableSorting?: boolean; + + /** filterOptions - + filterText: The text bound to the built-in search box. + useExternalFilter: Bypass internal filtering if you want to roll your own filtering mechanism but want to use builtin search box. + */ + filterOptions?: FilterOptions; + + /** Defining the height of the footer in pixels. */ + footerRowHeight?: number; + + /** Show or hide the footer alltogether the footer is enabled by default */ + footerVisible?: boolean; + + /** Initial fields to group data by. Array of field names, not displayName. */ + groups?: string[]; + + /** The height of the header row in pixels. */ + headerRowHeight?: number; + + /** Define a header row template for further customization. See github wiki for more details. */ + headerRowTemplate?: any; + + /** Enables the use of jquery UI reaggable/droppable plugin. requires jqueryUI to work if enabled. + Useful if you want drag + drop but your users insist on crappy browsers. */ + jqueryUIDraggable?: boolean; + + /** Enable the use jqueryUIThemes */ + jqueryUITheme?: boolean; + + /** Prevent unselections when in single selection mode. */ + keepLastSelected?: boolean; + + /** Maintains the column widths while resizing. + Defaults to true when using *'s or undefined widths. Can be ovverriden by setting to false. */ + maintainColumnRatios?: any; + + /** Set this to false if you only want one item selected at a time */ + multiSelect?: boolean; + + /** pagingOptions - */ + pagingOptions?: PagingOptions; + + /** Array of plugin functions to register in ng-grid */ + plugins?: Plugin[]; + + /** Row height of rows in grid. */ + rowHeight?: number; + + /** Define a row template to customize output. See github wiki for more details. */ + rowTemplate?: any; + + /** all of the items selected in the grid. In single select mode there will only be one item in the array. */ + selectedItems?: KnockoutObservableArray; + + /** Disable row selections by clicking on the row and only when the checkbox is clicked. */ + selectWithCheckboxOnly?: boolean; + + /** Enables menu to choose which columns to display and group by. + If both showColumnMenu and showFilter are false the menu button will not display.*/ + showColumnMenu?: boolean; + + /** Enables display of the filterbox in the column menu. + If both showColumnMenu and showFilter are false the menu button will not display.*/ + showFilter?: boolean; + + /** Show the dropzone for drag and drop grouping */ + showGroupPanel?: boolean; + + /** Define a sortInfo object to specify a default sorting state. + You can also observe this variable to utilize server-side sorting (see useExternalSorting). + Syntax is sortinfo: { fields: ['fieldName1',' fieldName2'], direction: 'ASC'/'asc' || 'desc'/'DESC'}*/ + sortInfo?: any; + + /** Set the tab index of the Vieport. */ + tabIndex?: number; + + /** Prevents the internal sorting from executing. + The sortInfo object will be updated with the sorting information so you can handle sorting (see sortInfo)*/ + useExternalSorting?: boolean; + } + + export interface ColumnDef { + /** The string name of the property in your data model you want that column to represent. Can also be a property path on your data model. 'foo.bar.myField', 'Name.First', etc.. */ + field: string; + + /** Sets the pretty display name of the column. default is the field given */ + displayName?: string; + + /** Sets the width of the column. Can be a fixed width in pixels as an int (42), string px('42px'), percentage string ('42%'), weighted asterisks (width divided by total number of *'s is all column definition widths) See github wiki for more details. */ + width?: string; + } + + export interface FilterOptions { + filterText?: string; + useExternalFilter?: boolean; + } + + export interface PagingOptions { + /** pageSizes: list of available page sizes. */ + pageSizes?: number[]; + /** pageSize: currently selected page size. */ + pageSize?: number; + /** totalServerItems: Total items are on the server. */ + totalServerItems?: number; + /** currentPage: the uhm... current page. */ + currentPage?: number; + } +} \ No newline at end of file From 2269608620de5d6c58b585ceba6e908130dce5d5 Mon Sep 17 00:00:00 2001 From: huer12 Date: Wed, 8 Jan 2014 11:43:30 +0100 Subject: [PATCH 02/42] Correct DomUtilityService definition --- knockout.kogrid/ko-grid.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/knockout.kogrid/ko-grid.d.ts b/knockout.kogrid/ko-grid.d.ts index 807eecdaf..01a7f7d17 100644 --- a/knockout.kogrid/ko-grid.d.ts +++ b/knockout.kogrid/ko-grid.d.ts @@ -6,12 +6,12 @@ declare module kg { - export interface DomUtilityService { - UpdateGridLayout(grid: Grid); - BuildStyles(grid: Grid); + export interface DomUtilityService { + UpdateGridLayout(grid: Grid); + BuildStyles(grid: Grid); } - var domUtilityService; + var domUtilityService: DomUtilityService; export interface Row { selected: KnockoutObservable; From e8b3b4c4cee3786bc71bd205c269f59110eac2f6 Mon Sep 17 00:00:00 2001 From: Dick van den Brink Date: Tue, 14 Jan 2014 22:19:02 +0100 Subject: [PATCH 03/42] Added JQueryMobilePath interface See http://api.jquerymobile.com/category/methods/path/ --- jquerymobile/jquerymobile.d.ts | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/jquerymobile/jquerymobile.d.ts b/jquerymobile/jquerymobile.d.ts index e7f92e8a2..dfc2a1de7 100644 --- a/jquerymobile/jquerymobile.d.ts +++ b/jquerymobile/jquerymobile.d.ts @@ -298,6 +298,30 @@ interface LoaderOptions { textonly?: boolean; } +interface JQueryMobilePath { + get(url: string): string; + getDocumentBase(asParsedObject?: boolean): any; + getDocumentUrl(asParsedObject?: boolean): any; + getLocation(): string; + isAbsoluteUrl(url: string): boolean; + isRelativeUrl(url: string): boolean; + makeUrlAbsolute(relUrl: string, absUrl: string): string; + parseLocation(): ParsedPath; + parseUrl(url): ParsedPath; +} + +interface ParsedPath { + hash: string; + host: string; + hostname: string; + href: string; + pathname: string; + port: string; + protocol: string; + search: string; +} + + interface JQueryMobile extends JQueryMobileOptions { version: string; @@ -321,7 +345,7 @@ interface JQueryMobile extends JQueryMobileOptions { touchOverflow: any; showCategory: any; - path: any; + path: JQueryMobilePath; dialog: any; popup: any; From 2f06bb165b10d96de3e224e4cfe4b43b84bfc934 Mon Sep 17 00:00:00 2001 From: Dick van den Brink Date: Tue, 14 Jan 2014 22:22:03 +0100 Subject: [PATCH 04/42] Added flipswitch widget. --- jquerymobile/jquerymobile.d.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/jquerymobile/jquerymobile.d.ts b/jquerymobile/jquerymobile.d.ts index dfc2a1de7..d73675d97 100644 --- a/jquerymobile/jquerymobile.d.ts +++ b/jquerymobile/jquerymobile.d.ts @@ -355,6 +355,7 @@ interface JQueryMobile extends JQueryMobileOptions { collapsibleset: any; textinput: any; slider: any; + flipswitch: any; checkboxradio: any; selectmenu: any; listview: any; @@ -411,6 +412,9 @@ interface JQuery { slider(options: SliderOptions): JQuery; slider(events: SliderEvents): JQuery; + flipswitch(): JQuery; + flipswitch(command: string): JQuery; + checkboxradio(): JQuery; checkboxradio(command: string): JQuery; checkboxradio(options: CheckboxRadioOptions): JQuery; From 7b2bc7f87214ecdd7994124d4a7c7871b1255925 Mon Sep 17 00:00:00 2001 From: Dick van den Brink Date: Tue, 14 Jan 2014 22:23:48 +0100 Subject: [PATCH 05/42] Bump to 1.4 Removed showPageLoadingMsg and hidePageLoadingMsg --- jquerymobile/jquerymobile.d.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/jquerymobile/jquerymobile.d.ts b/jquerymobile/jquerymobile.d.ts index d73675d97..a3a07f066 100644 --- a/jquerymobile/jquerymobile.d.ts +++ b/jquerymobile/jquerymobile.d.ts @@ -1,4 +1,4 @@ -// Type definitions for jQuery Mobile 1.2 +// Type definitions for jQuery Mobile 1.4 // Project: http://jquerymobile.com/ // Definitions by: Boris Yankov // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -338,8 +338,6 @@ interface JQueryMobile extends JQueryMobileOptions { options: JQueryMobileOptions; transitionFallbacks: any; - showPageLoadingMsg(): void; - hidePageLoadingMsg(): void; loader: any; page: any; From 4556398069496512dd8991ddaff8d768471d1d6f Mon Sep 17 00:00:00 2001 From: Dick van den Brink Date: Tue, 14 Jan 2014 22:28:29 +0100 Subject: [PATCH 06/42] Added new enhanceWithin() method. --- jquerymobile/jquerymobile.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/jquerymobile/jquerymobile.d.ts b/jquerymobile/jquerymobile.d.ts index a3a07f066..efb028b8f 100644 --- a/jquerymobile/jquerymobile.d.ts +++ b/jquerymobile/jquerymobile.d.ts @@ -366,6 +366,8 @@ interface JQuerySupport { interface JQuery { + enhanceWithin(): JQuery; + dialog(): JQuery; dialog(command: string): JQuery; dialog(options: DialogOptions): JQuery; From 1c695a17ee7f0f01a18d29090ffe06acb371eb89 Mon Sep 17 00:00:00 2001 From: Dick van den Brink Date: Tue, 14 Jan 2014 22:28:46 +0100 Subject: [PATCH 07/42] Added pagecontainer as a property. --- jquerymobile/jquerymobile.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/jquerymobile/jquerymobile.d.ts b/jquerymobile/jquerymobile.d.ts index efb028b8f..44dc78e62 100644 --- a/jquerymobile/jquerymobile.d.ts +++ b/jquerymobile/jquerymobile.d.ts @@ -331,6 +331,7 @@ interface JQueryMobile extends JQueryMobileOptions { loadPage(url: any, options?: LoadPageOptions): void; loading(command: string, options?: LoaderOptions): void; + pageContainer: any; base: any; silentScroll(yPos: number): void; activePage: JQuery; From 5b5846cbe46da6b64d5dce1a077307334d54bdd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20de=20Campredon?= Date: Wed, 15 Jan 2014 13:12:37 +0100 Subject: [PATCH 08/42] es6-promises defintion addition --- es6-promises/promises-tests.ts | 76 ++++++++++++++++++++++++ es6-promises/promises-tests.ts.tscparams | 1 + es6-promises/promises.d.ts | 39 ++++++++++++ 3 files changed, 116 insertions(+) create mode 100644 es6-promises/promises-tests.ts create mode 100644 es6-promises/promises-tests.ts.tscparams create mode 100644 es6-promises/promises.d.ts diff --git a/es6-promises/promises-tests.ts b/es6-promises/promises-tests.ts new file mode 100644 index 000000000..9f1e05dc2 --- /dev/null +++ b/es6-promises/promises-tests.ts @@ -0,0 +1,76 @@ +var promiseString: Promise, + promiseStringArr: Promise, + arrayOfPromise: Promise[], + promiseNumber: Promise, + promiseAny: Promise, + thenable: Thenable; + +// constructor test +var constructResult = new Promise((resolve, reject) => { + resolve('a string'); +}); +promiseString = constructResult; + + +var constructResult1 = new Promise((resolve:(promise: Thenable) => void , reject) => { + resolve(Promise.resolve('a string')); +}); +promiseString = constructResult1; + +//cast test +var castResult = Promise.cast('a string'); +promiseString = castResult; +var castResult1 = Promise.cast(Promise.resolve('a string')); +promiseString = castResult1; + +//resolve test +var resolveResult = Promise.resolve('a string'); +promiseString = resolveResult; + +var resolveResult1 = Promise.resolve(thenable); +promiseString = resolveResult1; + +//reject test +var rejectResult = Promise.reject('there is an error'); +promiseAny = rejectResult; + +//all test +var allResult = Promise.all(arrayOfPromise); +promiseStringArr = allResult; + +//race test +var raceResult = Promise.race(arrayOfPromise); +promiseString = raceResult; + + +//then test +var thenWithPromiseResult = promiseString.then(word => Promise.resolve(word.length)); +promiseNumber = thenWithPromiseResult; + +var thenWithPromiseResultAndVoidReject = promiseString.then(word => Promise.resolve(word.length), error => console.log(error)); +promiseNumber = thenWithPromiseResultAndVoidReject; + +var thenWithPromiseResultAndPromiseReject = promiseString.then(word => Promise.resolve(word.length), error => Promise.resolve(10)); +promiseNumber = thenWithPromiseResultAndPromiseReject; + +var thenWithPromiseResultAndSimpleReject = promiseString.then(word => Promise.resolve(word.length), error => 10); +promiseNumber = thenWithPromiseResultAndSimpleReject; + +var thenWithSimpleResult = promiseString.then(word => word.length); +promiseNumber = thenWithSimpleResult; + +var thenWithSimpleResultAndVoidReject = promiseString.then(word => word.length, error => console.log(error)); +promiseNumber = thenWithSimpleResultAndVoidReject; + +var thenWithSimpleResultAndPromiseReject = promiseString.then(word => word.length, error => Promise.resolve(10)); +promiseNumber = thenWithSimpleResultAndPromiseReject; + +var thenWithSimpleResultAndSimpleReject = promiseString.then(word => word.length, error => 10); +promiseNumber = thenWithSimpleResultAndSimpleReject; + +//catch test +var catchWithSimpleResult = promiseString.catch(error => 10); +promiseNumber = catchWithSimpleResult; + +var catchWithPromiseResult = promiseString.catch(error => Promise.resolve(10)); +promiseNumber = catchWithPromiseResult; diff --git a/es6-promises/promises-tests.ts.tscparams b/es6-promises/promises-tests.ts.tscparams new file mode 100644 index 000000000..3cc762b55 --- /dev/null +++ b/es6-promises/promises-tests.ts.tscparams @@ -0,0 +1 @@ +"" \ No newline at end of file diff --git a/es6-promises/promises.d.ts b/es6-promises/promises.d.ts new file mode 100644 index 000000000..c24844e6f --- /dev/null +++ b/es6-promises/promises.d.ts @@ -0,0 +1,39 @@ +interface Thenable { + then(onFulfill: (value: R) => Thenable, onReject?: (error: any) => void): Thenable; + then(onFulfill: (value: R) => U, onReject?: (error: any) => void): Thenable; + then(onFulfill: (value: R) => Thenable, onReject?: (error: any) => Thenable): Thenable; + then(onFulfill: (value: R) => Thenable, onReject?: (error: any) => U): Thenable; + then(onFulfill: (value: R) => U, onReject?: (error: any) => Thenable): Thenable; + then(onFulfill: (value: R) => U, onReject?: (error: any) => U): Thenable; +} + +declare class Promise implements Thenable { + constructor(callback: (resolve : (result: R) => void, reject: (error: any) => void) => void); + constructor(callback: (resolve : (result: Thenable) => void, reject: (error: any) => void) => void); + + then(onFulfill: (value: R) => Thenable, onReject?: (error: any) => void): Promise; + then(onFulfill: (value: R) => U, onReject?: (error: any) => void): Promise; + then(onFulfill: (value: R) => Thenable, onReject?: (error: any) => Thenable): Promise; + then(onFulfill: (value: R) => Thenable, onReject?: (error: any) => U): Promise; + then(onFulfill: (value: R) => U, onReject?: (error: any) => Thenable): Promise; + then(onFulfill: (value: R) => U, onReject?: (error: any) => U): Promise; + + catch(onReject?: (error: any) => Thenable): Promise + catch(onReject?: (error: any) => U): Promise +} + +declare module Promise { + + + function cast(promise: Promise): Promise; + function cast(object: R): Promise; + + function resolve(thenable: Thenable): Promise; + function resolve(object: R): Promise; + + function reject(error: any): Promise; + + function all(promises: Promise[]): Promise; + + function race(promises: Promise[]): Promise; +} \ No newline at end of file From 3a45c9d8be31da33f6f449c75c9c8fbfec4991c9 Mon Sep 17 00:00:00 2001 From: John Reilly Date: Wed, 15 Jan 2014 13:26:08 +0000 Subject: [PATCH 09/42] jQuery: Add jQuery/$ JSDoc And test suite --- jquery/jquery-tests.ts | 96 ++++++++++++++++++++++++++++++++++++++++++ jquery/jquery.d.ts | 64 ++++++++++++++++++++++++++-- 2 files changed, 156 insertions(+), 4 deletions(-) diff --git a/jquery/jquery-tests.ts b/jquery/jquery-tests.ts index a6cb92ee0..518e8a45d 100644 --- a/jquery/jquery-tests.ts +++ b/jquery/jquery-tests.ts @@ -2103,6 +2103,102 @@ function test_jquery() { alert(' b is a jQuery object! '); } alert('You are running jQuery version: ' + $.fn.jquery); + + $("div.foo"); + + $("div.foo").click(function () { + $("span", this).addClass("bar"); + }); + + $("div.foo").click(function () { + $(this).slideUp(); + }); + + $.post("url.xml", function (data) { + var $child = $(data).find("child"); + }); + + // Define a plain object + var foo = { foo: "bar", hello: "world" }; + + // Pass it to the jQuery function + var $foo = $(foo); + + // Test accessing property values + var test1 = $foo.prop("foo"); // bar + + // Test setting property values + $foo.prop("foo", "foobar"); + var test2 = $foo.prop("foo"); // foobar + + // Test using .data() as summarized above + $foo.data("keyName", "someValue"); + console.log($foo); // will now contain a jQuery{randomNumber} property + + // Test binding an event name and triggering + $foo.on("eventName", function () { + console.log("eventName was called"); + }); + + $foo.trigger("eventName"); // Logs "eventName was called" + + $foo.triggerHandler("eventName"); // Also logs "eventName was called" + + $("div > p").css("border", "1px solid gray"); + + $("input:radio", document.forms[0]); + + $(document.body).css("background", "black"); + + var myForm: HTMLFormElement; + $(myForm.elements).hide(); + + $("

My new text

").appendTo("body"); + + $(""); + + $(""); + $(""); + + var el = $("1
2
3"); // returns [
, "2",
] + el = $("1
2
3 >"); // returns [
, "2",
, "3 >"] + + $("
", { + "class": "my-div", + on: { + touchstart: function (event) { + // Do something + } + } + }).appendTo("body"); + + $("
") + .addClass("my-div") + .on({ + touchstart: function (event) { + // Do something + } + }) + .appendTo("body"); + + $("

Hello

").appendTo("body") + + $("
", { + "class": "test", + text: "Click me!", + click: function () { + $(this).toggleClass("test"); + } + }) + .appendTo("body"); + + $(function () { + // Document is ready + }); + + jQuery(function ($) { + // Your code using failsafe $ alias here... + }); } function test_keydown() { diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index 7d1ad992b..1dab9e790 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -553,15 +553,71 @@ interface JQueryStatic { */ holdReady(hold: boolean): void; - (selector: string, context?: any): JQuery; + /** + * Accepts a string containing a CSS selector which is then used to match a set of elements. + * + * @param selector A string containing a selector expression + * @param context A DOM Element, Document, or jQuery to use as context + */ + (selector: string, context?: Element): JQuery; + /** + * Accepts a string containing a CSS selector which is then used to match a set of elements. + * + * @param selector A string containing a selector expression + * @param context A DOM Element, Document, or jQuery to use as context + */ + (selector: string, context?: JQuery): JQuery; + /** + * Accepts a string containing a CSS selector which is then used to match a set of elements. + * + * @param element A DOM element to wrap in a jQuery object. + */ (element: Element): JQuery; - (object: {}): JQuery; + /** + * Accepts a string containing a CSS selector which is then used to match a set of elements. + * + * @param elementArray An array containing a set of DOM elements to wrap in a jQuery object. + */ (elementArray: Element[]): JQuery; + /** + * Accepts a string containing a CSS selector which is then used to match a set of elements. + * + * @param object A plain object to wrap in a jQuery object. + */ + (object: {}): JQuery; + /** + * Accepts a string containing a CSS selector which is then used to match a set of elements. + * + * @param object An existing jQuery object to clone. + */ (object: JQuery): JQuery; - (func: Function): JQuery; - (array: any[]): JQuery; + /** + * Specify a function to execute when the DOM is fully loaded. + */ (): JQuery; + /** + * Creates DOM elements on the fly from the provided string of raw HTML. + * + * @param html A string of HTML to create on the fly. Note that this parses HTML, not XML. + * @param ownerDocument A document in which the new elements will be created. + */ + (html: string, ownerDocument?: Document): JQuery; + /** + * Creates DOM elements on the fly from the provided string of raw HTML. + * + * @param html A string defining a single, standalone, HTML element (e.g.
or
). + * @param attributes An object of attributes, events, and methods to call on the newly-created element. + */ + (html: string, attributes: Object): JQuery; + + /** + * Binds a function to be executed when the DOM has finished loading. + * + * @param callback A function to execute after the DOM is ready. + */ + (callback: Function): JQuery; + /** * Relinquish jQuery's control of the $ variable. * From 2625222bb4adc940fe36f35c26f984173da0e5a4 Mon Sep 17 00:00:00 2001 From: Dick van den Brink Date: Wed, 15 Jan 2014 15:48:56 +0100 Subject: [PATCH 10/42] Fixed loading method Added empty loading method + return a JQuery object instead of void --- jquerymobile/jquerymobile.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/jquerymobile/jquerymobile.d.ts b/jquerymobile/jquerymobile.d.ts index 44dc78e62..48c6459e1 100644 --- a/jquerymobile/jquerymobile.d.ts +++ b/jquerymobile/jquerymobile.d.ts @@ -329,7 +329,8 @@ interface JQueryMobile extends JQueryMobileOptions { changePage(to: any, options?: ChangePageOptions): void; initializePage(): void; loadPage(url: any, options?: LoadPageOptions): void; - loading(command: string, options?: LoaderOptions): void; + loading(): JQuery; + loading(command: string, options?: LoaderOptions): JQuery; pageContainer: any; base: any; From 4887a99db3909a6a53348831cb551007d8dcaee2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20de=20Campredon?= Date: Wed, 15 Jan 2014 16:58:14 +0100 Subject: [PATCH 11/42] Renaming to respect conventions, add Readme --- README.md | 1 + ...romises-tests.ts => es6-promises-tests.ts} | 2 + ...params => es6-promises-tests.ts.tscparams} | 0 es6-promises/es6-promises.d.ts | 95 +++++++++++++++++++ es6-promises/promises.d.ts | 39 -------- 5 files changed, 98 insertions(+), 39 deletions(-) rename es6-promises/{promises-tests.ts => es6-promises-tests.ts} (98%) rename es6-promises/{promises-tests.ts.tscparams => es6-promises-tests.ts.tscparams} (100%) create mode 100644 es6-promises/es6-promises.d.ts delete mode 100644 es6-promises/promises.d.ts diff --git a/README.md b/README.md index 27d6be4e4..d97c6c2d0 100755 --- a/README.md +++ b/README.md @@ -64,6 +64,7 @@ List of Definitions * [EaselJS](http://www.createjs.com/#!/EaselJS) (by [Pedro Ferreira](https://bitbucket.org/drk4)) * [ember.js](http://emberjs.com/) (by [Boris Yankov](https://github.com/borisyankov)) * [EpicEditor](http://epiceditor.com/) (by [Boris Yankov](https://github.com/borisyankov)) +* [ES6-Promises](https://github.com/jakearchibald/ES6-Promises) (by [François de Campredon](https://github.com/fdecampredon/)) * [expect.js](https://github.com/LearnBoost/expect.js) (by [Teppei Sato](https://github.com/teppeis)) * [expectations](https://github.com/spmason/expectations) (by [vvakame](https://github.com/vvakame)) * [Express](http://expressjs.com/) (by [Boris Yankov](https://github.com/borisyankov)) diff --git a/es6-promises/promises-tests.ts b/es6-promises/es6-promises-tests.ts similarity index 98% rename from es6-promises/promises-tests.ts rename to es6-promises/es6-promises-tests.ts index 9f1e05dc2..fd1160572 100644 --- a/es6-promises/promises-tests.ts +++ b/es6-promises/es6-promises-tests.ts @@ -1,3 +1,5 @@ +/// + var promiseString: Promise, promiseStringArr: Promise, arrayOfPromise: Promise[], diff --git a/es6-promises/promises-tests.ts.tscparams b/es6-promises/es6-promises-tests.ts.tscparams similarity index 100% rename from es6-promises/promises-tests.ts.tscparams rename to es6-promises/es6-promises-tests.ts.tscparams diff --git a/es6-promises/es6-promises.d.ts b/es6-promises/es6-promises.d.ts new file mode 100644 index 000000000..fc013817d --- /dev/null +++ b/es6-promises/es6-promises.d.ts @@ -0,0 +1,95 @@ +// Type definitions for es6-promises +// Project: https://github.com/jakearchibald/ES6-Promises +// Definitions by: François de Campredon +// Definitions: https://github.com/borisyankov/DefinitelyTyped + + +interface Thenable { + then(onFulfill: (value: R) => Thenable, onReject?: (error: any) => void): Thenable; + then(onFulfill: (value: R) => U, onReject?: (error: any) => void): Thenable; + then(onFulfill: (value: R) => Thenable, onReject?: (error: any) => Thenable): Thenable; + then(onFulfill: (value: R) => Thenable, onReject?: (error: any) => U): Thenable; + then(onFulfill: (value: R) => U, onReject?: (error: any) => Thenable): Thenable; + then(onFulfill: (value: R) => U, onReject?: (error: any) => U): Thenable; +} + +declare class Promise implements Thenable { + /** + * @param resolve Your promise is fulfilled with obj + * @rejectYour promise is rejected with obj. For consistency and debugging (eg stack traces), obj should be an instanceof Error. Any errors thrown in the constructor callback will be implicitly passed to reject(). + */ + constructor(callback: (resolve : (result: R) => void, reject: (error: any) => void) => void); + /** + * @param resolve Your promise will be fulfilled/rejected with the outcome of thenable reject(obj) + * @rejectYour promise is rejected with obj. For consistency and debugging (eg stack traces), obj should be an instanceof Error. Any errors thrown in the constructor callback will be implicitly passed to reject(). + */ + constructor(callback: (resolve : (result: Thenable) => void, reject: (error: any) => void) => void); + + + /** + * onFullFill is called when/if "promise" resolves. onRejected is called when/if "promise" rejects. + * Both are optional, if either/both are omitted the next onFulfilled/onRejected in the chain is called. + * Both callbacks have a single parameter , the fulfillment value or rejection reason. + * "then" returns a new promise equivalent to the value you return from onFulfilled/onRejected after being passed through Promise.resolve. + * If an error is thrown in the callback, the returned promise rejects with that error. + * + * @param onFullFill called when/if "promise" resolves + * @param onReject called when/if "promise" rejects + */ + then(onFulfill: (value: R) => Thenable, onReject?: (error: any) => void): Promise; + then(onFulfill: (value: R) => U, onReject?: (error: any) => void): Promise; + then(onFulfill: (value: R) => Thenable, onReject?: (error: any) => Thenable): Promise; + then(onFulfill: (value: R) => Thenable, onReject?: (error: any) => U): Promise; + then(onFulfill: (value: R) => U, onReject?: (error: any) => Thenable): Promise; + then(onFulfill: (value: R) => U, onReject?: (error: any) => U): Promise; + + + /** + * Sugar for promise.then(undefined, onRejected) + * + * @param onReject called when/if "promise" rejects + */ + catch(onReject?: (error: any) => Thenable): Promise + catch(onReject?: (error: any) => U): Promise +} + +declare module Promise { + + /** + * Returns promise (only if promise.constructor == Promise) + */ + function cast(promise: Promise): Promise; + /** + * Make a promise that fulfills to obj. + */ + function cast(object: R): Promise; + + + /** + * Make a new promise from the thenable. + * A thenable is promise-like in as far as it has a "then" method. + * This also creates a new promise if you pass it a genuine JavaScript promise, making it less efficient for casting than Promise.cast. + */ + function resolve(thenable: Thenable): Promise; + /** + * Make a promise that fulfills to obj. Same as Promise.cast(obj) in this situation. + */ + function resolve(object: R): Promise; + + /** + * Make a promise that rejects to obj. For consistency and debugging (eg stack traces), obj should be an instanceof Error + */ + function reject(error: any): Promise; + + /** + * Make a promise that fulfills when every item in the array fulfills, and rejects if (and when) any item rejects. + * Eadd array item is passed to Promise.cast, so the array can be a mixture of promise-like objects and other objects. + * The fulfillment value is an array (in order) of fulfillment values. The rejection value is the first rejection value. + */ + function all(promises: Promise[]): Promise; + + /** + * Make a Promise that fulfills when any item fulfills, and rejects if any item rejects. + */ + function race(promises: Promise[]): Promise; +} \ No newline at end of file diff --git a/es6-promises/promises.d.ts b/es6-promises/promises.d.ts deleted file mode 100644 index c24844e6f..000000000 --- a/es6-promises/promises.d.ts +++ /dev/null @@ -1,39 +0,0 @@ -interface Thenable { - then(onFulfill: (value: R) => Thenable, onReject?: (error: any) => void): Thenable; - then(onFulfill: (value: R) => U, onReject?: (error: any) => void): Thenable; - then(onFulfill: (value: R) => Thenable, onReject?: (error: any) => Thenable): Thenable; - then(onFulfill: (value: R) => Thenable, onReject?: (error: any) => U): Thenable; - then(onFulfill: (value: R) => U, onReject?: (error: any) => Thenable): Thenable; - then(onFulfill: (value: R) => U, onReject?: (error: any) => U): Thenable; -} - -declare class Promise implements Thenable { - constructor(callback: (resolve : (result: R) => void, reject: (error: any) => void) => void); - constructor(callback: (resolve : (result: Thenable) => void, reject: (error: any) => void) => void); - - then(onFulfill: (value: R) => Thenable, onReject?: (error: any) => void): Promise; - then(onFulfill: (value: R) => U, onReject?: (error: any) => void): Promise; - then(onFulfill: (value: R) => Thenable, onReject?: (error: any) => Thenable): Promise; - then(onFulfill: (value: R) => Thenable, onReject?: (error: any) => U): Promise; - then(onFulfill: (value: R) => U, onReject?: (error: any) => Thenable): Promise; - then(onFulfill: (value: R) => U, onReject?: (error: any) => U): Promise; - - catch(onReject?: (error: any) => Thenable): Promise - catch(onReject?: (error: any) => U): Promise -} - -declare module Promise { - - - function cast(promise: Promise): Promise; - function cast(object: R): Promise; - - function resolve(thenable: Thenable): Promise; - function resolve(object: R): Promise; - - function reject(error: any): Promise; - - function all(promises: Promise[]): Promise; - - function race(promises: Promise[]): Promise; -} \ No newline at end of file From 4c956bc8d52a7f879077f2ebbfd451d8fa41dea0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20de=20Campredon?= Date: Wed, 15 Jan 2014 18:09:00 +0100 Subject: [PATCH 12/42] correct references in test --- es6-promises/es6-promises-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/es6-promises/es6-promises-tests.ts b/es6-promises/es6-promises-tests.ts index fd1160572..5a8b81a35 100644 --- a/es6-promises/es6-promises-tests.ts +++ b/es6-promises/es6-promises-tests.ts @@ -1,4 +1,4 @@ -/// +/// var promiseString: Promise, promiseStringArr: Promise, From 62644f420e2f94221d666e8ea555e0e379dcf1c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20de=20Campredon?= Date: Wed, 15 Jan 2014 18:11:12 +0100 Subject: [PATCH 13/42] add blank line --- es6-promises/es6-promises.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/es6-promises/es6-promises.d.ts b/es6-promises/es6-promises.d.ts index fc013817d..766fe3fbc 100644 --- a/es6-promises/es6-promises.d.ts +++ b/es6-promises/es6-promises.d.ts @@ -92,4 +92,4 @@ declare module Promise { * Make a Promise that fulfills when any item fulfills, and rejects if any item rejects. */ function race(promises: Promise[]): Promise; -} \ No newline at end of file +} From 5b515967e73856eac1f153d0b96bc656774e9c0e Mon Sep 17 00:00:00 2001 From: huer12 Date: Wed, 15 Jan 2014 20:57:14 +0100 Subject: [PATCH 14/42] Fix build errors and add a test --- knockout.kogrid/knockout.kogrid-tests.ts | 34 ++++++++++++++++++++++++ knockout.kogrid/ko-grid.d.ts | 9 ++++--- 2 files changed, 39 insertions(+), 4 deletions(-) create mode 100644 knockout.kogrid/knockout.kogrid-tests.ts diff --git a/knockout.kogrid/knockout.kogrid-tests.ts b/knockout.kogrid/knockout.kogrid-tests.ts new file mode 100644 index 000000000..94c061156 --- /dev/null +++ b/knockout.kogrid/knockout.kogrid-tests.ts @@ -0,0 +1,34 @@ +/// +/// + +module KoGridTests +{ + export interface IGridItem { + name: string; + } + + export class Tests { + public items: KnockoutObservableArray; + public selectedItems: KnockoutObservableArray; + public gridOptionsAlarms: kg.GridOptions; + + constructor() { + this.items = ko.observableArray(); + this.selectedItems = ko.observableArray(); + this.gridOptionsAlarms = this.createDefaultGridOptions(this.items, this.selectedItems); + } + + public createDefaultGridOptions(dataArray: KnockoutObservableArray, selectedItems: KnockoutObservableArray): kg.GridOptions { + var result = { + data: dataArray, + displaySelectionCheckbox: false, + footerVisible: false, + multiSelect: false, + showColumnMenu: false, + plugins: null, + selectedItems: selectedItems + }; + return result; + } + } +} \ No newline at end of file diff --git a/knockout.kogrid/ko-grid.d.ts b/knockout.kogrid/ko-grid.d.ts index 01a7f7d17..f07401806 100644 --- a/knockout.kogrid/ko-grid.d.ts +++ b/knockout.kogrid/ko-grid.d.ts @@ -4,11 +4,12 @@ // These are very definitely preliminary. Please feel free to improve. +/// declare module kg { export interface DomUtilityService { - UpdateGridLayout(grid: Grid); - BuildStyles(grid: Grid); + UpdateGridLayout(grid: Grid): void; + BuildStyles(grid: Grid): void; } var domUtilityService: DomUtilityService; @@ -23,7 +24,7 @@ declare module kg { } export interface SelectionService { - setSelection(row: Row, selected: boolean); + setSelection(row: Row, selected: boolean): void; multi: boolean; lastClickedRow: Row; } @@ -42,7 +43,7 @@ declare module kg { export interface GridOptions { /** Callback for when you want to validate something after selection. */ - afterSelectionChange?(row: Row); + afterSelectionChange?(row: Row): void; /** Callback if you want to inspect something before selection, return false if you want to cancel the selection. return true otherwise. From cbd40a2bf8ddaa42a05d1810356248477e1b4f0f Mon Sep 17 00:00:00 2001 From: huer12 Date: Wed, 15 Jan 2014 21:43:20 +0100 Subject: [PATCH 15/42] Changed a comment --- knockout.kogrid/ko-grid.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/knockout.kogrid/ko-grid.d.ts b/knockout.kogrid/ko-grid.d.ts index f07401806..c8d1b27c1 100644 --- a/knockout.kogrid/ko-grid.d.ts +++ b/knockout.kogrid/ko-grid.d.ts @@ -1,4 +1,4 @@ -// Type definitions for ng-grid +// Type definitions for ko-grid // Project: http://knockout-contrib.github.io/KoGrid/ // DefinitelyTyped: https://github.com/borisyankov/DefinitelyTyped From 09776db7ff3337f077cb8749e5d53d609870ff76 Mon Sep 17 00:00:00 2001 From: Horiuchi_H Date: Thu, 16 Jan 2014 12:37:59 +0900 Subject: [PATCH 16/42] add get quater method --- moment/moment-tests.ts | 1 + moment/moment.d.ts | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/moment/moment-tests.ts b/moment/moment-tests.ts index 5150f7ebc..e86989eed 100644 --- a/moment/moment-tests.ts +++ b/moment/moment-tests.ts @@ -102,6 +102,7 @@ var getHours: number = moment().hours(); var getDate: number = moment().date(); var getDay: number = moment().day(); var getMonth: number = moment().month(); +var getQuater: number = moment().quarter(); var getYear: number = moment().year(); moment().hours(0).minutes(0).seconds(0).milliseconds(0); diff --git a/moment/moment.d.ts b/moment/moment.d.ts index a920b57ac..20e921c32 100644 --- a/moment/moment.d.ts +++ b/moment/moment.d.ts @@ -1,7 +1,8 @@ -// Type definitions for Moment.js 2.4.0 +// Type definitions for Moment.js 2.5.0 // Project: https://github.com/timrwood/moment // Definitions by: Michael Lakerveld // 2.4.0 Aaron King +// 2.5.0 Hiroki Horiuchi // DefinitelyTyped: https://github.com/borisyankov/DefinitelyTyped @@ -81,6 +82,7 @@ interface Moment { year(y: number): Moment; year(): number; + quarter(): number; month(M: number): Moment; month(M: string): Moment; month(): number; From 4e94454e2e72819c76492f41dc3c91da465d9abb Mon Sep 17 00:00:00 2001 From: Bartvds Date: Thu, 16 Jan 2014 05:26:56 +0100 Subject: [PATCH 17/42] fixed header search/replace mistake --- lazy.js/lazy.js.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lazy.js/lazy.js.d.ts b/lazy.js/lazy.js.d.ts index 650ffd079..baba46a46 100644 --- a/lazy.js/lazy.js.d.ts +++ b/lazy.js/lazy.js.d.ts @@ -1,4 +1,4 @@ -// Type definitions for js 0.3.2 +// Type definitions for Lazy.js 0.3.2 // Project: https://github.com/dtao/lazy.js/ // Definitions by: Bart van der Schoor // Definitions: https://github.com/borisyankov/DefinitelyTyped From 663fce523244ed3ce561711e66088d099e35c0be Mon Sep 17 00:00:00 2001 From: Bartvds Date: Thu, 16 Jan 2014 05:37:32 +0100 Subject: [PATCH 18/42] Created definitions for js-git https://github.com/creationix/js-git few remaining problems: * overloading read/write git-object types * typing of streams * typing of options --- README.md | 1 + js-git/js-git-test.ts | 67 +++++++++++++++ js-git/js-git.d.ts | 188 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 256 insertions(+) create mode 100644 js-git/js-git-test.ts create mode 100644 js-git/js-git.d.ts diff --git a/README.md b/README.md index 8760adc87..5e61b1b94 100755 --- a/README.md +++ b/README.md @@ -149,6 +149,7 @@ List of Definitions * [jQuery.Validation](http://bassistance.de/jquery-plugins/jquery-plugin-validation/) (by [Boris Yankov](https://github.com/borisyankov)) * [jQuery.Watermark](http://jquery-watermark.googlecode.com) (by [Anwar Javed](https://github.com/anwarjaved)) * [jQuery.base64](https://github.com/yatt/jquery.base64) (by [Shinya Mochizuki](https://github.com/enrapt-mochizuki)) +* [js-git](https://github.com/creationix/js-git) (by [Bart van der Schoor](https://github.com/Bartvds)) * [jScrollPane](http://jscrollpane.kelvinluck.com) (by [Dániel Tar](https://github.com/qcz)) * [JSDeferred](http://cho45.stfuawsc.com/jsdeferred/) (by [Daisuke Mino](https://github.com/minodisk)) * [JSONEditorOnline](https://github.com/josdejong/jsoneditoronline) (by [Vincent Bortone](https://github.com/vbortone/)) diff --git a/js-git/js-git-test.ts b/js-git/js-git-test.ts new file mode 100644 index 000000000..2df372df3 --- /dev/null +++ b/js-git/js-git-test.ts @@ -0,0 +1,67 @@ +/// + +var obj:Object; +var bool:boolean; +var num:number; +var str:string; +var x:any = null; +var arr:any[]; +var exp:RegExp; +var strArr:string[]; +var numArr:string[]; + +var readable:any; +var git_object:JSGit.GitObject; +var commit:JSGit.GitCommit; +var author:JSGit.GitAuthor; +var tree:JSGit.GitTree; + +var elem:JSGit.GitTreeElem; +var map:JSGit.StringMap; +var remote:JSGit.Remote; + +var db:JSGit.DB; + +db.get(str, (err:any, value:any) => {}); +db.set(str, x, (err:any) => {}); + +db.has(str, (err:any, hasKey:boolean) => {}); + +db.del(str, (err:any) => {}); + +db.keys(str, (err:any, str:string[]) => {}); + +db.init((err:any) => {}); + +db.clear((err:any) => {}); + + +var repo:JSGit.Repo; + +repo.load(str, (err:any, git_object:JSGit.GitObject) => {}); + +repo.save(git_object, (err:any, str:string) => {}); + +repo.loadAs(str, str, (err:any, body:any) => {}); + +repo.saveAs(str, x, (err:any, str:string) => {}); + +repo.remove(str, (err:any) => {}); + +repo.unpack(x, obj, (err:any) => {}); + +repo.logWalk(str, (err:any, log_stream:any) => {}); + +repo.treeWalk(str, (err:any, file_stream:any) => {}); + +repo.walk(x, x, x, x); + +repo.resolveHashish(str, (err:any, str:string) => {}); + +repo.updateHead(str, (err:any) => {}); + +repo.getHead((err:any, str:string) => {}); + +repo.setHead(str, (err:any) => {}); + +repo.fetch(remote, obj, (err:any) => {}); diff --git a/js-git/js-git.d.ts b/js-git/js-git.d.ts new file mode 100644 index 000000000..b85cafbca --- /dev/null +++ b/js-git/js-git.d.ts @@ -0,0 +1,188 @@ +// Type definitions for js-git 0.5.2 +// Project: https://github.com/creationix/js-git +// Definitions by: Bart van der Schoor +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module JSGit { + + interface GitObject { + type:string; + body:any; + } + + interface GitCommit { + tree:string; + author:GitAuthor; + message:string; + } + + interface GitAuthor { + name:string; + email:string; + date:Date; + } + + interface GitTree { + [i:number]:GitTreeElem; + } + + interface GitTreeElem { + mode:number; + name:string; + hash:string; + } + + interface StringMap { + [i:string]:string; + } + + interface Remote { + hostname:string; + pathname:string; + + discover(callback:(err:any, refs:StringMap) => void); + fetch(repo:Repo, opts:Object, callback:(err:any) => void); + close(callback?:(err:any) => void); + } + + interface DB { + /** + * Load a ref or object from the database. + * The database should assume that keys that are 40-character long hex strings are sha1 hashes. The value for these will always be binary (Buffer in node, Uint8Array in browser) All other keys are paths like refs/heads/master or HEAD and the value is a string. + */ + get(key:string, callback:(err:any, value:any) => void):void; + + /** + * Save a value to the database. Same rules apply about hash keys being binary values and other keys being string values. + */ + set(key:string, value:any, callback:(err:any) => void):void; + + /** + * Check if a key is in the database + */ + has(key:string, callback:(err:any, hasKey:boolean) => void):void; + + /** + * Remove an object or ref from the database. + */ + del(key:string, callback:(err:any) => void):void; + + /** + * Given a path prefix, give all the keys. This is like a readdir if you treat the keys as paths. + * For example, given the keys refs/heads/master, refs/heads/experimental, refs/tags/0.1.3 and the prefix refs/heads/, the output would be master and experimental. + * A null prefix returns all non hash keys. + */ + keys(prefix:string, callback:(err:any, keys:string[]) => void):void; + + /** + * Initialize a database. This is where you db implementation can setup stuff. + */ + init(callback:(err:any) => void):void; + + /** + * This is for when the user wants to delete or otherwise reclaim your database's resources. + */ + clear(callback:(err:any) => void):void; + } + + interface Repo { + /** + * Load a git object from the database. You can pass in either a hash or a symbolic name like HEAD or refs/tags/v3.1.4. + * + * The object will be of the form: + * { + * type: "commit", // Or "tag", "tree", or "blob" + * body: { ... } // Or an array for tree and a binary value for blob. + * } + */ + load(hashish:string, callback:(err:any, git_object:GitObject) => void):void; + + /** + * Save an object to the database. This will give you back the hash of the cotent by which you can retrieve the value back. + */ + save(git_object:GitObject, callback:(err:any, hash:string) => void):void; + + /** + * This convenience wrapper will call repo.load for you and then check if the type is what you expected. If it is, it will return the body directly. If it's not, it will error. + * + * var commit = yield repo.loadAs("commit", "HEAD"); + * var tree = yield repo.loadAs("tree", commit.tree); + * + * I'm using yield syntax because it's simpler, you can use callbacks instead if you prefer. + */ + loadAs(type:string, hash:string, callback:(err:any, body:any) => void):void; + + /** + * Another convenience wrapper, this time to save objects as a specefic type. The body must be in the right format. + * + * var blobHash = yield repo.saveAs("blob", binaryData); + * var treeHash = yield repo.saveAs("tree", [ + * { mode: 0100644, name: "file.dat", hash: blobHash } + * ]); + * var commitHash = yield repo.saveAs("commit", { + * tree: treeHash, + * author: { name: "Tim Caswell", email: "tim@creationix.com", date: new Date }, + * message: "Save the blob" + * }); + */ + saveAs(type:string, body:any, callback:(err:any, hash:string) => void):void; + + /** + * Remove an object. + */ + remove(hash:string, callback:(err:any) => void):void; + + /** + * Import a packfile stream (simple-stream format) into the current database. This is used mostly for clone and fetch operations where the stream comes from a remote repo. + * + * opts is a hash of optional configs. + * + * opts.onProgress(progress) - listen to the git progress channel by passing in a event listener. + * opts.onError(error) - same thing, but for the error channel. + * opts.deline - If this is truthy, the progress and error messages will be rechunked to be whole lines. They usually come jumbled in the internal sidechannel. + */ + unpack(packFileStream:any, opts:Object, callback:(err:any) => void):void; + + /** + * This convenience wrapper creates a readable stream of the history sorted by author date. + * If you want full history, pass in HEAD for the hash. + */ + logWalk(hashish:string, callback:(err:any, log_stream:any) => void):void; + + /** + * This helper will return a stream of files suitable for traversing a file tree as a linear stream. The hash can be a ref to a commit, a commit hash or a tree hash directly. + */ + treeWalk(hashish:string, callback:(err:any, file_stream:any) => void):void; + + /** + * This is the generic helper that logWalk and treeWalk use. See js-git.js source for usage. + */ + walk(seed:any, scan:any, loadKey:any, compare:any):any; + + /** + * Resolve a ref, branch, or tag to a real hash. + */ + resolveHashish(hashish:string, callback:(err:any, hash:string) => void):void; + + /** + * Update whatever branch HEAD is pointing to so that it points to hash. + * You'll usually want to do this after creating a new commint in the HEAD branch. + */ + updateHead(hash:string, callback:(err:any) => void):void; + + /** + * Read the current active branch. + */ + getHead(callback:(err:any, ref_name:string) => void):void; + + /** + * Set the current active branch. + */ + setHead(ref:string, callback:(err:any) => void):void; + + /** + * Convenience wrapper that fetches from a remote instance and calls repo.unpack with the resulting packfile stream for you. + */ + fetch(remote:Remote, opts:Object, callback:(err:any) => void):void; + } +} From ce05d531f6f6fe59723d200cc5bcd5dda8394de2 Mon Sep 17 00:00:00 2001 From: Bartvds Date: Thu, 16 Jan 2014 06:27:06 +0100 Subject: [PATCH 19/42] fixed js-git implicit any --- js-git/js-git.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/js-git/js-git.d.ts b/js-git/js-git.d.ts index b85cafbca..03b99b8bd 100644 --- a/js-git/js-git.d.ts +++ b/js-git/js-git.d.ts @@ -40,9 +40,9 @@ declare module JSGit { hostname:string; pathname:string; - discover(callback:(err:any, refs:StringMap) => void); - fetch(repo:Repo, opts:Object, callback:(err:any) => void); - close(callback?:(err:any) => void); + discover(callback:(err:any, refs:StringMap) => void):void; + fetch(repo:Repo, opts:Object, callback:(err:any) => void):void; + close(callback?:(err:any) => void):void; } interface DB { From 3f692cc3b6bfb62468d169e7810e77be8847e946 Mon Sep 17 00:00:00 2001 From: John Reilly Date: Thu, 16 Jan 2014 13:23:16 +0000 Subject: [PATCH 20/42] jQuery: added param JSDoc and test suite --- jquery/jquery-tests.ts | 52 ++++++++++++++++++++++++++++++++++++++++++ jquery/jquery.d.ts | 15 ++++++++++++ 2 files changed, 67 insertions(+) diff --git a/jquery/jquery-tests.ts b/jquery/jquery-tests.ts index 518e8a45d..0ad13a4bf 100644 --- a/jquery/jquery-tests.ts +++ b/jquery/jquery-tests.ts @@ -1876,6 +1876,58 @@ function test_scrollTop() { $("div.demo").scrollTop(300); } +function test_param() { + + function test1() { + var myObject = { + a: { + one: 1, + two: 2, + three: 3 + }, + b: [1, 2, 3] + }; + var recursiveEncoded = $.param(myObject); + var recursiveDecoded = decodeURIComponent($.param(myObject)); + + alert(recursiveEncoded); + alert(recursiveDecoded); + } + + function test2() { + var myObject = { + a: { + one: 1, + two: 2, + three: 3 + }, + b: [1, 2, 3] + }; + var shallowEncoded = $.param(myObject, true); + var shallowDecoded = decodeURIComponent(shallowEncoded); + + alert(shallowEncoded); + alert(shallowDecoded); + } + + var params = { width: 1680, height: 1050 }; + var str = jQuery.param(params); + $("#results").text(str); + + // <=1.3.2: + $.param({ a: [2, 3, 4] }); // "a=2&a=3&a=4" + // >=1.4: + $.param({ a: [2, 3, 4] }); // "a[]=2&a[]=3&a[]=4" + + // <=1.3.2: + $.param({ a: { b: 1, c: 2 }, d: [3, 4, { e: 5 }] }); + // "a=[object+Object]&d=3&d=4&d=[object+Object]" + + // >=1.4: + $.param({ a: { b: 1, c: 2 }, d: [3, 4, { e: 5 }] }); + // "a[b]=1&a[c]=2&d[]=3&d[]=4&d[2][e]=5" +} + function test_position() { var p = $("p:first"); var position = p.position(); diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index 1dab9e790..d690a649e 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -333,7 +333,19 @@ interface JQuerySupport { } interface JQueryParam { + /** + * Create a serialized representation of an array or object, suitable for use in a URL query string or Ajax request. + * + * @param obj An array or object to serialize. + */ (obj: any): string; + + /** + * Create a serialized representation of an array or object, suitable for use in a URL query string or Ajax request. + * + * @param obj An array or object to serialize. + * @param traditional A Boolean indicating whether to perform a traditional "shallow" serialization. + */ (obj: any, traditional: boolean): string; } @@ -510,6 +522,9 @@ interface JQueryStatic { */ getScript(url: string, success?: (script: string, textStatus: string, jqXHR: JQueryXHR) => any): JQueryXHR; + /** + * Create a serialized representation of an array or object, suitable for use in a URL query string or Ajax request. + */ param: JQueryParam; /** From 07041a3088e7284058df81a35961b61d5faff106 Mon Sep 17 00:00:00 2001 From: John Reilly Date: Thu, 16 Jan 2014 13:38:16 +0000 Subject: [PATCH 21/42] jQuery: queue, dequeue, hasdata added queue test suite --- jquery/jquery-tests.ts | 62 ++++++++++++++++++++++++++++++++++++++++++ jquery/jquery.d.ts | 45 ++++++++++++++++++++++++++---- 2 files changed, 102 insertions(+), 5 deletions(-) diff --git a/jquery/jquery-tests.ts b/jquery/jquery-tests.ts index 0ad13a4bf..e024f1dc6 100644 --- a/jquery/jquery-tests.ts +++ b/jquery/jquery-tests.ts @@ -1095,6 +1095,68 @@ function test_dequeue() { }); } +function test_queue() { + + $("#show").click(function () { + var n = jQuery.queue($("div")[0], "fx"); + $("span").text("Queue length is: " + n.length); + }); + + function runIt() { + $("div") + .show("slow") + .animate({ + left: "+=200" + }, 2000) + .slideToggle(1000) + .slideToggle("fast") + .animate({ + left: "-=200" + }, 1500) + .hide("slow") + .show(1200) + .slideUp("normal", runIt); + } + + runIt(); + + $(document.body).click(function () { + var divs = $("div") + .show("slow") + .animate({ left: "+=200" }, 2000); + jQuery.queue(divs[0], "fx", function () { + $(this).addClass("newcolor"); + jQuery.dequeue(this); + }); + divs.animate({ left: "-=200" }, 500); + jQuery.queue(divs[0], "fx", function () { + $(this).removeClass("newcolor"); + jQuery.dequeue(this); + }); + divs.slideUp(); + }); + + $("#start").click(function () { + var divs = $("div") + .show("slow") + .animate({ left: "+=200" }, 5000); + jQuery.queue(divs[0], "fx", function () { + $(this).addClass("newcolor"); + jQuery.dequeue(this); + }); + divs.animate({ left: "-=200" }, 1500); + jQuery.queue(divs[0], "fx", function () { + $(this).removeClass("newcolor"); + jQuery.dequeue(this); + }); + divs.slideUp(); + }); + $("#stop").click(function () { + jQuery.queue($("div")[0], "fx", []); + $("div").stop(); + }); +} + function test_detach() { $("p").click(function () { $(this).toggleClass("off"); diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index d690a649e..df6256293 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -423,9 +423,9 @@ interface JQueryEasing { swing(p: number): number; } -/* - Static members of jQuery (those on $ and jQuery themselves) -*/ +/** + * Static members of jQuery (those on $ and jQuery themselves) + */ interface JQueryStatic { /** @@ -659,6 +659,9 @@ interface JQueryStatic { */ when(...deferreds: any[]): JQueryPromise; + /** + * Hook directly into jQuery to override how particular CSS properties are retrieved or set, normalize CSS property naming, or create custom properties. + */ cssHooks: { [key: string]: any; }; cssNumber: any; @@ -684,12 +687,44 @@ interface JQueryStatic { */ data(element: Element): any; - dequeue(element: Element, queueName?: string): any; + /** + * Execute the next function on the queue for the matched element. + * + * @param element A DOM element from which to remove and execute a queued function. + * @param queueName A string containing the name of the queue. Defaults to fx, the standard effects queue. + */ + dequeue(element: Element, queueName?: string): void; + /** + * Determine whether an element has any jQuery data associated with it. + * + * @param element A DOM element to be checked for data. + */ hasData(element: Element): boolean; + /** + * Show the queue of functions to be executed on the matched element. + * + * @param element A DOM element to inspect for an attached queue. + * @param queueName A string containing the name of the queue. Defaults to fx, the standard effects queue. + */ queue(element: Element, queueName?: string): any[]; - queue(element: Element, queueName: string, newQueueOrCallback: any): JQuery; + /** + * Manipulate the queue of functions to be executed on the matched element. + * + * @param element A DOM element where the array of queued functions is attached. + * @param queueName A string containing the name of the queue. Defaults to fx, the standard effects queue. + * @param newQueue An array of functions to replace the current queue contents. + */ + queue(element: Element, queueName: string, newQueue: Function[]): JQuery; + /** + * Manipulate the queue of functions to be executed on the matched element. + * + * @param element A DOM element on which to add a queued function. + * @param queueName A string containing the name of the queue. Defaults to fx, the standard effects queue. + * @param callback The new function to add to the queue. + */ + queue(element: Element, queueName: string, callback: Function): JQuery; removeData(element: Element, name?: string): JQuery; From 02348d3eb0d88f81b526e4a20ca358ce49692e0c Mon Sep 17 00:00:00 2001 From: John Reilly Date: Thu, 16 Jan 2014 14:00:56 +0000 Subject: [PATCH 22/42] jQuery: added proxy / removeData JSDoc + tests --- jquery/jquery-tests.ts | 109 +++++++++++++++++++++++++++++++++++++++++ jquery/jquery.d.ts | 50 ++++++++++++++++--- 2 files changed, 153 insertions(+), 6 deletions(-) diff --git a/jquery/jquery-tests.ts b/jquery/jquery-tests.ts index e024f1dc6..95fed2635 100644 --- a/jquery/jquery-tests.ts +++ b/jquery/jquery-tests.ts @@ -946,6 +946,17 @@ function test_removeData() { $("span:eq(3)").text("" + $("div").data("test2")); } +function test_jQuery_removeData() { + var div = $("div")[0]; + $("span:eq(0)").text("" + $("div").data("test1")); + jQuery.data(div, "test1", "VALUE-1"); + jQuery.data(div, "test2", "VALUE-2"); + $("span:eq(1)").text("" + jQuery.data(div, "test1")); + jQuery.removeData(div, "test1"); + $("span:eq(2)").text("" + jQuery.data(div, "test1")); + $("span:eq(3)").text("" + jQuery.data(div, "test2")); +} + function test_dblclick() { $('#target').dblclick(function () { alert('Handler for .dblclick() called.'); @@ -1731,6 +1742,104 @@ function test_hasData() { $p.append(jQuery.hasData(p) + " "); } +function test_jQuery_proxy() { + + function test1() { + var me = { + type: "zombie", + test: function (event?) { + // Without proxy, `this` would refer to the event target + // use event.target to reference that element. + var element = event.target; + $(element).css("background-color", "red"); + + // With proxy, `this` refers to the me object encapsulating + // this function. + $("#log").append("Hello " + this.type + "
"); + $("#test").off("click", this.test); + } + }; + + var you = { + type: "person", + test: function (event?) { + $("#log").append(this.type + " "); + } + }; + + // Execute you.test() in the context of the `you` object + // no matter where it is called + // i.e. the `this` keyword will refer to `you` + var youClick = $.proxy(you.test, you); + + // attach click handlers to #test + $("#test") + // this === "zombie"; handler unbound after first click + .on("click", $.proxy(me.test, me)) + + // this === "person" + .on("click", youClick) + + // this === "zombie" + .on("click", $.proxy(you.test, me)) + + // this === "