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. diff --git a/README.md b/README.md index 5e94c6003f..f18d6fee08 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 ------------------- @@ -133,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)) @@ -182,6 +182,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/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; +} diff --git a/express/express.d.ts b/express/express.d.ts index 6d87249cdc..243aa41d4d 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 { 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/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; } /** 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; } 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/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 diff --git a/jquery/jquery-tests.ts b/jquery/jquery-tests.ts index 57ba838ee3..cfd4ae56f4 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) @@ -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.'); @@ -1119,7 +1183,6 @@ function test_delay() { }); } -/* Not existing, but not recommended either function test_delegate() { $("table").delegate("td", "click", function () { $(this).toggleClass("chosen"); @@ -1137,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) @@ -1147,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 235022bf99..329e0a177e 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -2028,14 +2028,59 @@ 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; + /** + * 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; /** @@ -2560,15 +2605,59 @@ 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; + /** + * 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; 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/; 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(); 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; } 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 new file mode 100644 index 0000000000..c3d0371d00 --- /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): void + getItem(key: string): IPromise + setItem(key: string, value: T, callback: ICallback): void + setItem(key: string, value: T): IPromise + removeItem(key: string, callback: ICallback): void + removeItem(key: string): IPromise + } + + interface ICallback { + (data: T): void + } + + interface IPromise { + then(callback: ICallback): void + } +} \ No newline at end of file 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 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; +} diff --git a/package.json b/package.json index 93f27fc421..5cbbac47de 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.7-59a846" - } + "scripts": { + "test": "node ./_infrastructure/tests/runner.js --tsc-version 0.9.7-59a846" + } } 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; diff --git a/rx.js/rx.jquery.d.ts b/rx.js/rx.jquery.d.ts index f8513cf446..f2dcb284a7 100644 --- a/rx.js/rx.jquery.d.ts +++ b/rx.js/rx.jquery.d.ts @@ -6,12 +6,18 @@ /// /// +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 { 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; 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'); 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; 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[]; 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; + } + } +}