From 33735286ede08b854b666e01b25bd9586f8b0352 Mon Sep 17 00:00:00 2001 From: david pichsenmeister Date: Tue, 4 Feb 2014 15:14:35 +0100 Subject: [PATCH 01/28] added typing of mozilla localForage library --- localForage/localForage.d.ts | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 localForage/localForage.d.ts diff --git a/localForage/localForage.d.ts b/localForage/localForage.d.ts new file mode 100644 index 0000000000..71ccaba3c2 --- /dev/null +++ b/localForage/localForage.d.ts @@ -0,0 +1,26 @@ +// Type definitions for Mozilla's localForage +// Project: https://github.com/mozilla/localforage +// Definitions by: david pichsenmeister +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module lf { + interface ILocalForage { + clear(): void + key(index: number): T + length: number + getItem(key: string, callback: ICallback) + getItem(key: string): IPromise + setItem(key: string, value: T, callback: ICallback) + setItem(key: string, value: T): IPromise + removeItem(key: string, callback: ICallback) + removeItem(key: string): IPromise + } + + interface ICallback { + (data: T): void + } + + interface IPromise { + then(callback: ICallback): void + } +} \ No newline at end of file From 0aa867fe9aad08e77de3d2038f6fa3995299692c Mon Sep 17 00:00:00 2001 From: scriby Date: Tue, 11 Feb 2014 15:40:08 -0500 Subject: [PATCH 02/28] Add support for app.patch --- express/express.d.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/express/express.d.ts b/express/express.d.ts index b97888998f..6fc3c0fec2 100644 --- a/express/express.d.ts +++ b/express/express.d.ts @@ -122,6 +122,10 @@ declare module "express" { del(name: string, ...handlers: RequestFunction[]): T; del(name: RegExp, ...handlers: RequestFunction[]): T; + + patch(name: string, ...handlers: RequestFunction[]): T; + + patch(name: RegExp, ...handlers: RequestFunction[]): T; } export class Router implements IRouter { @@ -152,6 +156,10 @@ declare module "express" { del(name: string, ...handlers: RequestFunction[]): Router; del(name: RegExp, ...handlers: RequestFunction[]): Router; + + patch(name: string, ...handlers: RequestFunction[]): Router; + + patch(name: RegExp, ...handlers: RequestFunction[]): Router; } interface Handler { From 4924c77584176c4515aeb11facd5074bed692921 Mon Sep 17 00:00:00 2001 From: Carl de Billy Date: Tue, 11 Feb 2014 23:25:19 -0500 Subject: [PATCH 03/28] Fixed generics return value of Window and Buffer operators Generics values where incorrect. The correct result for windowWithXXX operators is Observable> and for bufferWithXXX it's Observable --- rx.js/rx.time.d.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/rx.js/rx.time.d.ts b/rx.js/rx.time.d.ts index 1ee0d4f22f..013665517d 100644 --- a/rx.js/rx.time.d.ts +++ b/rx.js/rx.time.d.ts @@ -25,12 +25,12 @@ declare module Rx { delay(dueTime: number, scheduler?: IScheduler): Observable; throttle(dueTime: number, scheduler?: IScheduler): Observable; - windowWithTime(timeSpan: number, timeShift: number, scheduler?: IScheduler): Observable; - windowWithTime(timeSpan: number, scheduler?: IScheduler): Observable; - windowWithTimeOrCount(timeSpan: number, count: number, scheduler?: IScheduler): Observable; - bufferWithTime(timeSpan: number, timeShift: number, scheduler?: IScheduler): Observable; - bufferWithTime(timeSpan: number, scheduler?: IScheduler): Observable; - bufferWithTimeOrCount(timeSpan: number, count: number, scheduler?: IScheduler): Observable; + windowWithTime(timeSpan: number, timeShift: number, scheduler?: IScheduler): Observable>; + windowWithTime(timeSpan: number, scheduler?: IScheduler): Observable>; + windowWithTimeOrCount(timeSpan: number, count: number, scheduler?: IScheduler): Observable>; + bufferWithTime(timeSpan: number, timeShift: number, scheduler?: IScheduler): Observable; + bufferWithTime(timeSpan: number, scheduler?: IScheduler): Observable; + bufferWithTimeOrCount(timeSpan: number, count: number, scheduler?: IScheduler): Observable; timeInterval(scheduler?: IScheduler): Observable>; timestamp(scheduler?: IScheduler): Observable>; sample(interval: number, scheduler?: IScheduler): Observable; From 586de634a88bf01828fc36fcf5d4c7a445701de9 Mon Sep 17 00:00:00 2001 From: John Reilly Date: Tue, 18 Feb 2014 16:52:02 +0000 Subject: [PATCH 04/28] jQuery: JSDoc'd bind --- jquery/jquery-tests.ts | 2 +- jquery/jquery.d.ts | 34 ++++++++++++++++++++++++++++++++-- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/jquery/jquery-tests.ts b/jquery/jquery-tests.ts index 57ba838ee3..7177b13330 100644 --- a/jquery/jquery-tests.ts +++ b/jquery/jquery-tests.ts @@ -568,7 +568,7 @@ function test_bind() { $("form").bind("submit", function (event) { event.stopPropagation(); }); - $("p").bind("myCustomEvent", function (e, myName, myValue) { + $("p").bind("myCustomEvent", function (e, myName?, myValue?) { $(this).text(myName + ", hi there!"); $("span").stop().css("opacity", 1) .text("myName = " + myName) diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index 235022bf99..87f3a9afd5 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -2028,12 +2028,42 @@ interface JQuery { */ toggle(showOrHide: boolean): JQuery; - // Events + /** + * Attach a handler to an event for the elements. + * + * @param eventType A string containing one or more DOM event types, such as "click" or "submit," or custom event names. + * @param eventData An object containing data that will be passed to the event handler. + * @param handler A function to execute each time the event is triggered. + */ bind(eventType: string, eventData: any, handler: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Attach a handler to an event for the elements. + * + * @param eventType A string containing one or more DOM event types, such as "click" or "submit," or custom event names. + * @param handler A function to execute each time the event is triggered. + */ bind(eventType: string, handler: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Attach a handler to an event for the elements. + * + * @param eventType A string containing one or more DOM event types, such as "click" or "submit," or custom event names. + * @param eventData An object containing data that will be passed to the event handler. + * @param preventBubble Setting the third argument to false will attach a function that prevents the default action from occurring and stops the event from bubbling. The default is true. + */ bind(eventType: string, eventData: any, preventBubble: boolean): JQuery; + /** + * Attach a handler to an event for the elements. + * + * @param eventType A string containing one or more DOM event types, such as "click" or "submit," or custom event names. + * @param preventBubble Setting the third argument to false will attach a function that prevents the default action from occurring and stops the event from bubbling. The default is true. + */ bind(eventType: string, preventBubble: boolean): JQuery; - bind(...events: any[]): JQuery; + /** + * Attach a handler to an event for the elements. + * + * @param events An object containing one or more DOM event types and functions to execute for them. + */ + bind(events: any): JQuery; blur(handler: (eventObject: JQueryEventObject) => any): JQuery; blur(eventData?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery; From b4ce3c8e6eb6eadd9ba167c580b3afb1bb241bca Mon Sep 17 00:00:00 2001 From: John Reilly Date: Tue, 18 Feb 2014 16:56:14 +0000 Subject: [PATCH 05/28] jQuery: JSDoc'd blur --- jquery/jquery.d.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index 87f3a9afd5..83f2288d0c 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -2065,7 +2065,22 @@ interface JQuery { */ bind(events: any): JQuery; + /** + * Trigger the "blur" event on an element + */ + blur(): JQuery; + /** + * Bind an event handler to the "blur" JavaScript event + * + * @param handler A function to execute each time the event is triggered. + */ blur(handler: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Bind an event handler to the "blur" JavaScript event + * + * @param eventData An object containing data that will be passed to the event handler. + * @param handler A function to execute each time the event is triggered. + */ blur(eventData?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery; /** From 83f6f736fdaab965c4c9aa8b9c417a0f0ee3dd81 Mon Sep 17 00:00:00 2001 From: Bart van der Schoor Date: Tue, 18 Feb 2014 22:19:36 +0100 Subject: [PATCH 06/28] set to private :cold_sweat: --- package.json | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 61c1dc6cdd..382b060bd2 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,8 @@ { + "private": true, "name": "DefinitelyTyped", "version": "0.0.0", - "scripts": { - "test": "node ./_infrastructure/tests/runner.js --tsc-version 0.9.5" - } + "scripts": { + "test": "node ./_infrastructure/tests/runner.js --tsc-version 0.9.5" + } } From a26949b652ef468890e5f480df704dfcee3af198 Mon Sep 17 00:00:00 2001 From: Bart van der Schoor Date: Tue, 18 Feb 2014 22:29:59 +0100 Subject: [PATCH 07/28] added CONTRIBUTING.md with link to wiki --- CONTRIBUTING.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000000..13053ce7ff --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1 @@ +Please see the [contribution guide](https://github.com/borisyankov/DefinitelyTyped/wiki/How-to-contribute) for information on how to contribute to this project. From 3e989b586a25149ea5b8ce33e9ffe621525db1d8 Mon Sep 17 00:00:00 2001 From: jraymakers Date: Wed, 19 Feb 2014 09:18:16 -0800 Subject: [PATCH 08/28] underscore: remove 'extends {}' constraint from each and map --- underscore/underscore.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/underscore/underscore.d.ts b/underscore/underscore.d.ts index 41b634081b..10e4ccb23a 100644 --- a/underscore/underscore.d.ts +++ b/underscore/underscore.d.ts @@ -100,7 +100,7 @@ interface UnderscoreStatic { * @param iterator Iterator function for each property on `obj`. * @param context 'this' object in `iterator`, optional. **/ - each( + each( object: _.Dictionary, iterator: _.ObjectIterator, context?: any): void; @@ -116,7 +116,7 @@ interface UnderscoreStatic { /** * @see _.each **/ - forEach( + forEach( object: _.Dictionary, iterator: _.ObjectIterator, context?: any): void; @@ -142,7 +142,7 @@ interface UnderscoreStatic { * @param context `this` object in `iterator`, optional. * @return The mapped object result. **/ - map( + map( object: _.Dictionary, iterator: _.ObjectIterator, context?: any): TResult[]; @@ -158,7 +158,7 @@ interface UnderscoreStatic { /** * @see _.map **/ - collect( + collect( object: _.Dictionary, iterator: _.ObjectIterator, context?: any): TResult[]; From d820bc739dfb068b00b620f7d7b675bfe16de425 Mon Sep 17 00:00:00 2001 From: pushplay Date: Wed, 19 Feb 2014 13:31:44 -0800 Subject: [PATCH 09/28] Added definitions for XSockets.net. --- xsockets/XSockets-tests.ts | 61 ++++++++++++++++++++++++++++ xsockets/XSockets-tests.ts.tscparams | 1 + xsockets/XSockets.d.ts | 38 +++++++++++++++++ xsockets/XSockets.d.ts.tscparams | 1 + 4 files changed, 101 insertions(+) create mode 100644 xsockets/XSockets-tests.ts create mode 100644 xsockets/XSockets-tests.ts.tscparams create mode 100644 xsockets/XSockets.d.ts create mode 100644 xsockets/XSockets.d.ts.tscparams diff --git a/xsockets/XSockets-tests.ts b/xsockets/XSockets-tests.ts new file mode 100644 index 0000000000..0b65bf9078 --- /dev/null +++ b/xsockets/XSockets-tests.ts @@ -0,0 +1,61 @@ +/// + +var conn = new XSockets.WebSocket('ws://localhost:4502/Generic'); + +conn.on(XSockets.Events.open,function (clientInfo) { + console.log('Open', clientInfo); +}); + +conn.on(XSockets.Events.onError, function (err) { + console.log('Error', err); +}); + +conn.on(XSockets.Events.close, function () { + console.log('Closed'); +}); + +conn.publish('foo', {text:'Hello Real-Time World'}); + +conn.on('foo', function(data) { + console.log('subscription to foo fired with data = ', data); +}); + +conn.unbind('foo'); + +conn.one('foo', function(data) { + console.log('subscription to foo fired with data = ', data); +}); + +conn.many('foo',4, function(data) { + console.log('subscription to foo fired with data = ', data); +}); + +conn.on('foo', function (data) { + console.log('subscription to foo fired with data = ', data); +}, function (confirmation) { + console.log('subscription confirmed',confirmation); + conn.publish('foo', { text: 'Hello Real-Time World' }); +}); + +conn.publish(XSockets.Events.storage.set, { + Key: "yourKey", + Value: { + Name: "John Doe", + Age: 40, + Likes: ["Beer", "Food", "Coffe"] + } +}); + +conn.publish(XSockets.Events.storage.remove, {Key: 'yourKey'}); + +conn.on(XSockets.Events.storage.getAll, function (data) { + data.forEach(function (item) { + console.log(item); + }); +}); + +conn.publish(XSockets.Events.storage.getAll, {}); + +conn.publish('set_MyProp',{value:'New Value'}); + +conn.on('get_MyProp',function(prop){console.log('Value Of MyProp',prop)}); \ No newline at end of file diff --git a/xsockets/XSockets-tests.ts.tscparams b/xsockets/XSockets-tests.ts.tscparams new file mode 100644 index 0000000000..3cc762b550 --- /dev/null +++ b/xsockets/XSockets-tests.ts.tscparams @@ -0,0 +1 @@ +"" \ No newline at end of file diff --git a/xsockets/XSockets.d.ts b/xsockets/XSockets.d.ts new file mode 100644 index 0000000000..b09e577a89 --- /dev/null +++ b/xsockets/XSockets.d.ts @@ -0,0 +1,38 @@ +// Type definitions for XSockets.NET 3.0 +// Project: http://xsockets.net/ +// Definitions by: Jeffery Grajkowski +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module XSockets { + export class WebSocket { + id: string; + constructor(url: string, subprotocol?: string, settings?: any); + on(event: string, handler: (data: any) => void, confirmation?: (arg: ConfirmationArgument) => void): void; + one(event: string, handler: (data: any) => void, confirmation?: (arg: ConfirmationArgument) => void): void; + many(event: string, times: number, handler: (data: any) => void, confirmation?: (arg: ConfirmationArgument) => void): void; + unbind(event: string): void; + publish(topic: string, data: any): void; + } + export interface ConfirmationArgument { + event: string; + } + export module Events { + export var close: string; + export var onBlob: string; + export var onError: string; + export module bindings { + export var completed: string; + } + export var open: string; + export module pubSub { + export var subscribe: string; + export var unsubscribe: string; + } + export module storage { + export var get: string; + export var getAll: string; + export var remove: string; + export var set: string; + } + } +} diff --git a/xsockets/XSockets.d.ts.tscparams b/xsockets/XSockets.d.ts.tscparams new file mode 100644 index 0000000000..3cc762b550 --- /dev/null +++ b/xsockets/XSockets.d.ts.tscparams @@ -0,0 +1 @@ +"" \ No newline at end of file From e88a5272edae42666fd7121e84a774c7ce54e50b Mon Sep 17 00:00:00 2001 From: Paul Vick Date: Wed, 19 Feb 2014 22:05:35 -0800 Subject: [PATCH 10/28] Fixes for jake definitions * There were a couple of definitions that were missing type decorations that would infer "any" implicitly. * Exec had four constructors that the actual jake object doesn't seem to have. Exec objects are always created using createExec. * The methods implementing node's EventEmitter didn't match the actual EventEmitter signatures, so I updated them. --- jake/jake.d.ts | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/jake/jake.d.ts b/jake/jake.d.ts index 349e08e52c..6995abc83c 100644 --- a/jake/jake.d.ts +++ b/jake/jake.d.ts @@ -114,7 +114,7 @@ declare module jake{ */ breakOnError?:boolean; } - export function exec(cmds:string[], callback?:()=>void, opts?:ExecOptions); + export function exec(cmds:string[], callback?:()=>void, opts?:ExecOptions):void; /** @@ -125,10 +125,6 @@ declare module jake{ * @event error When a shell-command */ export interface Exec extends NodeEventEmitter { - constructor(cmds:string[], callback?:()=>void, opts?:ExecOptions); - constructor(cmds:string[], opts?:ExecOptions, callback?:()=>void); - constructor(cmds:string, callback?:()=>void, opts?:ExecOptions); - constructor(cmds:string, opts?:ExecOptions, callback?:()=>void); append(cmd:string): void; run(): void; } @@ -208,11 +204,9 @@ declare module jake{ removeAllListeners(event?: string): NodeEventEmitter; setMaxListeners(n: number): void; listeners(event: string): Function[]; - emit(event: string, arg1?: any, arg2?: any): boolean; + emit(event: string, ...args: any[]): boolean; } - - export class DirectoryTask{ /** * @param name The name of the directory to create. @@ -275,7 +269,6 @@ declare module jake{ exclude(file:FileFilter[]): void; exclude(...file:FileFilter[]): void; - /** * Populates the FileList from the include/exclude rules with a list of * actual files @@ -377,12 +370,12 @@ declare module jake{ constructor(name:string, packageFiles:string[]); } - export function addListener(event: string, listener: Function); - export function on(event: string, listener: Function); - export function once(event: string, listener: Function): void; - export function removeListener(event: string, listener: Function): void; - export function removeAllListener(event: string): void; + export function addListener(event: string, listener: Function): NodeEventEmitter; + export function on(event: string, listener: Function): NodeEventEmitter; + export function once(event: string, listener: Function): NodeEventEmitter; + export function removeListener(event: string, listener: Function): NodeEventEmitter; + export function removeAllListener(event: string): NodeEventEmitter; export function setMaxListeners(n: number): void; - export function listeners(event: string): { Function; }[]; - export function emit(event: string, arg1?: any, arg2?: any): void; + export function listeners(event: string): Function[]; + export function emit(event: string, ...args: any[]): boolean; } From 6fccc6e510f8b4cf40246f205df906e1dac8d6a0 Mon Sep 17 00:00:00 2001 From: John Reilly Date: Thu, 20 Feb 2014 11:52:31 +0000 Subject: [PATCH 11/28] jQuery: fix to jquerymobile tests --- jquerymobile/jquerymobile-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jquerymobile/jquerymobile-tests.ts b/jquerymobile/jquerymobile-tests.ts index 19231849f4..b28d308a02 100644 --- a/jquerymobile/jquerymobile-tests.ts +++ b/jquerymobile/jquerymobile-tests.ts @@ -71,7 +71,7 @@ function test_pagesDialogs() { } }); - $(document).bind("pagebeforechange", function (e, data) { + $(document).bind("pagebeforechange", function (e, data?) { if (typeof data.toPage === "string") { var u = $.mobile.path.parseUrl(data.toPage), re = /^#category-item/; From f4e9a367db89730a1b2acaf57dd7085815566e6b Mon Sep 17 00:00:00 2001 From: John Reilly Date: Thu, 20 Feb 2014 16:58:11 +0000 Subject: [PATCH 12/28] jQuery: and fixed Sammy too --- sammyjs/sammyjs-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sammyjs/sammyjs-tests.ts b/sammyjs/sammyjs-tests.ts index da0da616e8..1aa151d6ea 100644 --- a/sammyjs/sammyjs-tests.ts +++ b/sammyjs/sammyjs-tests.ts @@ -422,7 +422,7 @@ function test_misc() { }); store = new Sammy.Store({ name: 'kvo' }); - $('body').bind('set-kvo-foo', function (e, data) { + $('body').bind('set-kvo-foo', function (e, data?) { Sammy.log(data.key + ' changed to ' + data.value); }); store.set('foo', 'bar'); From b875f439c4ff0e191c5a6a64d70bd6b029cfcca9 Mon Sep 17 00:00:00 2001 From: SomaticIT Date: Fri, 21 Feb 2014 01:04:46 +0100 Subject: [PATCH 13/28] Add moment amd definition (require shim) --- moment/moment.d.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/moment/moment.d.ts b/moment/moment.d.ts index 4bc63c8075..0d7affcb2d 100644 --- a/moment/moment.d.ts +++ b/moment/moment.d.ts @@ -324,3 +324,7 @@ interface MomentStatic { } declare var moment: MomentStatic; + +declare module "moment" { + export = moment; +} From 699ad8ec9f041b12d923b9f76df6b89fcd0a3377 Mon Sep 17 00:00:00 2001 From: david pichsenmeister Date: Fri, 21 Feb 2014 15:03:21 +0100 Subject: [PATCH 14/28] added tests --- README.md | 1 + localForage/localForage-tests.ts | 34 ++++++++++++++++++++++++++++++++ localForage/localForage.d.ts | 6 +++--- 3 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 localForage/localForage-tests.ts diff --git a/README.md b/README.md index ab4a8cdaef..2095f510bf 100755 --- a/README.md +++ b/README.md @@ -178,6 +178,7 @@ List of Definitions * [Levelup](https://github.com/rvagg/node-levelup) (by [Bret Little](https://github.com/blittle)) * [linq.js](http://linqjs.codeplex.com/) (by [Marcin Najder](https://github.com/marcinnajder)) * [Livestamp.js](https://github.com/mattbradley/livestampjs) (by [Vincent Bortone](https://github.com/vbortone)) +* [localForage](https://github.com/mozilla/localForage) (by [david pichsenmeister](https://github.com/3x14159265)) * [Lodash](http://lodash.com/) (by [Brian Zengel](https://github.com/bczengel)) * [Logg](https://github.com/dpup/node-logg) (by [Bret Little](https://github.com/blittle)) * [Marked](https://github.com/chjj/marked) (by [William Orr](https://github.com/worr)) diff --git a/localForage/localForage-tests.ts b/localForage/localForage-tests.ts new file mode 100644 index 0000000000..f1a416dcf7 --- /dev/null +++ b/localForage/localForage-tests.ts @@ -0,0 +1,34 @@ +/// + +declare var localForage: lf.ILocalForage +declare var callback: lf.ICallback +declare var promise: lf.IPromise + +() => { + localForage.clear() + localForage.length + localForage.key(0) + + localForage.getItem("key", (str: string) => { + var newStr: string = str + }) + localForage.getItem("key").then((str: string) => { + var newStr: string = str + }) + + localForage.setItem("key", "value", (str: string) => { + var newStr: string = str + }) + localForage.setItem("key", "value").then((str: string) => { + var newStr: string = str + }) + + localForage.removeItem("key", (str: string) => { + var newStr: string = str + }) + localForage.removeItem("key").then((str: string) => { + var newStr: string = str + }) + + promise.then(callback) +} diff --git a/localForage/localForage.d.ts b/localForage/localForage.d.ts index 71ccaba3c2..c3d0371d00 100644 --- a/localForage/localForage.d.ts +++ b/localForage/localForage.d.ts @@ -8,11 +8,11 @@ declare module lf { clear(): void key(index: number): T length: number - getItem(key: string, callback: ICallback) + getItem(key: string, callback: ICallback): void getItem(key: string): IPromise - setItem(key: string, value: T, callback: ICallback) + setItem(key: string, value: T, callback: ICallback): void setItem(key: string, value: T): IPromise - removeItem(key: string, callback: ICallback) + removeItem(key: string, callback: ICallback): void removeItem(key: string): IPromise } From 301188b6bfb1f11461f65389de56e35025d1ede4 Mon Sep 17 00:00:00 2001 From: rmoudy Date: Fri, 21 Feb 2014 08:22:18 -0600 Subject: [PATCH 15/28] Update three.d.ts Added missing .userData property to Object3D --- threejs/three.d.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/threejs/three.d.ts b/threejs/three.d.ts index e2e923f87f..2767570333 100644 --- a/threejs/three.d.ts +++ b/threejs/three.d.ts @@ -1856,6 +1856,12 @@ declare module THREE { static defaultEulerOrder: string; // static defaultEulerOrder:EulerOrder; + + /** + * An object that can be used to store custom data about the Object3d. + * It should not hold references to functions as these will not be cloned. + */ + userData: any; } var Object3DIdCount: number; From bc8eb1b106a19fec56838bc471df1d12d16fef74 Mon Sep 17 00:00:00 2001 From: gscshoyru Date: Fri, 21 Feb 2014 11:21:32 -0500 Subject: [PATCH 16/28] Change resolver type to Function in lodash.d.ts Change to support functions with arbitrary number of inputs, not just one. --- lodash/lodash.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index b40a59f2b1..0afd193702 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -2672,7 +2672,7 @@ declare module _ { **/ memoize( func: T, - resolver?: (n: any) => string): T; + resolver?: Function): T; } //_.once From 3824f54c02943d5cd38a55c1dc9c08b9cdd50bde Mon Sep 17 00:00:00 2001 From: Bart van der Schoor Date: Sat, 22 Feb 2014 01:26:56 +0100 Subject: [PATCH 17/28] temporary removed link to tsdpm.com until Diullei updates the DNS to the github pages --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 5e94c6003f..2628d4b8f9 100755 --- a/README.md +++ b/README.md @@ -21,8 +21,7 @@ See the section: [How to contribute](https://github.com/borisyankov/DefinitelyTy Other means to get the definitions ---------------------------------- * [NuGet packages](http://nuget.org/packages?q=DefinitelyTyped) -* [TypeScript definition package manager](https://github.com/Diullei/tsd) -* [tsdpm](http://www.tsdpm.com/) - Online search +* [TypeScript Definition package manager](https://github.com/DefinitelyTyped/tsd) List of Definitions ------------------- From cc33dd64a40e819db960a3b06c73bf7c0494163d Mon Sep 17 00:00:00 2001 From: Bart van der Schoor Date: Sat, 22 Feb 2014 19:51:18 +0100 Subject: [PATCH 18/28] fixed bluebird (dynamic version) mistake in test name added 'preliminary typings' note to definitions --- bluebird/{bluebird-test.ts => bluebird-tests.ts} | 0 bluebird/bluebird.d.ts | 10 ++++++++++ 2 files changed, 10 insertions(+) rename bluebird/{bluebird-test.ts => bluebird-tests.ts} (100%) diff --git a/bluebird/bluebird-test.ts b/bluebird/bluebird-tests.ts similarity index 100% rename from bluebird/bluebird-test.ts rename to bluebird/bluebird-tests.ts diff --git a/bluebird/bluebird.d.ts b/bluebird/bluebird.d.ts index c05f8b02b8..4706991439 100644 --- a/bluebird/bluebird.d.ts +++ b/bluebird/bluebird.d.ts @@ -3,6 +3,13 @@ // Definitions by: Bart van der Schoor // Definitions: https://github.com/borisyankov/DefinitelyTyped +// note: these are preliminary typings using `any`: the generic versions are under construction, see: + +// https://github.com/borisyankov/DefinitelyTyped/issues/1563 + +// https://github.com/borisyankov/DefinitelyTyped/tree/def/bluebird + + declare module Bluebird { interface ArrayLike { @@ -496,3 +503,6 @@ declare module Bluebird { filter(values:any[], filterer:(item:any, index?:number, arrayLength?:number) => any):Promise; } } +declare module 'bluebird' { + export = Bluebird; +} From 4ce66d41dc3973d29da86786e161c6c2306f94bc Mon Sep 17 00:00:00 2001 From: Bart van der Schoor Date: Sat, 22 Feb 2014 21:19:54 +0100 Subject: [PATCH 19/28] Fixed gruntjs done() callback signature --- gruntjs/gruntjs-tests.ts | 15 +++++++++++++-- gruntjs/gruntjs.d.ts | 7 ++++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/gruntjs/gruntjs-tests.ts b/gruntjs/gruntjs-tests.ts index f36b74d764..853cac370b 100644 --- a/gruntjs/gruntjs-tests.ts +++ b/gruntjs/gruntjs-tests.ts @@ -42,9 +42,20 @@ exports = (grunt: IGrunt) => { var valid = false; valid = valid && options.sourceRoot === "default"; valid = valid && currenttask.data.repeat > 0; - return valid; + + var done = this.async(); + done(); }); + grunt.registerMultiTask('task-1', "", function() { + var done = this.async(); + done(new Error('nope')); + }); + + grunt.registerMultiTask('task-2', "", function() { + var done = this.async(); + done(false); + }); // util methods var testOneArg = (a: number) => a * 2; @@ -61,4 +72,4 @@ exports = (grunt: IGrunt) => { fileMaps.length; fileMaps[0].src.length; fileMaps[0].dest; -}; \ No newline at end of file +}; diff --git a/gruntjs/gruntjs.d.ts b/gruntjs/gruntjs.d.ts index f601ce4fb6..cfe2825e41 100644 --- a/gruntjs/gruntjs.d.ts +++ b/gruntjs/gruntjs.d.ts @@ -816,9 +816,10 @@ declare module grunt { * Either false or an Error object may be passed to the done function * to instruct Grunt that the task has failed. */ - done(success: boolean): void; - done(error: Error): void; - done(result: any): void; + (success: boolean): void; + (error: Error): void; + (result: any): void; + (): void; } /** From c9007a305f2de31ead84ddd613f6635fdc33f43a Mon Sep 17 00:00:00 2001 From: Carl de Billy Date: Sun, 23 Feb 2014 10:01:02 -0500 Subject: [PATCH 20/28] Adjusted the result type of ajax requests The generic result type of ajax requests were incorrect. Now adjusted with right values. --- rx.js/rx.jquery.d.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/rx.js/rx.jquery.d.ts b/rx.js/rx.jquery.d.ts index f8513cf446..28183aa6f1 100644 --- a/rx.js/rx.jquery.d.ts +++ b/rx.js/rx.jquery.d.ts @@ -6,12 +6,18 @@ /// /// +interface RxJQueryResult { + data: T; + textStatus: string; + jqXHR: JQueryXHR; +} + interface JQueryStatic { - ajaxAsObservable(settings: JQueryAjaxSettings): Rx.Observable; - getAsObservable(url: string, data: any, dataType: string): Rx.Observable; - getJSONAsObservable(url: string, data: any): Rx.Observable; - getScriptAsObservable(url: string, data: any): Rx.Observable; - postAsObservable(url: string, data: any, dataType: string): Rx.Observable; + ajaxAsObservable(settings: JQueryAjaxSettings): Rx.Observable>; + getAsObservable(url: string, data: any, dataType: string): Rx.Observable>; + getJSONAsObservable(url: string, data: any): Rx.Observable>; + getScriptAsObservable(url: string, data: any): Rx.Observable>; + postAsObservable(url: string, data: any, dataType: string): Rx.Observable>; } interface JQuery { From 36ab9ba2a0bf62badeac14f2b71b7ed0c1718d26 Mon Sep 17 00:00:00 2001 From: Carl de Billy Date: Sun, 23 Feb 2014 10:05:19 -0500 Subject: [PATCH 21/28] Renamed RxJQueryResult to RxJQueryAjaxResult --- rx.js/rx.jquery.d.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/rx.js/rx.jquery.d.ts b/rx.js/rx.jquery.d.ts index 28183aa6f1..f2dcb284a7 100644 --- a/rx.js/rx.jquery.d.ts +++ b/rx.js/rx.jquery.d.ts @@ -6,18 +6,18 @@ /// /// -interface RxJQueryResult { +interface RxJQueryAjaxResult { data: T; textStatus: string; jqXHR: JQueryXHR; } interface JQueryStatic { - ajaxAsObservable(settings: JQueryAjaxSettings): Rx.Observable>; - getAsObservable(url: string, data: any, dataType: string): Rx.Observable>; - getJSONAsObservable(url: string, data: any): Rx.Observable>; - getScriptAsObservable(url: string, data: any): Rx.Observable>; - postAsObservable(url: string, data: any, dataType: string): Rx.Observable>; + ajaxAsObservable(settings: JQueryAjaxSettings): Rx.Observable>; + getAsObservable(url: string, data: any, dataType: string): Rx.Observable>; + getJSONAsObservable(url: string, data: any): Rx.Observable>; + getScriptAsObservable(url: string, data: any): Rx.Observable>; + postAsObservable(url: string, data: any, dataType: string): Rx.Observable>; } interface JQuery { From f8afb57dfec69aef8b5380442c0a144db881b862 Mon Sep 17 00:00:00 2001 From: Carl de Billy Date: Sun, 23 Feb 2014 10:23:20 -0500 Subject: [PATCH 22/28] Corrected Rx.IObservable => Rx.Observable The interface name changed in the RxJs definitions. Corrections reported here. --- knockout.rx/knockout.rx.d.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/knockout.rx/knockout.rx.d.ts b/knockout.rx/knockout.rx.d.ts index 2822b12f4f..f897bc7619 100644 --- a/knockout.rx/knockout.rx.d.ts +++ b/knockout.rx/knockout.rx.d.ts @@ -7,20 +7,20 @@ /// interface KnockoutSubscribableFunctions { - toObservable(event?: string): Rx.IObservable; - toObservable(event: string): Rx.IObservable; + toObservable(event?: string): Rx.Observable; + toObservable(event: string): Rx.Observable; } interface KnockoutObservableFunctions { - toObservableWithReplyLatest(): Rx.IObservable; + toObservableWithReplyLatest(): Rx.Observable; } interface KnockoutComputedFunctions { - toObservableWithReplyLatest(): Rx.IObservable; + toObservableWithReplyLatest(): Rx.Observable; } declare module Rx { - interface IObservable { + interface Observable { toKoSubscribable(): KnockoutSubscribable; toKoObservable(initialValue?: T): KnockoutObservable; } From 9a2a6fd4323eee5f5339ee0c422e12b1ab4ba2c5 Mon Sep 17 00:00:00 2001 From: Carl de Billy Date: Sun, 23 Feb 2014 10:28:13 -0500 Subject: [PATCH 23/28] Fixed unit test too --- knockout.rx/knockout.rx-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/knockout.rx/knockout.rx-tests.ts b/knockout.rx/knockout.rx-tests.ts index 674e9bb6a4..21a0a52484 100644 --- a/knockout.rx/knockout.rx-tests.ts +++ b/knockout.rx/knockout.rx-tests.ts @@ -1,6 +1,6 @@ /// -var ax: Rx.IObservable; +var ax: Rx.Observable; var ao = ax.toKoObservable(); From 490945c9dc9ac88dd27fdd689c28f616d34896d5 Mon Sep 17 00:00:00 2001 From: Donny Nadolny Date: Sun, 23 Feb 2014 16:50:26 -0500 Subject: [PATCH 24/28] Create jquery.cycle2.d.ts --- README.md | 1 + jquery.cycle2/jquery.cycle2-tests.ts | 50 ++++++++++ jquery.cycle2/jquery.cycle2.d.ts | 143 +++++++++++++++++++++++++++ 3 files changed, 194 insertions(+) create mode 100644 jquery.cycle2/jquery.cycle2-tests.ts create mode 100644 jquery.cycle2/jquery.cycle2.d.ts diff --git a/README.md b/README.md index 1ad14a26c8..f18d6fee08 100755 --- a/README.md +++ b/README.md @@ -132,6 +132,7 @@ List of Definitions * [jQuery.contextMenu](http://medialize.github.com/jQuery-contextMenu/) (by [Natan Vivo](https://github.com/nvivo/)) * [jQuery.Cookie](https://github.com/carhartl/jquery-cookie) (by [Roy Goode](https://github.com/RoyGoode)) * [jQuery.Cycle](http://jquery.malsup.com/cycle/) (by [François Guillot](http://fguillot.developpez.com/)) +* [jQuery.Cycle2](http://jquery.malsup.com/cycle2/) (by [Donny Nadolny](https://github.com/dnadolny)) * [jQuery.dataTables](http://www.datatables.net) (by [Armin Sander](https://github.com/pragmatrix)) * [jQuery.dynatree](http://code.google.com/p/dynatree/) (by [François de Campredon](https://github.com/fdecampredon)) * [jQuery.Flot](http://www.flotcharts.org/) (by [Matt Burland](https://github.com/burlandm)) diff --git a/jquery.cycle2/jquery.cycle2-tests.ts b/jquery.cycle2/jquery.cycle2-tests.ts new file mode 100644 index 0000000000..8a7eedf635 --- /dev/null +++ b/jquery.cycle2/jquery.cycle2-tests.ts @@ -0,0 +1,50 @@ +/// +/// + +// basic +$('#element').cycle(); + + +// code snippets from http://jquery.malsup.com/cycle2/api +$('.cycle-slideshow').cycle({ + speed: 600, + manualSpeed: 100 +}); + +var newSlide = ''; +$('.cycle-slideshow').cycle('add', newSlide); + +$('.cycle-slideshow').cycle('destroy'); + +// goto 3rd slide +$('.cycle-slideshow').cycle('goto', 2); + +$('.cycle-slideshow').cycle('next'); + +$('.cycle-slideshow').cycle('pause'); + +$('.cycle-slideshow').cycle('prev'); + +$('.cycle-slideshow').cycle('reinit'); + +// remove 2nd slide +$('.cycle-slideshow').cycle('remove', 1); + +$('.cycle-slideshow').cycle('resume'); + +$('.cycle-slideshow').cycle('stop'); + + +// from http://jquery.malsup.com/cycle2/demo/add.php +var images = [ + '', + '', + '' +]; + +$('button').one('click', function() { + for (var i=0; i < images.length; i++) { + $('.cycle-slideshow').cycle('add', images[i]); + } + $(this).prop('disabled', true) +}) diff --git a/jquery.cycle2/jquery.cycle2.d.ts b/jquery.cycle2/jquery.cycle2.d.ts new file mode 100644 index 0000000000..699d2aff87 --- /dev/null +++ b/jquery.cycle2/jquery.cycle2.d.ts @@ -0,0 +1,143 @@ +// Type definitions for jQuery Cycle2 version 2.1.2 (build 20140216) +// Project: http://jquery.malsup.com/cycle2/ (also https://github.com/malsup/cycle2) +// Definitions by: Donny Nadolny +// Definitions: https://github.com/borisyankov/DefinitelyTyped + + +/// + +interface JQuery { + cycle: JQueryCycle2.Cycle2; + + on(methodName: 'cycle-after', callback: (event: JQueryEventObject, optionHash: JQueryCycle2.OptionsWithState, outgoingSlideEl: Element, incomingSlideEl: Element, forwardFlag: boolean) => void): JQuery; + on(methodName: 'cycle-before', callback: (event: JQueryEventObject, optionHash: JQueryCycle2.OptionsWithState, outgoingSlideEl: Element, incomingSlideEl: Element, forwardFlag: boolean) => void): JQuery; + on(methodName: 'cycle-bootstrap', callback: (event: JQueryEventObject, optionHash: JQueryCycle2.OptionsWithState, API: JQueryCycle2.API) => void): JQuery; + on(methodName: 'cycle-destroyed', callback: (event: JQueryEventObject, optionHash: JQueryCycle2.OptionsWithState) => void): JQuery; + on(methodName: 'cycle-finished', callback: (event: JQueryEventObject, optionHash: JQueryCycle2.OptionsWithState) => void): JQuery; + on(methodName: 'cycle-initialized', callback: (event: JQueryEventObject, optionHash: JQueryCycle2.OptionsWithState) => void): JQuery; + on(methodName: 'cycle-next', callback: (event: JQueryEventObject, optionHash: JQueryCycle2.OptionsWithState) => void): JQuery; + on(methodName: 'cycle-pager-activated', callback: (event: JQueryEventObject, optionHash: JQueryCycle2.OptionsWithState) => void): JQuery; + on(methodName: 'cycle-paused', callback: (event: JQueryEventObject, optionHash: JQueryCycle2.OptionsWithState) => void): JQuery; + on(methodName: 'cycle-post-initialize', callback: (event: JQueryEventObject, optionHash: JQueryCycle2.OptionsWithState) => void): JQuery; + on(methodName: 'cycle-pre-initialize', callback: (event: JQueryEventObject, optionHash: JQueryCycle2.OptionsWithState) => void): JQuery; + on(methodName: 'cycle-prev', callback: (event: JQueryEventObject, optionHash: JQueryCycle2.OptionsWithState) => void): JQuery; + on(methodName: 'cycle-resumed', callback: (event: JQueryEventObject, optionHash: JQueryCycle2.OptionsWithState) => void): JQuery; + on(methodName: 'cycle-slide-added', callback: (event: JQueryEventObject, jQueryWrappedSlideEl: JQuery) => void): JQuery; + on(methodName: 'cycle-slide-removed', callback: (event: JQueryEventObject, indexOfSlideRemoved: number, removedSlideEl: Element) => void): JQuery; + on(methodName: 'cycle-stopped', callback: (event: JQueryEventObject, optionHash: JQueryCycle2.OptionsWithState) => void): JQuery; + on(methodName: 'cycle-transition-stopped', callback: (event: JQueryEventObject, optionHash: JQueryCycle2.OptionsWithState) => void): JQuery; + on(methodName: 'cycle-update-view', callback: (event: JQueryEventObject, optionHash: JQueryCycle2.OptionsWithState, slideOptionsHash: JQueryCycle2.OptionsWithState, currentSlideEl: Element) => void): JQuery; +} + + +declare module JQueryCycle2 { + interface Cycle2 { + (options?: Options): JQuery; + (methodName: 'add', newSlide: any): JQuery; // string or JQuery + (methodName: 'destroy'): JQuery; + (methodName: 'goto', index: number): JQuery; + (methodName: 'next'): JQuery; + (methodName: 'pause'): JQuery; + (methodName: 'prev'): JQuery; + (methodName: 'reinit'): JQuery; + (methodName: 'remove', index: number): JQuery; + (methodName: 'resume'): JQuery; + (methodName: 'stop'): JQuery; + (methodNameDontCallMe: string, arg1DontCallMe: any, arg2DontCallMe: any): JQuery; // catch-all, shouldn't ever be called though + } + + interface Options { + allowWrap?: boolean; + autoHeight?: any; // number or string + autoSelector?: string; + caption?: string; + captionTemplate?: string; + continueAuto?: boolean; + delay?: number; + disabledClass?: string; + easing?: string; + fx?: string; + hideNonActive?: boolean; + loader?: any; // boolean or 'wait' + log?: boolean; + loop?: number; + manualSpeed?: number; + manualTrump?: boolean; + next?: string; + nextEvent?: string; + overlay?: string; + overlayTemplate?: string; + pager?: string; + pagerActivateClass?: string; + pagerEvent?: string; + pagerTemplate?: string; + pauseOnHover?: any; // boolean or string + paused?: boolean; + prev?: string; + prevEvent?: string; + progressive?: string; + random?: boolean; + reverse?: boolean; + slideActiveClass?: string; + slideCss?: any; + slideClass?: string; + slides?: string; + speed?: number; + startingSlide?: number; + swipe?: boolean; + sync?: boolean; + timeout?: number; + tmplRegex?: string; + updateView?: number; + } + + interface OptionsWithState extends Options { + busy: boolean; + currSlide: number; + nextSlide: number; + paused: boolean; + slideNum: number; + slideCount: number; + } + + interface API { + add(slides: any, prepend?: boolean): void; // string or array or JQuery + addInitialSlides(): void; + advanceSlide(numberOfOpositions: number): boolean; // always false + buildPagerLink(slideOptionHash: Options, slide: any /*not sure*/): void; + buildSlideOpts(slide: any /*not sure*/): Options; + calcFirstSlide(): void; + calcNextSlide(): void; + calcTx(slideOptions: Options, manual: boolean): Transition; + destroy(): void; + doTransition(slideOptions: Options, currEl: Element, nextEl: Element, fwdFlag: boolean, callback: Function): void; + getComponent(nameOfComponent: string): JQuery; + getSlideIndex(slideElement: Element): number; + getSlideOpts(slideIndex: number): Options; + goto(index: number): void; + initSlide(slideOptions: Options, slide: any /*not sure*/, suggestedZindex: number): void; + initSlideshow(): void; + log(...args: any[]): void; + next(): void; + page(pagerEl: Element, targetEl: Element): void; + pause(): void; + postInitSlideshow(): void; + preInitSlideshow(): void; + prepareTx(manualFlag: boolean, fwdFlag: boolean): void; + prev(): void; + queueTransition(slideOptions: Options): void; + reinit(): void; + remove(slideIndexToRemove: number): void; + resume(): void; + stackSlides(currEl: Element, nextEl: Element, fwdFlag: boolean): void; + stop(): void; + stopTransition(): void; + tmpl(templateString: string, optionHash: Options, slideEl: Element): void; + trigger(eventName: String, ...args: any[]): void; + updateView(): void; + } + + interface Transition { + before(opts: Options, curr: Element, next: Element, fwd: boolean): void; + } +} \ No newline at end of file From 35e573697c1613a4fa293a2ff4eab333f24032b8 Mon Sep 17 00:00:00 2001 From: vvakame Date: Mon, 24 Feb 2014 11:48:00 +0900 Subject: [PATCH 25/28] remove not required .tscparams --- firebase/firebase-tests.ts.tscparams | 1 - firebase/firebase.d.ts.tscparams | 1 - jake/jake.d.ts.tscparams | 1 - xsockets/XSockets.d.ts.tscparams | 1 - 4 files changed, 4 deletions(-) delete mode 100644 firebase/firebase-tests.ts.tscparams delete mode 100644 firebase/firebase.d.ts.tscparams delete mode 100644 jake/jake.d.ts.tscparams delete mode 100644 xsockets/XSockets.d.ts.tscparams diff --git a/firebase/firebase-tests.ts.tscparams b/firebase/firebase-tests.ts.tscparams deleted file mode 100644 index e16c76dff8..0000000000 --- a/firebase/firebase-tests.ts.tscparams +++ /dev/null @@ -1 +0,0 @@ -"" diff --git a/firebase/firebase.d.ts.tscparams b/firebase/firebase.d.ts.tscparams deleted file mode 100644 index e16c76dff8..0000000000 --- a/firebase/firebase.d.ts.tscparams +++ /dev/null @@ -1 +0,0 @@ -"" diff --git a/jake/jake.d.ts.tscparams b/jake/jake.d.ts.tscparams deleted file mode 100644 index e16c76dff8..0000000000 --- a/jake/jake.d.ts.tscparams +++ /dev/null @@ -1 +0,0 @@ -"" diff --git a/xsockets/XSockets.d.ts.tscparams b/xsockets/XSockets.d.ts.tscparams deleted file mode 100644 index 3cc762b550..0000000000 --- a/xsockets/XSockets.d.ts.tscparams +++ /dev/null @@ -1 +0,0 @@ -"" \ No newline at end of file From 50bc863d8c142aefda434259ca60b6781bb7b087 Mon Sep 17 00:00:00 2001 From: John Reilly Date: Mon, 24 Feb 2014 14:49:28 +0000 Subject: [PATCH 26/28] jQuery: JSDoc'd unbind and added test suite --- jquery/jquery-tests.ts | 64 ++++++++++++++++++++++++++++++++++++++++++ jquery/jquery.d.ts | 23 +++++++++++++++ 2 files changed, 87 insertions(+) diff --git a/jquery/jquery-tests.ts b/jquery/jquery-tests.ts index 7177b13330..37cf5495ec 100644 --- a/jquery/jquery-tests.ts +++ b/jquery/jquery-tests.ts @@ -590,6 +590,70 @@ function test_bind() { }); } +function test_unbind() { + $("#foo").unbind(); + + $("#foo").unbind("click"); + + var handler = function () { + alert("The quick brown fox jumps over the lazy dog."); + }; + $("#foo").bind("click", handler); + $("#foo").unbind("click", handler); + + $("#foo").bind("click", function () { + alert("The quick brown fox jumps over the lazy dog."); + }); + + // Will NOT work + $("#foo").unbind("click", function () { + alert("The quick brown fox jumps over the lazy dog."); + }); + + $("#foo").bind("click.myEvents", handler); + + $("#foo").unbind("click"); + + $("#foo").unbind("click.myEvents"); + + $("#foo").unbind(".myEvents"); + + var timesClicked = 0; + $("#foo").bind("click", function (event) { + alert("The quick brown fox jumps over the lazy dog."); + timesClicked++; + if (timesClicked >= 3) { + $(this).unbind(event); + } + }); + + function aClick() { + $("div").show().fadeOut("slow"); + } + $("#bind").click(function () { + $("#theone") + .bind("click", aClick) + .text("Can Click!"); + }); + $("#unbind").click(function () { + $("#theone") + .unbind("click", aClick) + .text("Does nothing..."); + }); + + $("p").unbind(); + + $("p").unbind("click"); + + var foo = function () { + // Code to handle some kind of event + }; + + $("p").bind("click", foo); // ... Now foo will be called when paragraphs are clicked ... + + $("p").unbind("click", foo); // ... foo will no longer be called. +} + function test_blur() { $('#target').blur(function () { alert('Handler for .blur() called.'); diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index 83f2288d0c..76e5172f33 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -2605,10 +2605,33 @@ interface JQuery { */ trigger(event: JQueryEventObject, extraParameters?: Object): JQuery; + /** + * Execute all handlers attached to an element for an event. + * + * @param eventType A string containing a JavaScript event type, such as click or submit. + * @param extraParameters An array of additional parameters to pass along to the event handler. + */ triggerHandler(eventType: string, ...extraParameters: any[]): Object; + /** + * Remove a previously-attached event handler from the elements. + * + * @param eventType A string containing a JavaScript event type, such as click or submit. + * @param handler The function that is to be no longer executed. + */ unbind(eventType?: string, handler?: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Remove a previously-attached event handler from the elements. + * + * @param eventType A string containing a JavaScript event type, such as click or submit. + * @param fls Unbinds the corresponding 'return false' function that was bound using .bind( eventType, false ). + */ unbind(eventType: string, fls: boolean): JQuery; + /** + * Remove a previously-attached event handler from the elements. + * + * @param evt A JavaScript event object as passed to an event handler. + */ unbind(evt: any): JQuery; undelegate(): JQuery; From 69f36f7e0bbf6bd29415b5a609588c5f7d5286c4 Mon Sep 17 00:00:00 2001 From: John Reilly Date: Mon, 24 Feb 2014 14:57:10 +0000 Subject: [PATCH 27/28] jQuery: JSDoc'd undelegate added delegate / undelegate test suites --- jquery/jquery-tests.ts | 46 +++++++++++++++++++++++++++++++++++++++--- jquery/jquery.d.ts | 25 +++++++++++++++++++++-- 2 files changed, 66 insertions(+), 5 deletions(-) diff --git a/jquery/jquery-tests.ts b/jquery/jquery-tests.ts index 37cf5495ec..cfd4ae56f4 100644 --- a/jquery/jquery-tests.ts +++ b/jquery/jquery-tests.ts @@ -1183,7 +1183,6 @@ function test_delay() { }); } -/* Not existing, but not recommended either function test_delegate() { $("table").delegate("td", "click", function () { $(this).toggleClass("chosen"); @@ -1201,7 +1200,7 @@ function test_delegate() { $("body").delegate("a", "click", function (event) { event.preventDefault(); }); - $("body").delegate("p", "myCustomEvent", function (e, myName, myValue) { + $("body").delegate("p", "myCustomEvent", function (e, myName?, myValue?) { $(this).text("Hi there!"); $("span").stop().css("opacity", 1) .text("myName = " + myName) @@ -1211,7 +1210,48 @@ function test_delegate() { $("p").trigger("myCustomEvent"); }); } -*/ + +function test_undelegate() { + function aClick() { + $("div").show().fadeOut("slow"); + } + $("#bind").click(function () { + $("body") + .delegate("#theone", "click", aClick) + .find("#theone").text("Can Click!"); + }); + $("#unbind").click(function () { + $("body") + .undelegate("#theone", "click", aClick) + .find("#theone").text("Does nothing..."); + }); + + $("p").undelegate(); + + $("p").undelegate("click"); + + var foo = function () { + // Code to handle some kind of event + }; + + // ... Now foo will be called when paragraphs are clicked ... + $("body").delegate("p", "click", foo); + + // ... foo will no longer be called. + $("body").undelegate("p", "click", foo); + + var foo = function () { + // Code to handle some kind of event + }; + + // Delegate events under the ".whatever" namespace + $("form").delegate(":button", "click.whatever", foo); + + $("form").delegate("input[type='text'] ", "keypress.whatever", foo); + + // Unbind all events delegated under the ".whatever" namespace + $("form").undelegate(".whatever"); +} function test_dequeue() { $("button").click(function () { diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index 76e5172f33..329e0a177e 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -2634,9 +2634,30 @@ interface JQuery { */ unbind(evt: any): JQuery; + /** + * Remove a handler from the event for all elements which match the current selector, based upon a specific set of root elements. + */ undelegate(): JQuery; - undelegate(selector: any, eventType: string, handler?: (eventObject: JQueryEventObject) => any): JQuery; - undelegate(selector: any, events: any): JQuery; + /** + * Remove a handler from the event for all elements which match the current selector, based upon a specific set of root elements. + * + * @param selector A selector which will be used to filter the event results. + * @param eventType A string containing a JavaScript event type, such as "click" or "keydown" + * @param handler A function to execute at the time the event is triggered. + */ + undelegate(selector: string, eventType: string, handler?: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Remove a handler from the event for all elements which match the current selector, based upon a specific set of root elements. + * + * @param selector A selector which will be used to filter the event results. + * @param events An object of one or more event types and previously bound functions to unbind from them. + */ + undelegate(selector: string, events: Object): JQuery; + /** + * Remove a handler from the event for all elements which match the current selector, based upon a specific set of root elements. + * + * @param namespace A string containing a namespace to unbind all events from. + */ undelegate(namespace: string): JQuery; unload(handler: (eventObject: JQueryEventObject) => any): JQuery; From 99468aa382e6b3662a0d06006d139cab8ae9f90e Mon Sep 17 00:00:00 2001 From: Gabriele Genta Date: Mon, 24 Feb 2014 16:24:46 +0100 Subject: [PATCH 28/28] Made every type declaration explicit to prevent compilation errors when using the --noImplicitAny switch. --- restangular/restangular.d.ts | 50 ++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/restangular/restangular.d.ts b/restangular/restangular.d.ts index f6ea5b97b1..a5b7de20d9 100644 --- a/restangular/restangular.d.ts +++ b/restangular/restangular.d.ts @@ -24,46 +24,46 @@ interface Restangular extends RestangularCustom { all(route: string): RestangularCollection; allUrl(route: string, url: string): RestangularCollection; copy(fromElement: any): RestangularElement; - withConfig(configurer: (RestangularProvider) => any): Restangular; - restangularizeElement(parent: any, element: any, route: string, collection?, reqParams?): RestangularElement; + withConfig(configurer: (RestangularProvider: RestangularProvider) => any): Restangular; + restangularizeElement(parent: any, element: any, route: string, collection?: any, reqParams?: any): RestangularElement; restangularizeCollection(parent: any, element: any, route: string): RestangularCollection; stripRestangular(element: any): any; } interface RestangularElement extends Restangular { - get (queryParams?: any, headers?: any): ng.IPromise; + get(queryParams?: any, headers?: any): ng.IPromise; getList(subElement: any, queryParams?: any, headers?: any): ng.IPromise; put(queryParams?: any, headers?: any): ng.IPromise; - post(subElement, elementToPost, queryParams?, headers?): ng.IPromise; - remove(queryParams?, headers?): ng.IPromise; - head(queryParams?, headers?): ng.IPromise; - trace(queryParams?, headers?): ng.IPromise; - options(queryParams?, headers?): ng.IPromise; - patch(queryParams?, headers?): ng.IPromise; + post(subElement: any, elementToPost: any, queryParams?: any, headers?: any): ng.IPromise; + remove(queryParams?: any, headers?: any): ng.IPromise; + head(queryParams?: any, headers?: any): ng.IPromise; + trace(queryParams?: any, headers?: any): ng.IPromise; + options(queryParams?: any, headers?: any): ng.IPromise; + patch(queryParams?: any, headers?: any): ng.IPromise; withHttpConfig(httpConfig: RestangularRequestConfig): RestangularElement; getRestangularUrl(): string; } interface RestangularCollection extends Restangular { - getList(queryParams?, headers?): ng.IPromise; - post(elementToPost, queryParams?, headers?): ng.IPromise; - head(queryParams?, headers?): ng.IPromise; - trace(queryParams?, headers?): ng.IPromise; - options(queryParams?, headers?): ng.IPromise; - patch(queryParams?, headers?): ng.IPromise; - putElement(idx, params, headers): ng.IPromise; + getList(queryParams?: any, headers?: any): ng.IPromise; + post(elementToPost: any, queryParams?: any, headers?: any): ng.IPromise; + head(queryParams?: any, headers?: any): ng.IPromise; + trace(queryParams?: any, headers?: any): ng.IPromise; + options(queryParams?: any, headers?: any): ng.IPromise; + patch(queryParams?: any, headers?: any): ng.IPromise; + putElement(idx: any, params: any, headers: any): ng.IPromise; withHttpConfig(httpConfig: RestangularRequestConfig): RestangularCollection; getRestangularUrl(): string; } interface RestangularCustom { - customGET(path, params?, headers?): ng.IPromise; - customGETLIST(path, params?, headers?): ng.IPromise; - customDELETE(path, params?, headers?): ng.IPromise; - customPOST(path, params?, headers?, elem?): ng.IPromise; - customPUT(path, params?, headers?, elem?): ng.IPromise; - customOperation(operation, path, params?, headers?, elem?): ng.IPromise; - addRestangularMethod(name, operation, path?, params?, headers?, elem?): ng.IPromise; + customGET(path: string, params?: any, headers?: any): ng.IPromise; + customGETLIST(path: string, params?: any, headers?: any): ng.IPromise; + customDELETE(path: string, params?: any, headers?: any): ng.IPromise; + customPOST(path: string, params?: any, headers?: any, elem?: any): ng.IPromise; + customPUT(path: string, params?: any, headers?: any, elem?: any): ng.IPromise; + customOperation(operation: string, path: string, params?: any, headers?: any, elem?: any): ng.IPromise; + addRestangularMethod(name: string, operation: string, path?: string, params?: any, headers?: any, elem?: any): ng.IPromise; } interface RestangularProvider { @@ -76,8 +76,8 @@ interface RestangularProvider { setOnElemRestangularized(callback: (elem: any, isCollection: boolean, what: string, restangular: Restangular) => any): void; setResponseInterceptor(responseInterceptor: (data: any, operation: string, what: string, url: string, response: RestangularResponse, deferred: ng.IDeferred) => any): void; setResponseExtractor(responseInterceptor: (data: any, operation: string, what: string, url: string, response: RestangularResponse, deferred: ng.IDeferred) => any): void; - setRequestInterceptor(requestInterceptor: (element: any, operation: string, what: string, url: string) => any); - setFullRequestInterceptor(fullRequestInterceptor: (element: any, operation: string, what: string, url: string, headers: any, params: any) => {element: any; headers: any; params: any}); + setRequestInterceptor(requestInterceptor: (element: any, operation: string, what: string, url: string) => any): void; + setFullRequestInterceptor(fullRequestInterceptor: (element: any, operation: string, what: string, url: string, headers: any, params: any) => {element: any; headers: any; params: any}): void; setErrorInterceptor(errorInterceptor: (response: RestangularResponse) => any): void; setRestangularFields(fields: {[fieldName: string]: string}): void; setMethodOverriders(overriders: string[]): void;